]> git.ipfire.org Git - thirdparty/bash.git/blob - doc/bash.html
commit bash-20101025 snapshot
[thirdparty/bash.git] / doc / bash.html
1 <HTML><HEAD>
2 <TITLE>BASH(1) Manual Page</TITLE>
3 </HEAD>
4 <BODY><TABLE WIDTH=100%>
5 <TR>
6 <TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2010 September 6<TH ALIGN=RIGHT width=33%>BASH(1)
7 </TR>
8 </TABLE>
9 <BR><A HREF="#index">Index</A>
10 <HR>
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 <A NAME="lbAB">&nbsp;</A>
31 <H3>NAME</H3>
32
33 bash - GNU Bourne-Again SHell
34 <A NAME="lbAC">&nbsp;</A>
35 <H3>SYNOPSIS</H3>
36
37 <B>bash</B>
38
39 [options]
40 [file]
41 <A NAME="lbAD">&nbsp;</A>
42 <H3>COPYRIGHT</H3>
43
44
45 Bash is Copyright &#169; 1989-2010 by the Free Software Foundation, Inc.
46 <A NAME="lbAE">&nbsp;</A>
47 <H3>DESCRIPTION</H3>
48
49 <B>Bash</B>
50
51 is an <B>sh</B>-compatible command language interpreter that
52 executes commands read from the standard input or from a file.
53 <B>Bash</B>
54
55 also incorporates useful features from the <I>Korn</I> and <I>C</I>
56 shells (<B>ksh</B> and <B>csh</B>).
57 <P>
58
59 <B>Bash</B>
60
61 is intended to be a conformant implementation of the
62 Shell and Utilities portion of the IEEE POSIX specification
63 (IEEE Standard 1003.1).
64 <B>Bash</B>
65
66 can be configured to be POSIX-conformant by default.
67 <A NAME="lbAF">&nbsp;</A>
68 <H3>OPTIONS</H3>
69
70 All of the single-character shell options documented in the
71 description of the <B>set</B> builtin command can be used as options
72 when the shell is invoked.
73 In addition, <B>bash</B>
74 interprets the following options when it is invoked:
75 <P>
76
77
78 <DL COMPACT>
79 <DT><B>-c</B><I> string</I>
80
81 <DD>
82 If the
83 <B>-c</B>
84
85 option is present, then commands are read from
86 <I>string</I>.
87
88 If there are arguments after the
89 <I>string</I>,
90
91 they are assigned to the positional parameters, starting with
92 <B>$0</B>.
93
94 <DT><B>-i</B>
95
96 <DD>
97 If the
98 <B>-i</B>
99
100 option is present, the shell is
101 <I>interactive</I>.
102
103 <DT><B>-l</B>
104
105 <DD>
106 Make
107 <B>bash</B>
108
109 act as if it had been invoked as a login shell (see
110 <FONT SIZE=-1><B>INVOCATION</B>
111
112 </FONT>
113 below).
114 <DT><B>-r</B>
115
116 <DD>
117 If the
118 <B>-r</B>
119
120 option is present, the shell becomes
121 <I>restricted</I>
122
123 (see
124 <FONT SIZE=-1><B>RESTRICTED SHELL</B>
125
126 </FONT>
127 below).
128 <DT><B>-s</B>
129
130 <DD>
131 If the
132 <B>-s</B>
133
134 option is present, or if no arguments remain after option
135 processing, then commands are read from the standard input.
136 This option allows the positional parameters to be set
137 when invoking an interactive shell.
138 <DT><B>-D</B>
139
140 <DD>
141 A list of all double-quoted strings preceded by <B>$</B>
142 is printed on the standard output.
143 These are the strings that
144 are subject to language translation when the current locale
145 is not <B>C</B> or <B>POSIX</B>.
146 This 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>
155 below).
156 If <I>shopt_option</I> is present, <B>-O</B> sets the value of that option;
157 <B>+O</B> unsets it.
158 If <I>shopt_option</I> is not supplied, the names and values of the shell
159 options accepted by <B>shopt</B> are printed on the standard output.
160 If the invocation option is <B>+O</B>, the output is displayed in a format
161 that may be reused as input.
162 <DT><B>--</B>
163
164 <DD>
165 A
166 <B>--</B>
167
168 signals the end of options and disables further option processing.
169 Any arguments after the
170 <B>--</B>
171
172 are treated as filenames and arguments. An argument of
173 <B>-</B>
174
175 is equivalent to <B>--</B>.
176
177 </DL>
178 <P>
179
180 <B>Bash</B>
181
182 also interprets a number of multi-character options.
183 These options must appear on the command line before the
184 single-character options to be recognized.
185 <P>
186
187
188 <DL COMPACT>
189 <DT><B>--debugger</B>
190
191 <DD>
192 Arrange for the debugger profile to be executed before the shell
193 starts.
194 Turns on extended debugging mode (see the description of the
195 <B>extdebug</B>
196
197 option to the
198 <B>shopt</B>
199
200 builtin below).
201 <DT><B>--dump-po-strings</B>
202
203 <DD>
204 Equivalent 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>
209 Equivalent to <B>-D</B>.
210 <DT><B>--help</B>
211
212 <DD>
213 Display 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
218 Execute commands from
219 <I>file</I>
220
221 instead of the standard personal initialization file
222 <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
223
224 if the shell is interactive (see
225 <FONT SIZE=-1><B>INVOCATION</B>
226
227 </FONT>
228 below).
229 <DT><B>--login</B>
230
231 <DD>
232 Equivalent to <B>-l</B>.
233 <DT><B>--noediting</B>
234
235 <DD>
236 Do not use the GNU
237 <B>readline</B>
238
239 library to read command lines when the shell is interactive.
240 <DT><B>--noprofile</B>
241
242 <DD>
243 Do not read either the system-wide startup file
244
245 <A HREF="file:/etc/profile"><I>/etc/profile</I></A>
246
247 or 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
252 or
253 <A HREF="file:~/.profile"><I>~/.profile</I></A>.
254
255 By default,
256 <B>bash</B>
257
258 reads these files when it is invoked as a login shell (see
259 <FONT SIZE=-1><B>INVOCATION</B>
260
261 </FONT>
262 below).
263 <DT><B>--norc</B>
264
265 <DD>
266 Do not read and execute the personal initialization file
267 <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
268
269 if the shell is interactive.
270 This option is on by default if the shell is invoked as
271 <B>sh</B>.
272
273 <DT><B>--posix</B>
274
275 <DD>
276 Change the behavior of <B>bash</B> where the default operation differs
277 from the POSIX standard to match the standard (<I>posix mode</I>).
278 <DT><B>--restricted</B>
279
280 <DD>
281 The shell becomes restricted (see
282 <FONT SIZE=-1><B>RESTRICTED SHELL</B>
283
284 </FONT>
285 below).
286 <DT><B>--verbose</B>
287
288 <DD>
289 Equivalent to <B>-v</B>.
290 <DT><B>--version</B>
291
292 <DD>
293 Show version information for this instance of
294 <B>bash</B>
295
296 on the standard output and exit successfully.
297
298 </DL>
299 <A NAME="lbAG">&nbsp;</A>
300 <H3>ARGUMENTS</H3>
301
302 If arguments remain after option processing, and neither the
303 <B>-c</B>
304
305 nor the
306 <B>-s</B>
307
308 option has been supplied, the first argument is assumed to
309 be the name of a file containing shell commands.
310 If
311 <B>bash</B>
312
313 is invoked in this fashion,
314 <B>$0</B>
315
316 is set to the name of the file, and the positional parameters
317 are set to the remaining arguments.
318 <B>Bash</B>
319
320 reads and executes commands from this file, then exits.
321 <B>Bash</B>'s exit status is the exit status of the last command
322 executed in the script.
323 If no commands are executed, the exit status is 0.
324 An attempt is first made to open the file in the current directory, and,
325 if no file is found, then the shell searches the directories in
326 <FONT SIZE=-1><B>PATH</B>
327
328 </FONT>
329 for the script.
330 <A NAME="lbAH">&nbsp;</A>
331 <H3>INVOCATION</H3>
332
333 A <I>login shell</I> is one whose first character of argument zero is a
334 <B>-</B>,
335
336 or one started with the
337 <B>--login</B>
338
339 option.
340 <P>
341
342 An <I>interactive</I> shell is one started without non-option arguments
343 and without the
344 <B>-c</B>
345
346 option
347 whose standard input and error are
348 both connected to terminals (as determined by
349 <I>isatty</I>(3)),
350
351 or one started with the
352 <B>-i</B>
353
354 option.
355 <FONT SIZE=-1><B>PS1</B>
356
357 </FONT>
358 is set and
359 <B>$-</B>
360
361 includes
362 <B>i</B>
363
364 if
365 <B>bash</B>
366
367 is interactive,
368 allowing a shell script or a startup file to test this state.
369 <P>
370
371 The following paragraphs describe how
372 <B>bash</B>
373
374 executes its startup files.
375 If any of the files exist but cannot be read,
376 <B>bash</B>
377
378 reports an error.
379 Tildes are expanded in file names as described below under
380 <B>Tilde Expansion</B>
381
382 in the
383 <FONT SIZE=-1><B>EXPANSION</B>
384
385 </FONT>
386 section.
387 <P>
388
389 When
390 <B>bash</B>
391
392 is invoked as an interactive login shell, or as a non-interactive shell
393 with the <B>--login</B> option, it first reads and
394 executes commands from the file <A HREF="file:/etc/profile"><I>/etc/profile</I></A>, if that
395 file exists.
396 After reading that file, it looks for <A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>,
397 <A HREF="file:~/.bash_login"><I>~/.bash_login</I></A>, and <A HREF="file:~/.profile"><I>~/.profile</I></A>, in that order, and reads
398 and executes commands from the first one that exists and is readable.
399 The
400 <B>--noprofile</B>
401
402 option may be used when the shell is started to inhibit this behavior.
403 <P>
404
405 When a login shell exits,
406 <B>bash</B>
407
408 reads and executes commands from the file <A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A>, if it
409 exists.
410 <P>
411
412 When an interactive shell that is not a login shell is started,
413 <B>bash</B>
414
415 reads and executes commands from <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>, if that file exists.
416 This may be inhibited by using the
417 <B>--norc</B>
418
419 option.
420 The <B>--rcfile</B> <I>file</I> option will force
421 <B>bash</B>
422
423 to read and execute commands from <I>file</I> instead of <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>.
424 <P>
425
426 When
427 <B>bash</B>
428
429 is started non-interactively, to run a shell script, for example, it
430 looks for the variable
431 <FONT SIZE=-1><B>BASH_ENV</B>
432
433 </FONT>
434 in the environment, expands its value if it appears there, and uses the
435 expanded value as the name of a file to read and execute.
436 <B>Bash</B>
437
438 behaves as if the following command were executed:
439 <P>
440 <DL COMPACT><DT><DD>
441 <TT>if [ -n &quot;$BASH_ENV&quot; ]; then . &quot;$BASH_ENV&quot;; fi</TT>
442
443 </DL>
444
445 <P>
446 but the value of the
447 <FONT SIZE=-1><B>PATH</B>
448
449 </FONT>
450 variable is not used to search for the file name.
451 <P>
452
453 If
454 <B>bash</B>
455
456 is invoked with the name
457 <B>sh</B>,
458
459 it tries to mimic the startup behavior of historical versions of
460 <B>sh</B>
461
462 as closely as possible,
463 while conforming to the POSIX standard as well.
464 When invoked as an interactive login shell, or a non-interactive
465 shell with the <B>--login</B> option, it first attempts to
466 read and execute commands from
467 <A HREF="file:/etc/profile"><I>/etc/profile</I></A>
468
469 and
470 <A HREF="file:~/.profile"><I>~/.profile</I></A>,
471
472 in that order.
473 The
474 <B>--noprofile</B>
475
476 option may be used to inhibit this behavior.
477 When invoked as an interactive shell with the name
478 <B>sh</B>,
479
480 <B>bash</B>
481
482 looks for the variable
483 <FONT SIZE=-1><B>ENV</B>,
484
485 </FONT>
486 expands its value if it is defined, and uses the
487 expanded value as the name of a file to read and execute.
488 Since a shell invoked as
489 <B>sh</B>
490
491 does not attempt to read and execute commands from any other startup
492 files, the
493 <B>--rcfile</B>
494
495 option has no effect.
496 A non-interactive shell invoked with the name
497 <B>sh</B>
498
499 does not attempt to read any other startup files.
500 When invoked as
501 <B>sh</B>,
502
503 <B>bash</B>
504
505 enters
506 <I>posix</I>
507
508 mode after the startup files are read.
509 <P>
510
511 When
512 <B>bash</B>
513
514 is started in
515 <I>posix</I>
516
517 mode, as with the
518 <B>--posix</B>
519
520 command line option, it follows the POSIX standard for startup files.
521 In this mode, interactive shells expand the
522 <FONT SIZE=-1><B>ENV</B>
523
524 </FONT>
525 variable and commands are read and executed from the file
526 whose name is the expanded value.
527 No other startup files are read.
528 <P>
529
530 <B>Bash</B>
531
532 attempts to determine when it is being run with its standard input
533 connected to a network connection, as when executed by the remote shell
534 daemon, usually <I>rshd</I>, or the secure shell daemon <I>sshd</I>.
535 If
536 <B>bash</B>
537
538 determines it is being run in this fashion, it reads and executes
539 commands from <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>, if that file exists and is readable.
540 It will not do this if invoked as <B>sh</B>.
541 The
542 <B>--norc</B>
543
544 option may be used to inhibit this behavior, and the
545 <B>--rcfile</B>
546
547 option may be used to force another file to be read, but
548 <I>rshd</I> does not generally invoke the shell with those options
549 or allow them to be specified.
550 <P>
551
552 If the shell is started with the effective user (group) id not equal to the
553 real user (group) id, and the <B>-p</B> option is not supplied, no startup
554 files are read, shell functions are not inherited from the environment, the
555 <FONT SIZE=-1><B>SHELLOPTS</B>,
556
557 </FONT>
558 <FONT SIZE=-1><B>BASHOPTS</B>,
559
560 </FONT>
561 <FONT SIZE=-1><B>CDPATH</B>,
562
563 </FONT>
564 and
565 <FONT SIZE=-1><B>GLOBIGNORE</B>
566
567 </FONT>
568 variables, if they appear in the environment, are ignored,
569 and the effective user id is set to the real user id.
570 If the <B>-p</B> option is supplied at invocation, the startup behavior is
571 the same, but the effective user id is not reset.
572 <A NAME="lbAI">&nbsp;</A>
573 <H3>DEFINITIONS</H3>
574
575 <P>
576
577 The following definitions are used throughout the rest of this
578 document.
579
580 <DL COMPACT>
581 <DT><B>blank </B>
582
583 <DD>
584 A space or tab.
585 <DT><B>word</B>
586
587 <DD>
588 A sequence of characters considered as a single unit by the shell.
589 Also known as a
590 <B>token</B>.
591
592 <DT><B>name</B>
593
594 <DD>
595 A
596 <I>word</I>
597
598 consisting only of alphanumeric characters and underscores, and
599 beginning with an alphabetic character or an underscore. Also
600 referred to as an
601 <B>identifier</B>.
602
603 <DT><B>metacharacter</B>
604
605 <DD>
606 A character that, when unquoted, separates words. One of the following:
607 <BR>
608
609 <DL COMPACT><DT><DD>
610 <P>
611
612 <B>| &amp; ; ( ) &lt; &gt; space tab</B>
613
614 </DL>
615
616 </DL>
617 <P>
618
619 <DL COMPACT>
620 <DT><B>control operator</B>
621
622 <DD>
623 A <I>token</I> that performs a control function. It is one of the following
624 symbols:
625 <DL COMPACT><DT><DD>
626 <P>
627
628 <B>|| &amp; &amp;&amp; ; ;; ( ) | |&amp; &lt;newline&gt;</B>
629
630 </DL>
631
632
633 </DL>
634 <A NAME="lbAJ">&nbsp;</A>
635 <H3>RESERVED WORDS</H3>
636
637 <I>Reserved words</I> are words that have a special meaning to the shell.
638 The following words are recognized as reserved when unquoted and either
639 the first word of a simple command (see
640 <FONT SIZE=-1><B>SHELL GRAMMAR</B>
641
642 </FONT>
643 below) or the third word of a
644 <B>case </B>
645
646 or
647 <B>for</B>
648
649 command:
650 <DL COMPACT><DT><DD>
651
652 <P>
653
654 <B>
655 </B>
656
657 ! case do done elif else esac fi for function if in select then until while { } time [[ ]]
658 </DL>
659
660
661 <A NAME="lbAK">&nbsp;</A>
662 <H3>SHELL GRAMMAR</H3>
663
664 <A NAME="lbAL">&nbsp;</A>
665 <H4>Simple Commands</H4>
666
667 <P>
668
669 A <I>simple command</I> is a sequence of optional variable assignments
670 followed by <B>blank</B>-separated words and redirections, and
671 terminated by a <I>control operator</I>. The first word
672 specifies the command to be executed, and is passed as argument zero.
673 The remaining words are passed as arguments to the invoked command.
674 <P>
675
676 The return value of a <I>simple command</I> is its exit status, or
677 128+<I>n</I> if the command is terminated by signal
678 <I>n</I>.
679
680 <A NAME="lbAM">&nbsp;</A>
681 <H4>Pipelines</H4>
682
683 <P>
684
685 A <I>pipeline</I> is a sequence of one or more commands separated by
686 one of the control operators
687 <B>|</B>
688
689 or <B>|&amp;</B>.
690 The format for a pipeline is:
691 <DL COMPACT><DT><DD>
692 <P>
693
694 [<B>time</B> [<B>-p</B>]] [ ! ] <I>command</I> [ [<B>|</B>|<B>|&amp;</B>] <I>command2</I> ... ]
695 </DL>
696
697 <P>
698
699 The standard output of
700 <I>command</I>
701
702 is connected via a pipe to the standard input of
703 <I>command2</I>.
704
705 This connection is performed before any redirections specified by the
706 command (see
707 <FONT SIZE=-1><B>REDIRECTION</B>
708
709 </FONT>
710 below).
711 If <B>|&amp;</B> is used, the standard error of <I>command</I> is connected to
712 <I>command2</I>'s standard input through the pipe; it is shorthand for
713 <B>2&gt;&amp;1 |</B>.
714 This implicit redirection of the standard error is performed after any
715 redirections specified by the command.
716 <P>
717
718 The return status of a pipeline is the exit status of the last
719 command, unless the <B>pipefail</B> option is enabled.
720 If <B>pipefail</B> is enabled, the pipeline's return status is the
721 value of the last (rightmost) command to exit with a non-zero status,
722 or zero if all commands exit successfully.
723 If the reserved word
724 <B>!</B>
725
726 precedes a pipeline, the exit status of that pipeline is the logical
727 negation of the exit status as described above.
728 The shell waits for all commands in the pipeline to
729 terminate before returning a value.
730 <P>
731
732 If the
733 <B>time</B>
734
735 reserved word precedes a pipeline, the elapsed as well as user and
736 system time consumed by its execution are reported when the pipeline
737 terminates.
738 The <B>-p</B> option changes the output format to that specified by POSIX.
739 When the shell is in <I>posix mode</I>, it does not recognize
740 <B>time</B> as a reserved word if the next token begins with a `-'.
741 The
742 <FONT SIZE=-1><B>TIMEFORMAT</B>
743
744 </FONT>
745 variable may be set to a format string that specifies how the timing
746 information should be displayed; see the description of
747 <FONT SIZE=-1><B>TIMEFORMAT</B>
748
749 </FONT>
750 under
751 <B>Shell Variables</B>
752
753 below.
754 <P>
755
756 When the shell is in <I>posix mode</I>, <B>time</B>
757 may be followed by a newline. In this case, the shell displays the
758 total user and system time consumed by the shell and its children.
759 The
760 <FONT SIZE=-1><B>TIMEFORMAT</B>
761
762 </FONT>
763 variable may be used to specify the format of
764 the time information.
765 <P>
766
767 Each command in a pipeline is executed as a separate process (i.e., in a
768 subshell).
769 <A NAME="lbAN">&nbsp;</A>
770 <H4>Lists</H4>
771
772 <P>
773
774 A <I>list</I> is a sequence of one or more pipelines separated by one
775 of the operators
776 <B>;</B>,
777
778 <B>&amp;</B>,
779
780 <B>&amp;&amp;</B>,
781
782 or
783 <B>||</B>,
784
785 and optionally terminated by one of
786 <B>;</B>,
787
788 <B>&amp;</B>,
789
790 or
791 <B>&lt;newline&gt;</B>.
792
793 <P>
794
795 Of these list operators,
796 <B>&amp;&amp;</B>
797
798 and
799 <B>||</B>
800
801 have equal precedence, followed by
802 <B>;</B>
803
804 and
805 <B>&amp;</B>,
806
807 which have equal precedence.
808 <P>
809
810 A sequence of one or more newlines may appear in a <I>list</I> instead
811 of a semicolon to delimit commands.
812 <P>
813
814 If a command is terminated by the control operator
815 <B>&amp;</B>,
816
817 the shell executes the command in the <I>background</I>
818 in a subshell. The shell does not wait for the command to
819 finish, and the return status is 0. Commands separated by a
820 <B>;</B>
821
822 are executed sequentially; the shell waits for each
823 command to terminate in turn. The return status is the
824 exit status of the last command executed.
825 <P>
826
827 AND and OR lists are sequences of one of more pipelines separated by the
828 <B>&amp;&amp;</B> and <B>||</B> control operators, respectively.
829 AND and OR lists are executed with left associativity.
830 An AND list has the form
831 <DL COMPACT><DT><DD>
832 <P>
833
834 <I>command1</I> <B>&amp;&amp;</B> <I>command2</I>
835 </DL>
836
837 <P>
838
839 <I>command2</I>
840
841 is executed if, and only if,
842 <I>command1</I>
843
844 returns an exit status of zero.
845 <P>
846
847 An OR list has the form
848 <DL COMPACT><DT><DD>
849 <P>
850
851 <I>command1</I> <B>||</B> <I>command2</I>
852 <P>
853
854 </DL>
855
856 <P>
857
858 <I>command2</I>
859
860 is executed if and only if
861 <I>command1</I>
862
863 returns a non-zero exit status.
864 The return status of
865 AND and OR lists is the exit status of the last command
866 executed in the list.
867 <A NAME="lbAO">&nbsp;</A>
868 <H4>Compound Commands</H4>
869
870 <P>
871
872 A <I>compound command</I> is one of the following:
873 <DL COMPACT>
874 <DT>(<I>list</I>)<DD>
875 <I>list</I> is executed in a subshell environment (see
876 <FONT SIZE=-1><B>COMMAND EXECUTION ENVIRONMENT</B></FONT>
877 below).
878 Variable assignments and builtin
879 commands that affect the shell's environment do not remain in effect
880 after the command completes. The return status is the exit status of
881 <I>list</I>.
882 <DT>{ <I>list</I>; }<DD>
883 <I>list</I> is simply executed in the current shell environment.
884 <I>list</I> must be terminated with a newline or semicolon.
885 This is known as a <I>group command</I>.
886 The return status is the exit status of
887 <I>list</I>.
888 Note that unlike the metacharacters <B>(</B> and <B>)</B>, <B>{</B> and
889 <B>}</B> are <I>reserved words</I> and must occur where a reserved
890 word is permitted to be recognized. Since they do not cause a word
891 break, they must be separated from <I>list</I> by whitespace or another
892 shell metacharacter.
893 <DT>((<I>expression</I>))<DD>
894 The <I>expression</I> is evaluated according to the rules described
895 below under
896 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
897
898 </FONT>
899 If the value of the expression is non-zero, the return status is 0;
900 otherwise the return status is 1. This is exactly equivalent to
901 <B>let &quot;</B><I>expression</I>&quot;.
902 <DT><B>[[</B> <I>expression</I> <B>]]</B><DD>
903 Return a status of 0 or 1 depending on the evaluation of
904 the conditional expression <I>expression</I>.
905 Expressions are composed of the primaries described below under
906 <FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>.
907
908 </FONT>
909 Word splitting and pathname expansion are not performed on the words
910 between the <B>[[</B> and <B>]]</B>; tilde expansion, parameter and
911 variable expansion, arithmetic expansion, command substitution, process
912 substitution, and quote removal are performed.
913 Conditional operators such as <B>-f</B> must be unquoted to be recognized
914 as primaries.
915 <P>
916
917
918 When used with <B>[[</B>, The <B>&lt;</B> and <B>&gt;</B> operators sort
919 lexicographically using the current locale.
920 <P>
921
922
923 When the <B>==</B> and <B>!=</B> operators are used, the string to the
924 right of the operator is considered a pattern and matched according
925 to the rules described below under <B>Pattern Matching</B>.
926 If the shell option
927 <B>nocasematch</B>
928
929 is enabled, the match is performed without regard to the case
930 of alphabetic characters.
931 The return value is 0 if the string matches (<B>==</B>) or does not match
932 (<B>!=</B>) the pattern, and 1 otherwise.
933 Any part of the pattern may be quoted to force it to be matched as a
934 string.
935 <P>
936
937
938 An additional binary operator, <B>=~</B>, is available, with the same
939 precedence as <B>==</B> and <B>!=</B>.
940 When it is used, the string to the right of the operator is considered
941 an extended regular expression and matched accordingly (as in <I>regex</I>(3)).
942 The return value is 0 if the string matches
943 the pattern, and 1 otherwise.
944 If the regular expression is syntactically incorrect, the conditional
945 expression's return value is 2.
946 If the shell option
947 <B>nocasematch</B>
948
949 is enabled, the match is performed without regard to the case
950 of alphabetic characters.
951 Any part of the pattern may be quoted to force it to be matched as a
952 string.
953 Substrings matched by parenthesized subexpressions within the regular
954 expression are saved in the array variable
955 <FONT SIZE=-1><B>BASH_REMATCH</B>.
956
957 </FONT>
958 The element of
959 <FONT SIZE=-1><B>BASH_REMATCH</B>
960
961 </FONT>
962 with index 0 is the portion of the string
963 matching the entire regular expression.
964 The element of
965 <FONT SIZE=-1><B>BASH_REMATCH</B>
966
967 </FONT>
968 with index <I>n</I> is the portion of the
969 string matching the <I>n</I>th parenthesized subexpression.
970 <P>
971
972
973 Expressions may be combined using the following operators, listed
974 in decreasing order of precedence:
975 <P>
976
977
978 <DL COMPACT><DT><DD>
979
980 <DL COMPACT>
981 <DT><B>( </B><I>expression</I> )
982
983 <DD>
984 Returns the value of <I>expression</I>.
985 This may be used to override the normal precedence of operators.
986 <DT><B>! </B><I>expression</I>
987
988 <DD>
989 True if
990 <I>expression</I>
991
992 is false.
993 <DT><I>expression1</I> <B>&amp;&amp;</B> <I>expression2</I><DD>
994 True if both
995 <I>expression1</I>
996
997 and
998 <I>expression2</I>
999
1000 are true.
1001 <DT><I>expression1</I> <B>||</B> <I>expression2</I>
1002 <DD>
1003
1004 True if either
1005 <I>expression1</I>
1006
1007 or
1008 <I>expression2</I>
1009
1010 is true.
1011
1012 </DL>
1013 <P>
1014
1015 The <B>&amp;&amp;</B> and
1016 <B>||</B>
1017
1018 operators do not evaluate <I>expression2</I> if the value of
1019 <I>expression1</I> is sufficient to determine the return value of
1020 the entire conditional expression.
1021 </DL>
1022
1023 <DT><B>for</B> <I>name</I> [ [ <B>in</B> [ <I>word ...</I> ] ] ; ] <B>do</B> <I>list</I> ; <B>done</B><DD>
1024 The list of words following <B>in</B> is expanded, generating a list
1025 of items.
1026 The variable <I>name</I> is set to each element of this list
1027 in turn, and <I>list</I> is executed each time.
1028 If the <B>in</B> <I>word</I> is omitted, the <B>for</B> command executes
1029 <I>list</I> once for each positional parameter that is set (see
1030 <FONT SIZE=-1><B>PARAMETERS</B>
1031
1032 </FONT>
1033 below).
1034 The return status is the exit status of the last command that executes.
1035 If the expansion of the items following <B>in</B> results in an empty
1036 list, no commands are executed, and the return status is 0.
1037 <DT><B>for</B> (( <I>expr1</I> ; <I>expr2</I> ; <I>expr3</I> )) ; <B>do</B> <I>list</I> ; <B>done</B><DD>
1038 First, the arithmetic expression <I>expr1</I> is evaluated according
1039 to the rules described below under
1040 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
1041
1042 </FONT>
1043 The arithmetic expression <I>expr2</I> is then evaluated repeatedly
1044 until it evaluates to zero.
1045 Each time <I>expr2</I> evaluates to a non-zero value, <I>list</I> is
1046 executed and the arithmetic expression <I>expr3</I> is evaluated.
1047 If any expression is omitted, it behaves as if it evaluates to 1.
1048 The return value is the exit status of the last command in <I>list</I>
1049 that is executed, or false if any of the expressions is invalid.
1050 <DT><B>select</B> <I>name</I> [ <B>in</B> <I>word</I> ] ; <B>do</B> <I>list</I> ; <B>done</B><DD>
1051 The list of words following <B>in</B> is expanded, generating a list
1052 of items. The set of expanded words is printed on the standard
1053 error, each preceded by a number. If the <B>in</B>
1054 <I>word</I> is omitted, the positional parameters are printed (see
1055 <FONT SIZE=-1><B>PARAMETERS</B>
1056
1057 </FONT>
1058 below). The
1059 <FONT SIZE=-1><B>PS3</B>
1060
1061 </FONT>
1062 prompt is then displayed and a line read from the standard input.
1063 If the line consists of a number corresponding to one of
1064 the displayed words, then the value of
1065 <I>name</I>
1066
1067 is set to that word. If the line is empty, the words and prompt
1068 are displayed again. If EOF is read, the command completes. Any
1069 other value read causes
1070 <I>name</I>
1071
1072 to be set to null. The line read is saved in the variable
1073 <FONT SIZE=-1><B>REPLY</B>.
1074
1075 </FONT>
1076 The
1077 <I>list</I>
1078
1079 is executed after each selection until a
1080 <B>break</B>
1081
1082 command is executed.
1083 The exit status of
1084 <B>select</B>
1085
1086 is the exit status of the last command executed in
1087 <I>list</I>,
1088
1089 or zero if no commands were executed.
1090 <DT><B>case</B> <I>word</I> <B>in</B> [ [(] <I>pattern</I> [ <B>|</B> <I>pattern</I> ]
1091 <DD>
1092 A <B>case</B> command first expands <I>word</I>, and tries to match
1093 it against each <I>pattern</I> in turn, using the same matching rules
1094 as for pathname expansion (see
1095 <B>Pathname Expansion</B>
1096
1097 below).
1098 The <I>word</I> is expanded using tilde
1099 expansion, parameter and variable expansion, arithmetic substitution,
1100 command substitution, process substitution and quote removal.
1101 Each <I>pattern</I> examined is expanded using tilde
1102 expansion, parameter and variable expansion, arithmetic substitution,
1103 command substitution, and process substitution.
1104 If the shell option
1105 <B>nocasematch</B>
1106
1107 is enabled, the match is performed without regard to the case
1108 of alphabetic characters.
1109 When a match is found, the corresponding <I>list</I> is executed.
1110 If the <B>;;</B> operator is used, no subsequent matches are attempted after
1111 the first pattern match.
1112 Using <B>;&amp;</B> in place of <B>;;</B> causes execution to continue with
1113 the <I>list</I> associated with the next set of patterns.
1114 Using <B>;;&amp;</B> in place of <B>;;</B> causes the shell to test the next
1115 pattern list in the statement, if any, and execute any associated <I>list</I>
1116 on a successful match.
1117 The exit status is zero if no
1118 pattern matches. Otherwise, it is the exit status of the
1119 last command executed in <I>list</I>.
1120 <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>
1121 The
1122 <B>if </B>
1123
1124 <I>list</I>
1125
1126 is executed. If its exit status is zero, the
1127 <B>then</B> <I>list</I> is executed. Otherwise, each <B>elif</B>
1128 <I>list</I> is executed in turn, and if its exit status is zero,
1129 the corresponding <B>then</B> <I>list</I> is executed and the
1130 command completes. Otherwise, the <B>else</B> <I>list</I> is
1131 executed, if present. The exit status is the exit status of the
1132 last command executed, or zero if no condition tested true.
1133 <DT><B>while</B> <I>list</I>; <B>do</B> <I>list</I>; <B>done</B><DD>
1134
1135 <DT><B>until</B> <I>list</I>; <B>do</B> <I>list</I>; <B>done</B><DD>
1136
1137 The <B>while</B> command continuously executes the <B>do</B>
1138 <I>list</I> as long as the last command in <I>list</I> returns
1139 an exit status of zero. The <B>until</B> command is identical
1140 to the <B>while</B> command, except that the test is negated;
1141 the
1142 <B>do</B>
1143
1144 <I>list</I>
1145
1146 is executed as long as the last command in
1147 <I>list</I>
1148
1149 returns a non-zero exit status.
1150 The exit status of the <B>while</B> and <B>until</B> commands
1151 is the exit status
1152 of the last <B>do</B> <I>list</I> command executed, or zero if
1153 none was executed.
1154 </DL>
1155 <A NAME="lbAP">&nbsp;</A>
1156 <H4>Coprocesses</H4>
1157
1158 <P>
1159
1160 A <I>coprocess</I> is a shell command preceded by the <B>coproc</B> reserved
1161 word.
1162 A coprocess is executed asynchronously in a subshell, as if the command
1163 had been terminated with the <B>&amp;</B> control operator, with a two-way pipe
1164 established between the executing shell and the coprocess.
1165 <P>
1166
1167 The format for a coprocess is:
1168 <DL COMPACT><DT><DD>
1169 <P>
1170
1171 <B>coproc</B> [<I>NAME</I>] <I>command</I> [<I>redirections</I>]
1172 </DL>
1173
1174 <P>
1175
1176 This creates a coprocess named <I>NAME</I>.
1177 If <I>NAME</I> is not supplied, the default name is <I>COPROC</I>.
1178 <I>NAME</I> must not be supplied if <I>command</I> is a <I>simple
1179 command</I> (see above); otherwise, it is interpreted as the first word
1180 of the simple command.
1181 When the coproc is executed, the shell creates an array variable (see
1182 <B>Arrays</B>
1183
1184 below) named <I>NAME</I> in the context of the executing shell.
1185 The standard output of
1186 <I>command</I>
1187
1188 is connected via a pipe to a file descriptor in the executing shell,
1189 and that file descriptor is assigned to <I>NAME</I>[0].
1190 The standard input of
1191 <I>command</I>
1192
1193 is connected via a pipe to a file descriptor in the executing shell,
1194 and that file descriptor is assigned to <I>NAME</I>[1].
1195 This pipe is established before any redirections specified by the
1196 command (see
1197 <FONT SIZE=-1><B>REDIRECTION</B>
1198
1199 </FONT>
1200 below).
1201 The file descriptors can be utilized as arguments to shell commands
1202 and redirections using standard word expansions.
1203 The process ID of the shell spawned to execute the coprocess is
1204 available as the value of the variable <I>NAME</I>_PID.
1205 The <B>wait</B>
1206 builtin command may be used to wait for the coprocess to terminate.
1207 <P>
1208
1209 The return status of a coprocess is the exit status of <I>command</I>.
1210 <A NAME="lbAQ">&nbsp;</A>
1211 <H4>Shell Function Definitions</H4>
1212
1213 <P>
1214
1215 A shell function is an object that is called like a simple command and
1216 executes a compound command with a new set of positional parameters.
1217 Shell functions are declared as follows:
1218 <DL COMPACT>
1219 <DT><I>name</I> () <I>compound-command</I> [<I>redirection</I>]<DD>
1220
1221 <DT><B>function</B> <I>name</I> [()] <I>compound-command</I> [<I>redirection</I>]<DD>
1222
1223 This defines a function named <I>name</I>.
1224 The reserved word <B>function</B> is optional.
1225 If the <B>function</B> reserved word is supplied, the parentheses are optional.
1226 The <I>body</I> of the function is the compound command
1227 <I>compound-command </I>
1228
1229 (see <B>Compound Commands</B> above).
1230 That command is usually a <I>list</I> of commands between { and }, but
1231 may be any command listed under <B>Compound Commands</B> above.
1232 <I>compound-command</I> is executed whenever <I>name</I> is specified as the
1233 name of a simple command.
1234 Any redirections (see
1235 <FONT SIZE=-1><B>REDIRECTION</B>
1236
1237 </FONT>
1238 below) specified when a function is defined are performed
1239 when the function is executed.
1240 The exit status of a function definition is zero unless a syntax error
1241 occurs or a readonly function with the same name already exists.
1242 When executed, the exit status of a function is the exit status of the
1243 last command executed in the body. (See
1244 <FONT SIZE=-1><B>FUNCTIONS</B>
1245
1246 </FONT>
1247 below.)
1248 </DL>
1249 <A NAME="lbAR">&nbsp;</A>
1250 <H3>COMMENTS</H3>
1251
1252 In a non-interactive shell, or an interactive shell in which the
1253 <B>interactive_comments</B>
1254
1255 option to the
1256 <B>shopt</B>
1257
1258 builtin is enabled (see
1259 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
1260
1261 </FONT>
1262 below), a word beginning with
1263 <B>#</B>
1264
1265 causes that word and all remaining characters on that line to
1266 be ignored. An interactive shell without the
1267 <B>interactive_comments</B>
1268
1269 option enabled does not allow comments. The
1270 <B>interactive_comments</B>
1271
1272 option is on by default in interactive shells.
1273 <A NAME="lbAS">&nbsp;</A>
1274 <H3>QUOTING</H3>
1275
1276 <I>Quoting</I> is used to remove the special meaning of certain
1277 characters or words to the shell. Quoting can be used to
1278 disable special treatment for special characters, to prevent
1279 reserved words from being recognized as such, and to prevent
1280 parameter expansion.
1281 <P>
1282
1283 Each of the <I>metacharacters</I> listed above under
1284 <FONT SIZE=-1><B>DEFINITIONS</B>
1285
1286 </FONT>
1287 has special meaning to the shell and must be quoted if it is to
1288 represent itself.
1289 <P>
1290
1291 When the command history expansion facilities are being used
1292 (see
1293 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
1294
1295 </FONT>
1296 below), the
1297 <I>history expansion</I> character, usually <B>!</B>, must be quoted
1298 to prevent history expansion.
1299 <P>
1300
1301 There are three quoting mechanisms: the
1302 <I>escape character</I>,
1303
1304 single quotes, and double quotes.
1305 <P>
1306
1307 A non-quoted backslash (<B>\</B>) is the
1308 <I>escape character</I>.
1309
1310 It preserves the literal value of the next character that follows,
1311 with the exception of &lt;newline&gt;. If a <B>\</B>&lt;newline&gt; pair
1312 appears, and the backslash is not itself quoted, the <B>\</B>&lt;newline&gt;
1313 is treated as a line continuation (that is, it is removed from the
1314 input stream and effectively ignored).
1315 <P>
1316
1317 Enclosing characters in single quotes preserves the literal value
1318 of each character within the quotes. A single quote may not occur
1319 between single quotes, even when preceded by a backslash.
1320 <P>
1321
1322 Enclosing characters in double quotes preserves the literal value
1323 of all characters within the quotes, with the exception of
1324 <B>$</B>,
1325
1326 <B>`</B>,
1327
1328 <B>\</B>,
1329
1330 and, when history expansion is enabled,
1331 <B>!</B>.
1332
1333 The characters
1334 <B>$</B>
1335
1336 and
1337 <B>`</B>
1338
1339 retain their special meaning within double quotes. The backslash
1340 retains its special meaning only when followed by one of the following
1341 characters:
1342 <B>$</B>,
1343
1344 <B>`</B>,
1345
1346 <B>&quot;</B>,
1347 <B>\</B>,
1348
1349 or
1350 <B>&lt;newline&gt;</B>.
1351
1352 A double quote may be quoted within double quotes by preceding it with
1353 a backslash.
1354 If enabled, history expansion will be performed unless an
1355 <B>!</B>
1356
1357 appearing in double quotes is escaped using a backslash.
1358 The backslash preceding the
1359 <B>!</B>
1360
1361 is not removed.
1362 <P>
1363
1364 The special parameters
1365 <B>*</B>
1366
1367 and
1368 <B>@</B>
1369
1370 have special meaning when in double
1371 quotes (see
1372 <FONT SIZE=-1><B>PARAMETERS</B>
1373
1374 </FONT>
1375 below).
1376 <P>
1377
1378 Words of the form <B>$</B>aq<I>string</I>aq are treated specially. The
1379 word expands to <I>string</I>, with backslash-escaped characters replaced
1380 as specified by the ANSI C standard. Backslash escape sequences, if
1381 present, are decoded as follows:
1382 <DL COMPACT><DT><DD>
1383
1384 <DL COMPACT>
1385 <DT><B>\a</B>
1386
1387 <DD>
1388 alert (bell)
1389 <DT><B>\b</B>
1390
1391 <DD>
1392 backspace
1393 <DT><B>\e</B>
1394
1395 <DD>
1396 <DT><B>\E</B>
1397
1398 <DD>
1399 an escape character
1400 <DT><B>\f</B>
1401
1402 <DD>
1403 form feed
1404 <DT><B>\n</B>
1405
1406 <DD>
1407 new line
1408 <DT><B>\r</B>
1409
1410 <DD>
1411 carriage return
1412 <DT><B>\t</B>
1413
1414 <DD>
1415 horizontal tab
1416 <DT><B>\v</B>
1417
1418 <DD>
1419 vertical tab
1420 <DT><B>\\</B>
1421
1422 <DD>
1423 backslash
1424 <DT><B>\aq</B>
1425
1426 <DD>
1427 single quote
1428 <DT><B>\dq</B>
1429
1430 <DD>
1431 double quote
1432 <DT><B>\</B><I>nnn</I>
1433
1434 <DD>
1435 the eight-bit character whose value is the octal value <I>nnn</I>
1436 (one to three digits)
1437 <DT><B>\x</B><I>HH</I>
1438
1439 <DD>
1440 the eight-bit character whose value is the hexadecimal value <I>HH</I>
1441 (one or two hex digits)
1442 <DT><B>\u</B><I>HHHH</I>
1443
1444 <DD>
1445 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
1446 <I>HHHH</I> (one to four hex digits)
1447 <DT><B>\U</B><I>HHHHHHHH</I>
1448
1449 <DD>
1450 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
1451 <I>HHHHHHHH</I> (one to eight hex digits)
1452 <DT><B>\c</B><I>x</I>
1453
1454 <DD>
1455 a control-<I>x</I> character
1456
1457 </DL></DL>
1458
1459 <P>
1460
1461 The expanded result is single-quoted, as if the dollar sign had
1462 not been present.
1463 <P>
1464
1465 A double-quoted string preceded by a dollar sign (<B>$</B>dq<I>string</I>dq)
1466 will cause the string to be translated according to the current locale.
1467 If the current locale is <B>C</B> or <B>POSIX</B>, the dollar sign
1468 is ignored.
1469 If the string is translated and replaced, the replacement is
1470 double-quoted.
1471 <A NAME="lbAT">&nbsp;</A>
1472 <H3>PARAMETERS</H3>
1473
1474 A
1475 <I>parameter</I>
1476
1477 is an entity that stores values.
1478 It can be a
1479 <I>name</I>,
1480
1481 a number, or one of the special characters listed below under
1482 <B>Special Parameters</B>.
1483
1484 A
1485 <I>variable</I>
1486
1487 is a parameter denoted by a
1488 <I>name</I>.
1489
1490 A variable has a <I>value</I> and zero or more <I>attributes</I>.
1491 Attributes are assigned using the
1492 <B>declare</B>
1493
1494 builtin command (see
1495 <B>declare</B>
1496
1497 below in
1498 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>).
1499
1500 </FONT>
1501 <P>
1502
1503 A parameter is set if it has been assigned a value. The null string is
1504 a valid value. Once a variable is set, it may be unset only by using
1505 the
1506 <B>unset</B>
1507
1508 builtin command (see
1509 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
1510
1511 </FONT>
1512 below).
1513 <P>
1514
1515 A
1516 <I>variable</I>
1517
1518 may be assigned to by a statement of the form
1519 <DL COMPACT><DT><DD>
1520 <P>
1521
1522 <I>name</I>=[<I>value</I>]
1523 </DL>
1524
1525 <P>
1526
1527 If
1528 <I>value</I>
1529
1530 is not given, the variable is assigned the null string. All
1531 <I>values</I>
1532
1533 undergo tilde expansion, parameter and variable expansion,
1534 command substitution, arithmetic expansion, and quote
1535 removal (see
1536 <FONT SIZE=-1><B>EXPANSION</B>
1537
1538 </FONT>
1539 below). If the variable has its
1540 <B>integer</B>
1541
1542 attribute set, then
1543 <I>value</I>
1544
1545 is evaluated as an arithmetic expression even if the $((...)) expansion is
1546 not used (see
1547 <B>Arithmetic Expansion</B>
1548
1549 below).
1550 Word splitting is not performed, with the exception
1551 of <B>&quot;$@&quot;</B> as explained below under
1552 <B>Special Parameters</B>.
1553
1554 Pathname expansion is not performed.
1555 Assignment statements may also appear as arguments to the
1556 <B>alias</B>,
1557
1558 <B>declare</B>,
1559
1560 <B>typeset</B>,
1561
1562 <B>export</B>,
1563
1564 <B>readonly</B>,
1565
1566 and
1567 <B>local</B>
1568
1569 builtin commands.
1570 <P>
1571
1572 In the context where an assignment statement is assigning a value
1573 to a shell variable or array index, the += operator can be used to
1574 append to or add to the variable's previous value.
1575 When += is applied to a variable for which the <I>integer</I> attribute has been
1576 set, <I>value</I> is evaluated as an arithmetic expression and added to the
1577 variable's current value, which is also evaluated.
1578 When += is applied to an array variable using compound assignment (see
1579 <B>Arrays</B>
1580
1581 below), the
1582 variable's value is not unset (as it is when using =), and new values are
1583 appended to the array beginning at one greater than the array's maximum index
1584 (for indexed arrays) or added as additional key-value pairs in an
1585 associative array.
1586 When applied to a string-valued variable, <I>value</I> is expanded and
1587 appended to the variable's value.
1588 <A NAME="lbAU">&nbsp;</A>
1589 <H4>Positional Parameters</H4>
1590
1591 <P>
1592
1593 A
1594 <I>positional parameter</I>
1595
1596 is a parameter denoted by one or more
1597 digits, other than the single digit 0. Positional parameters are
1598 assigned from the shell's arguments when it is invoked,
1599 and may be reassigned using the
1600 <B>set</B>
1601
1602 builtin command. Positional parameters may not be assigned to
1603 with assignment statements. The positional parameters are
1604 temporarily replaced when a shell function is executed (see
1605 <FONT SIZE=-1><B>FUNCTIONS</B>
1606
1607 </FONT>
1608 below).
1609 <P>
1610
1611 When a positional parameter consisting of more than a single
1612 digit is expanded, it must be enclosed in braces (see
1613 <FONT SIZE=-1><B>EXPANSION</B>
1614
1615 </FONT>
1616 below).
1617 <A NAME="lbAV">&nbsp;</A>
1618 <H4>Special Parameters</H4>
1619
1620 <P>
1621
1622 The shell treats several parameters specially. These parameters may
1623 only be referenced; assignment to them is not allowed.
1624
1625 <DL COMPACT>
1626 <DT><B>*</B>
1627
1628 <DD>
1629 Expands to the positional parameters, starting from one. When the
1630 expansion occurs within double quotes, it expands to a single word
1631 with the value of each parameter separated by the first character
1632 of the
1633 <FONT SIZE=-1><B>IFS</B>
1634
1635 </FONT>
1636 special variable. That is, &quot;<B>$*</B>&quot; is equivalent
1637 to &quot;<B>$1</B><I>c</I><B>$2</B><I>c</I><B>...</B>&quot;, where
1638 <I>c</I>
1639
1640 is the first character of the value of the
1641 <FONT SIZE=-1><B>IFS</B>
1642
1643 </FONT>
1644 variable. If
1645 <FONT SIZE=-1><B>IFS</B>
1646
1647 </FONT>
1648 is unset, the parameters are separated by spaces.
1649 If
1650 <FONT SIZE=-1><B>IFS</B>
1651
1652 </FONT>
1653 is null, the parameters are joined without intervening separators.
1654 <DT><B>@</B>
1655
1656 <DD>
1657 Expands to the positional parameters, starting from one. When the
1658 expansion occurs within double quotes, each parameter expands to a
1659 separate word. That is, &quot;<B>$@</B>&quot; is equivalent to
1660 &quot;<B>$1</B>&quot; &quot;<B>$2</B>&quot; ...
1661 If the double-quoted expansion occurs within a word, the expansion of
1662 the first parameter is joined with the beginning part of the original
1663 word, and the expansion of the last parameter is joined with the last
1664 part of the original word.
1665 When there are no positional parameters, &quot;<B>$@</B>&quot; and
1666 <B>$@</B>
1667
1668 expand to nothing (i.e., they are removed).
1669 <DT><B>#</B>
1670
1671 <DD>
1672 Expands to the number of positional parameters in decimal.
1673 <DT><B>?</B>
1674
1675 <DD>
1676 Expands to the exit status of the most recently executed foreground
1677 pipeline.
1678 <DT><B>-</B>
1679
1680 <DD>
1681 Expands to the current option flags as specified upon invocation,
1682 by the
1683 <B>set</B>
1684
1685 builtin command, or those set by the shell itself
1686 (such as the
1687 <B>-i</B>
1688
1689 option).
1690 <DT><B>$</B>
1691
1692 <DD>
1693 Expands to the process ID of the shell. In a () subshell, it
1694 expands to the process ID of the current shell, not the
1695 subshell.
1696 <DT><B>!</B>
1697
1698 <DD>
1699 Expands to the process ID of the most recently executed background
1700 (asynchronous) command.
1701 <DT><B>0</B>
1702
1703 <DD>
1704 Expands to the name of the shell or shell script. This is set at
1705 shell initialization. If
1706 <B>bash</B>
1707
1708 is invoked with a file of commands,
1709 <B>$0</B>
1710
1711 is set to the name of that file. If
1712 <B>bash</B>
1713
1714 is started with the
1715 <B>-c</B>
1716
1717 option, then
1718 <B>$0</B>
1719
1720 is set to the first argument after the string to be
1721 executed, if one is present. Otherwise, it is set
1722 to the file name used to invoke
1723 <B>bash</B>,
1724
1725 as given by argument zero.
1726 <DT><B>_</B>
1727
1728 <DD>
1729 At shell startup, set to the absolute pathname used to invoke the
1730 shell or shell script being executed as passed in the environment
1731 or argument list.
1732 Subsequently, expands to the last argument to the previous command,
1733 after expansion.
1734 Also set to the full pathname used to invoke each command executed
1735 and placed in the environment exported to that command.
1736 When checking mail, this parameter holds the name of the mail file
1737 currently being checked.
1738
1739 </DL>
1740 <A NAME="lbAW">&nbsp;</A>
1741 <H4>Shell Variables</H4>
1742
1743 <P>
1744
1745 The following variables are set by the shell:
1746 <P>
1747
1748
1749 <DL COMPACT>
1750 <DT><B>BASH</B>
1751
1752 <DD>
1753 Expands to the full file name used to invoke this instance of
1754 <B>bash</B>.
1755
1756 <DT><B>BASHOPTS</B>
1757
1758 <DD>
1759 A colon-separated list of enabled shell options. Each word in
1760 the list is a valid argument for the
1761 <B>-s</B>
1762
1763 option to the
1764 <B>shopt</B>
1765
1766 builtin command (see
1767 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
1768
1769 </FONT>
1770 below). The options appearing in
1771 <FONT SIZE=-1><B>BASHOPTS</B>
1772
1773 </FONT>
1774 are those reported as
1775 <I>on</I>
1776
1777 by <B>shopt</B>.
1778 If this variable is in the environment when
1779 <B>bash</B>
1780
1781 starts up, each shell option in the list will be enabled before
1782 reading any startup files.
1783 This variable is read-only.
1784 <DT><B>BASHPID</B>
1785
1786 <DD>
1787 Expands to the process ID of the current <B>bash</B> process.
1788 This differs from <B>$$</B> under certain circumstances, such as subshells
1789 that do not require <B>bash</B> to be re-initialized.
1790 <DT><B>BASH_ALIASES</B>
1791
1792 <DD>
1793 An associative array variable whose members correspond to the internal
1794 list of aliases as maintained by the <B>alias</B> builtin.
1795 Elements added to this array appear in the alias list; unsetting array
1796 elements cause aliases to be removed from the alias list.
1797 <DT><B>BASH_ARGC</B>
1798
1799 <DD>
1800 An array variable whose values are the number of parameters in each
1801 frame of the current <B>bash</B> execution call stack.
1802 The number of
1803 parameters to the current subroutine (shell function or script executed
1804 with <B>.</B> or <B>source</B>) is at the top of the stack.
1805 When a subroutine is executed, the number of parameters passed is pushed onto
1806 <FONT SIZE=-1><B>BASH_ARGC</B>.
1807
1808 </FONT>
1809 The shell sets
1810 <FONT SIZE=-1><B>BASH_ARGC</B>
1811
1812 </FONT>
1813 only when in extended debugging mode (see the description of the
1814 <B>extdebug</B>
1815
1816 option to the
1817 <B>shopt</B>
1818
1819 builtin below)
1820 <DT><B>BASH_ARGV</B>
1821
1822 <DD>
1823 An array variable containing all of the parameters in the current <B>bash</B>
1824 execution call stack. The final parameter of the last subroutine call
1825 is at the top of the stack; the first parameter of the initial call is
1826 at the bottom. When a subroutine is executed, the parameters supplied
1827 are pushed onto
1828 <FONT SIZE=-1><B>BASH_ARGV</B>.
1829
1830 </FONT>
1831 The shell sets
1832 <FONT SIZE=-1><B>BASH_ARGV</B>
1833
1834 </FONT>
1835 only when in extended debugging mode
1836 (see the description of the
1837 <B>extdebug</B>
1838
1839 option to the
1840 <B>shopt</B>
1841
1842 builtin below)
1843 <DT><B>BASH_CMDS</B>
1844
1845 <DD>
1846 An associative array variable whose members correspond to the internal
1847 hash table of commands as maintained by the <B>hash</B> builtin.
1848 Elements added to this array appear in the hash table; unsetting array
1849 elements cause commands to be removed from the hash table.
1850 <DT><B>BASH_COMMAND</B>
1851
1852 <DD>
1853 The command currently being executed or about to be executed, unless the
1854 shell is executing a command as the result of a trap,
1855 in which case it is the command executing at the time of the trap.
1856 <DT><B>BASH_EXECUTION_STRING</B>
1857
1858 <DD>
1859 The command argument to the <B>-c</B> invocation option.
1860 <DT><B>BASH_LINENO</B>
1861
1862 <DD>
1863 An array variable whose members are the line numbers in source files
1864 where each corresponding member of
1865 <FONT SIZE=-1><B>FUNCNAME</B>
1866
1867 </FONT>
1868 was invoked.
1869 <B>${BASH_LINENO[</B><I>$i</I><B>]}</B> is the line number in the source
1870 file (<B>${BASH_SOURCE[</B><I>$i+1</I><B>]}</B>) where
1871 <B>${FUNCNAME[</B><I>$i</I><B>]}</B> was called
1872 (or <B>${BASH_LINENO[</B><I>$i-1</I><B>]}</B> if referenced within another
1873 shell function).
1874 Use
1875 <FONT SIZE=-1><B>LINENO</B>
1876
1877 </FONT>
1878 to obtain the current line number.
1879 <DT><B>BASH_REMATCH</B>
1880
1881 <DD>
1882 An array variable whose members are assigned by the <B>=~</B> binary
1883 operator to the <B>[[</B> conditional command.
1884 The element with index 0 is the portion of the string
1885 matching the entire regular expression.
1886 The element with index <I>n</I> is the portion of the
1887 string matching the <I>n</I>th parenthesized subexpression.
1888 This variable is read-only.
1889 <DT><B>BASH_SOURCE</B>
1890
1891 <DD>
1892 An array variable whose members are the source filenames
1893 where the corresponding shell function names in the
1894 <FONT SIZE=-1><B>FUNCNAME</B>
1895
1896 </FONT>
1897 array variable are defined.
1898 The shell function
1899 <B>${FUNCNAME[</B><I>$i</I><B>]}</B> is defined in the file
1900 <B>${BASH_SOURCE[</B><I>$i</I><B>]}</B> and called from
1901 <B>${BASH_SOURCE[</B><I>$i+1</I><B>]}</B>.
1902 <DT><B>BASH_SUBSHELL</B>
1903
1904 <DD>
1905 Incremented by one each time a subshell or subshell environment is spawned.
1906 The initial value is 0.
1907 <DT><B>BASH_VERSINFO</B>
1908
1909 <DD>
1910 A readonly array variable whose members hold version information for
1911 this instance of
1912 <B>bash</B>.
1913
1914 The values assigned to the array members are as follows:
1915 <P>
1916 <DL COMPACT><DT><DD>
1917
1918 <DL COMPACT>
1919 <DT><B>BASH_VERSINFO[</B>0]
1920
1921 <DD>
1922 The major version number (the <I>release</I>).
1923 <DT><B>BASH_VERSINFO[</B>1]
1924
1925 <DD>
1926 The minor version number (the <I>version</I>).
1927 <DT><B>BASH_VERSINFO[</B>2]
1928
1929 <DD>
1930 The patch level.
1931 <DT><B>BASH_VERSINFO[</B>3]
1932
1933 <DD>
1934 The build version.
1935 <DT><B>BASH_VERSINFO[</B>4]
1936
1937 <DD>
1938 The release status (e.g., <I>beta1</I>).
1939 <DT><B>BASH_VERSINFO[</B>5]
1940
1941 <DD>
1942 The value of
1943 <FONT SIZE=-1><B>MACHTYPE</B>.
1944
1945 </FONT>
1946
1947 </DL></DL>
1948
1949 <DT><B>BASH_VERSION</B>
1950
1951 <DD>
1952 Expands to a string describing the version of this instance of
1953 <B>bash</B>.
1954
1955 <DT><B>COMP_CWORD</B>
1956
1957 <DD>
1958 An index into <B>${COMP_WORDS}</B> of the word containing the current
1959 cursor position.
1960 This variable is available only in shell functions invoked by the
1961 programmable completion facilities (see <B>Programmable Completion</B>
1962 below).
1963 <DT><B>COMP_KEY</B>
1964
1965 <DD>
1966 The key (or final key of a key sequence) used to invoke the current
1967 completion function.
1968 <DT><B>COMP_LINE</B>
1969
1970 <DD>
1971 The current command line.
1972 This variable is available only in shell functions and external
1973 commands invoked by the
1974 programmable completion facilities (see <B>Programmable Completion</B>
1975 below).
1976 <DT><B>COMP_POINT</B>
1977
1978 <DD>
1979 The index of the current cursor position relative to the beginning of
1980 the current command.
1981 If the current cursor position is at the end of the current command,
1982 the value of this variable is equal to <B>${#COMP_LINE}</B>.
1983 This variable is available only in shell functions and external
1984 commands invoked by the
1985 programmable completion facilities (see <B>Programmable Completion</B>
1986 below).
1987 <DT><B>COMP_TYPE</B>
1988
1989 <DD>
1990 Set to an integer value corresponding to the type of completion attempted
1991 that caused a completion function to be called:
1992 <I>TAB</I>, for normal completion,
1993 <I>?</I>, for listing completions after successive tabs,
1994 <I>!</I>, for listing alternatives on partial word completion,
1995 <I>@</I>, to list completions if the word is not unmodified,
1996 or
1997 <I>%</I>, for menu completion.
1998 This variable is available only in shell functions and external
1999 commands invoked by the
2000 programmable completion facilities (see <B>Programmable Completion</B>
2001 below).
2002 <DT><B>COMP_WORDBREAKS</B>
2003
2004 <DD>
2005 The set of characters that the <B>readline</B> library treats as word
2006 separators when performing word completion.
2007 If
2008 <FONT SIZE=-1><B>COMP_WORDBREAKS</B>
2009
2010 </FONT>
2011 is unset, it loses its special properties, even if it is
2012 subsequently reset.
2013 <DT><B>COMP_WORDS</B>
2014
2015 <DD>
2016 An array variable (see <B>Arrays</B> below) consisting of the individual
2017 words in the current command line.
2018 The line is split into words as <B>readline</B> would split it, using
2019 <FONT SIZE=-1><B>COMP_WORDBREAKS</B>
2020
2021 </FONT>
2022 as described above.
2023 This variable is available only in shell functions invoked by the
2024 programmable completion facilities (see <B>Programmable Completion</B>
2025 below).
2026 <DT><B>COPROC</B>
2027
2028 <DD>
2029 An array variable (see <B>Arrays</B> below) created to hold the file descriptors
2030 for output from and input to an unnamed coprocess (see <B>Coprocesses</B>
2031 above).
2032 <DT><B>DIRSTACK</B>
2033
2034 <DD>
2035 An array variable (see
2036 <B>Arrays</B>
2037
2038 below) containing the current contents of the directory stack.
2039 Directories appear in the stack in the order they are displayed by the
2040 <B>dirs</B>
2041
2042 builtin.
2043 Assigning to members of this array variable may be used to modify
2044 directories already in the stack, but the
2045 <B>pushd</B>
2046
2047 and
2048 <B>popd</B>
2049
2050 builtins must be used to add and remove directories.
2051 Assignment to this variable will not change the current directory.
2052 If
2053 <FONT SIZE=-1><B>DIRSTACK</B>
2054
2055 </FONT>
2056 is unset, it loses its special properties, even if it is
2057 subsequently reset.
2058 <DT><B>EUID</B>
2059
2060 <DD>
2061 Expands to the effective user ID of the current user, initialized at
2062 shell startup. This variable is readonly.
2063 <DT><B>FUNCNAME</B>
2064
2065 <DD>
2066 An array variable containing the names of all shell functions
2067 currently in the execution call stack.
2068 The element with index 0 is the name of any currently-executing
2069 shell function.
2070 The bottom-most element (the one with the highest index) is
2071 <TT>&quot;main&quot;</TT>.
2072
2073 This variable exists only when a shell function is executing.
2074 Assignments to
2075 <FONT SIZE=-1><B>FUNCNAME</B>
2076
2077 </FONT>
2078 have no effect and return an error status.
2079 If
2080 <FONT SIZE=-1><B>FUNCNAME</B>
2081
2082 </FONT>
2083 is unset, it loses its special properties, even if it is
2084 subsequently reset.
2085 <P>
2086
2087
2088 This variable can be used with <B>BASH_LINENO</B> and <B>BASH_SOURCE</B>.
2089 Each element of <B>FUNCNAME</B> has corresponding elements in
2090 <B>BASH_LINENO</B> and <B>BASH_SOURCE</B> to describe the call stack.
2091 For instance, <B>${FUNCNAME[</B><I>$i</I><B>]}</B> was called from the file
2092 <B>${BASH_SOURCE[</B><I>$i+1</I><B>]}</B> at line number
2093 <B>${BASH_LINENO[</B><I>$i</I><B>]}</B>.
2094 The <B>caller</B> builtin displays the current call stack using this
2095 information.
2096 <DT><B>GROUPS</B>
2097
2098 <DD>
2099 An array variable containing the list of groups of which the current
2100 user is a member.
2101 Assignments to
2102 <FONT SIZE=-1><B>GROUPS</B>
2103
2104 </FONT>
2105 have no effect and return an error status.
2106 If
2107 <FONT SIZE=-1><B>GROUPS</B>
2108
2109 </FONT>
2110 is unset, it loses its special properties, even if it is
2111 subsequently reset.
2112 <DT><B>HISTCMD</B>
2113
2114 <DD>
2115 The history number, or index in the history list, of the current
2116 command.
2117 If
2118 <FONT SIZE=-1><B>HISTCMD</B>
2119
2120 </FONT>
2121 is unset, it loses its special properties, even if it is
2122 subsequently reset.
2123 <DT><B>HOSTNAME</B>
2124
2125 <DD>
2126 Automatically set to the name of the current host.
2127 <DT><B>HOSTTYPE</B>
2128
2129 <DD>
2130 Automatically set to a string that uniquely
2131 describes the type of machine on which
2132 <B>bash</B>
2133
2134 is executing.
2135 The default is system-dependent.
2136 <DT><B>LINENO</B>
2137
2138 <DD>
2139 Each time this parameter is referenced, the shell substitutes
2140 a decimal number representing the current sequential line number
2141 (starting with 1) within a script or function. When not in a
2142 script or function, the value substituted is not guaranteed to
2143 be meaningful.
2144 If
2145 <FONT SIZE=-1><B>LINENO</B>
2146
2147 </FONT>
2148 is unset, it loses its special properties, even if it is
2149 subsequently reset.
2150 <DT><B>MACHTYPE</B>
2151
2152 <DD>
2153 Automatically set to a string that fully describes the system
2154 type on which
2155 <B>bash</B>
2156
2157 is executing, in the standard GNU <I>cpu-company-system</I> format.
2158 The default is system-dependent.
2159 <DT><B>MAPFILE</B>
2160
2161 <DD>
2162 An array variable (see <B>Arrays</B> below) created to hold the text
2163 read by the <B>mapfile</B> builtin when no variable name is supplied.
2164 <DT><B>OLDPWD</B>
2165
2166 <DD>
2167 The previous working directory as set by the
2168 <B>cd</B>
2169
2170 command.
2171 <DT><B>OPTARG</B>
2172
2173 <DD>
2174 The value of the last option argument processed by the
2175 <B>getopts</B>
2176
2177 builtin command (see
2178 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2179
2180 </FONT>
2181 below).
2182 <DT><B>OPTIND</B>
2183
2184 <DD>
2185 The index of the next argument to be processed by the
2186 <B>getopts</B>
2187
2188 builtin command (see
2189 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2190
2191 </FONT>
2192 below).
2193 <DT><B>OSTYPE</B>
2194
2195 <DD>
2196 Automatically set to a string that
2197 describes the operating system on which
2198 <B>bash</B>
2199
2200 is executing.
2201 The default is system-dependent.
2202 <DT><B>PIPESTATUS</B>
2203
2204 <DD>
2205 An array variable (see
2206 <B>Arrays</B>
2207
2208 below) containing a list of exit status values from the processes
2209 in the most-recently-executed foreground pipeline (which may
2210 contain only a single command).
2211 <DT><B>PPID</B>
2212
2213 <DD>
2214 The process ID of the shell's parent. This variable is readonly.
2215 <DT><B>PWD</B>
2216
2217 <DD>
2218 The current working directory as set by the
2219 <B>cd</B>
2220
2221 command.
2222 <DT><B>RANDOM</B>
2223
2224 <DD>
2225 Each time this parameter is referenced, a random integer between
2226 0 and 32767 is
2227 generated. The sequence of random numbers may be initialized by assigning
2228 a value to
2229 <FONT SIZE=-1><B>RANDOM</B>.
2230
2231 </FONT>
2232 If
2233 <FONT SIZE=-1><B>RANDOM</B>
2234
2235 </FONT>
2236 is unset, it loses its special properties, even if it is
2237 subsequently reset.
2238 <DT><B>READLINE_LINE</B>
2239
2240 <DD>
2241 The contents of the
2242 <B>readline</B>
2243
2244 line buffer, for use with
2245 <TT>bind -x</TT>
2246
2247 (see
2248 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2249
2250 </FONT>
2251 below).
2252 <DT><B>READLINE_POINT</B>
2253
2254 <DD>
2255 The position of the insertion point in the
2256 <B>readline</B>
2257
2258 line buffer, for use with
2259 <TT>bind -x</TT>
2260
2261 (see
2262 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2263
2264 </FONT>
2265 below).
2266 <DT><B>REPLY</B>
2267
2268 <DD>
2269 Set to the line of input read by the
2270 <B>read</B>
2271
2272 builtin command when no arguments are supplied.
2273 <DT><B>SECONDS</B>
2274
2275 <DD>
2276 Each time this parameter is
2277 referenced, the number of seconds since shell invocation is returned. If a
2278 value is assigned to
2279 <FONT SIZE=-1><B>SECONDS</B>,
2280
2281 </FONT>
2282 the value returned upon subsequent
2283 references is
2284 the number of seconds since the assignment plus the value assigned.
2285 If
2286 <FONT SIZE=-1><B>SECONDS</B>
2287
2288 </FONT>
2289 is unset, it loses its special properties, even if it is
2290 subsequently reset.
2291 <DT><B>SHELLOPTS</B>
2292
2293 <DD>
2294 A colon-separated list of enabled shell options. Each word in
2295 the list is a valid argument for the
2296 <B>-o</B>
2297
2298 option to the
2299 <B>set</B>
2300
2301 builtin command (see
2302 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2303
2304 </FONT>
2305 below). The options appearing in
2306 <FONT SIZE=-1><B>SHELLOPTS</B>
2307
2308 </FONT>
2309 are those reported as
2310 <I>on</I>
2311
2312 by <B>set -o</B>.
2313 If this variable is in the environment when
2314 <B>bash</B>
2315
2316 starts up, each shell option in the list will be enabled before
2317 reading any startup files.
2318 This variable is read-only.
2319 <DT><B>SHLVL</B>
2320
2321 <DD>
2322 Incremented by one each time an instance of
2323 <B>bash</B>
2324
2325 is started.
2326 <DT><B>UID</B>
2327
2328 <DD>
2329 Expands to the user ID of the current user, initialized at shell startup.
2330 This variable is readonly.
2331
2332 </DL>
2333 <P>
2334
2335 The following variables are used by the shell. In some cases,
2336 <B>bash</B>
2337
2338 assigns a default value to a variable; these cases are noted
2339 below.
2340 <P>
2341
2342
2343 <DL COMPACT>
2344 <DT><B>BASH_ENV</B>
2345
2346 <DD>
2347 If this parameter is set when <B>bash</B> is executing a shell script,
2348 its value is interpreted as a filename containing commands to
2349 initialize the shell, as in
2350 <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>.
2351
2352 The value of
2353 <FONT SIZE=-1><B>BASH_ENV</B>
2354
2355 </FONT>
2356 is subjected to parameter expansion, command substitution, and arithmetic
2357 expansion before being interpreted as a file name.
2358 <FONT SIZE=-1><B>PATH</B>
2359
2360 </FONT>
2361 is not used to search for the resultant file name.
2362 <DT><B>BASH_XTRACEFD</B>
2363
2364 <DD>
2365 If set to an integer corresponding to a valid file descriptor, <B>bash</B>
2366 will write the trace output generated when
2367 <TT>set -x</TT>
2368
2369 is enabled to that file descriptor.
2370 The file descriptor is closed when
2371 <FONT SIZE=-1><B>BASH_XTRACEFD</B>
2372
2373 </FONT>
2374 is unset or assigned a new value.
2375 Unsetting
2376 <FONT SIZE=-1><B>BASH_XTRACEFD</B>
2377
2378 </FONT>
2379 or assigning it the empty string causes the
2380 trace output to be sent to the standard error.
2381 Note that setting
2382 <FONT SIZE=-1><B>BASH_XTRACEFD</B>
2383
2384 </FONT>
2385 to 2 (the standard error file
2386 descriptor) and then unsetting it will result in the standard error
2387 being closed.
2388 <DT><B>CDPATH</B>
2389
2390 <DD>
2391 The search path for the
2392 <B>cd</B>
2393
2394 command.
2395 This is a colon-separated list of directories in which the shell looks
2396 for destination directories specified by the
2397 <B>cd</B>
2398
2399 command.
2400 A sample value is
2401 <TT>&quot;.:~:/usr&quot;</TT>.
2402
2403 <DT><B>COLUMNS</B>
2404
2405 <DD>
2406 Used by the <B>select</B> builtin command to determine the terminal width
2407 when printing selection lists. Automatically set upon receipt of a
2408 <FONT SIZE=-1><B>SIGWINCH</B>.
2409
2410 </FONT>
2411 <DT><B>COMPREPLY</B>
2412
2413 <DD>
2414 An array variable from which <B>bash</B> reads the possible completions
2415 generated by a shell function invoked by the programmable completion
2416 facility (see <B>Programmable Completion</B> below).
2417 <DT><B>EMACS</B>
2418
2419 <DD>
2420 If <B>bash</B> finds this variable in the environment when the shell starts
2421 with value
2422 <TT>t</TT>,
2423
2424 it assumes that the shell is running in an Emacs shell buffer and disables
2425 line editing.
2426 <DT><B>ENV</B>
2427
2428 <DD>
2429 Similar to
2430 <FONT SIZE=-1><B>BASH_ENV</B>;
2431
2432 </FONT>
2433 used when the shell is invoked in POSIX mode.
2434 <DT><B>FCEDIT</B>
2435
2436 <DD>
2437 The default editor for the
2438 <B>fc</B>
2439
2440 builtin command.
2441 <DT><B>FIGNORE</B>
2442
2443 <DD>
2444 A colon-separated list of suffixes to ignore when performing
2445 filename completion (see
2446 <FONT SIZE=-1><B>READLINE</B>
2447
2448 </FONT>
2449 below).
2450 A filename whose suffix matches one of the entries in
2451 <FONT SIZE=-1><B>FIGNORE</B>
2452
2453 </FONT>
2454 is excluded from the list of matched filenames.
2455 A sample value is
2456 <TT>&quot;.o:~&quot;</TT>.
2457
2458 <DT><B>FUNCNEST</B>
2459
2460 <DD>
2461 If set to a numeric value greater than 0, defines a maximum function
2462 nesting level. Function invocations that exceed this nesting level
2463 will cause the current command to abort.
2464 <DT><B>GLOBIGNORE</B>
2465
2466 <DD>
2467 A colon-separated list of patterns defining the set of filenames to
2468 be ignored by pathname expansion.
2469 If a filename matched by a pathname expansion pattern also matches one
2470 of the patterns in
2471 <FONT SIZE=-1><B>GLOBIGNORE</B>,
2472
2473 </FONT>
2474 it is removed from the list of matches.
2475 <DT><B>HISTCONTROL</B>
2476
2477 <DD>
2478 A colon-separated list of values controlling how commands are saved on
2479 the history list.
2480 If the list of values includes
2481 <I>ignorespace</I>,
2482
2483 lines which begin with a
2484 <B>space</B>
2485
2486 character are not saved in the history list.
2487 A value of
2488 <I>ignoredups</I>
2489
2490 causes lines matching the previous history entry to not be saved.
2491 A value of
2492 <I>ignoreboth</I>
2493
2494 is shorthand for <I>ignorespace</I> and <I>ignoredups</I>.
2495 A value of
2496 <I>erasedups</I>
2497
2498 causes all previous lines matching the current line to be removed from
2499 the history list before that line is saved.
2500 Any value not in the above list is ignored.
2501 If
2502 <FONT SIZE=-1><B>HISTCONTROL</B>
2503
2504 </FONT>
2505 is unset, or does not include a valid value,
2506 all lines read by the shell parser are saved on the history list,
2507 subject to the value of
2508 <FONT SIZE=-1><B>HISTIGNORE</B>.
2509
2510 </FONT>
2511 The second and subsequent lines of a multi-line compound command are
2512 not tested, and are added to the history regardless of the value of
2513 <FONT SIZE=-1><B>HISTCONTROL</B>.
2514
2515 </FONT>
2516 <DT><B>HISTFILE</B>
2517
2518 <DD>
2519 The name of the file in which command history is saved (see
2520 <FONT SIZE=-1><B>HISTORY</B>
2521
2522 </FONT>
2523 below). The default value is <A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>. If unset, the
2524 command history is not saved when an interactive shell exits.
2525 <DT><B>HISTFILESIZE</B>
2526
2527 <DD>
2528 The maximum number of lines contained in the history file. When this
2529 variable is assigned a value, the history file is truncated, if
2530 necessary, by removing the oldest entries,
2531 to contain no more than that number of lines. The default
2532 value is 500. The history file is also truncated to this size after
2533 writing it when an interactive shell exits.
2534 <DT><B>HISTIGNORE</B>
2535
2536 <DD>
2537 A colon-separated list of patterns used to decide which command lines
2538 should be saved on the history list. Each pattern is anchored at the
2539 beginning of the line and must match the complete line (no implicit
2540 `<B>*</B>' is appended). Each pattern is tested against the line
2541 after the checks specified by
2542 <FONT SIZE=-1><B>HISTCONTROL</B>
2543
2544 </FONT>
2545 are applied.
2546 In addition to the normal shell pattern matching characters, `<B>&amp;</B>'
2547 matches the previous history line. `<B>&amp;</B>' may be escaped using a
2548 backslash; the backslash is removed before attempting a match.
2549 The second and subsequent lines of a multi-line compound command are
2550 not tested, and are added to the history regardless of the value of
2551 <FONT SIZE=-1><B>HISTIGNORE</B>.
2552
2553 </FONT>
2554 <DT><B>HISTSIZE</B>
2555
2556 <DD>
2557 The number of commands to remember in the command history (see
2558 <FONT SIZE=-1><B>HISTORY</B>
2559
2560 </FONT>
2561 below). The default value is 500.
2562 <DT><B>HISTTIMEFORMAT</B>
2563
2564 <DD>
2565 If this variable is set and not null, its value is used as a format string
2566 for <I>strftime</I>(3) to print the time stamp associated with each history
2567 entry displayed by the <B>history</B> builtin.
2568 If this variable is set, time stamps are written to the history file so
2569 they may be preserved across shell sessions.
2570 This uses the history comment character to distinguish timestamps from
2571 other history lines.
2572 <DT><B>HOME</B>
2573
2574 <DD>
2575 The home directory of the current user; the default argument for the
2576 <B>cd</B> builtin command.
2577 The value of this variable is also used when performing tilde expansion.
2578 <DT><B>HOSTFILE</B>
2579
2580 <DD>
2581 Contains the name of a file in the same format as
2582
2583 <I>/etc/hosts</I>
2584
2585 that should be read when the shell needs to complete a
2586 hostname.
2587 The list of possible hostname completions may be changed while the
2588 shell is running;
2589 the next time hostname completion is attempted after the
2590 value is changed,
2591 <B>bash</B>
2592
2593 adds the contents of the new file to the existing list.
2594 If
2595 <FONT SIZE=-1><B>HOSTFILE</B>
2596
2597 </FONT>
2598 is set, but has no value, or does not name a readable file,
2599 <B>bash</B> attempts to read
2600
2601 <I>/etc/hosts</I>
2602
2603 to obtain the list of possible hostname completions.
2604 When
2605 <FONT SIZE=-1><B>HOSTFILE</B>
2606
2607 </FONT>
2608 is unset, the hostname list is cleared.
2609 <DT><B>IFS</B>
2610
2611 <DD>
2612 The
2613 <I>Internal Field Separator</I>
2614
2615 that is used
2616 for word splitting after expansion and to
2617 split lines into words with the
2618 <B>read</B>
2619
2620 builtin command. The default value is
2621 ``&lt;space&gt;&lt;tab&gt;&lt;newline&gt;''.
2622 <DT><B>IGNOREEOF</B>
2623
2624 <DD>
2625 Controls the
2626 action of an interactive shell on receipt of an
2627 <FONT SIZE=-1><B>EOF</B>
2628
2629 </FONT>
2630 character as the sole input. If set, the value is the number of
2631 consecutive
2632 <FONT SIZE=-1><B>EOF</B>
2633
2634 </FONT>
2635 characters which must be
2636 typed as the first characters on an input line before
2637 <B>bash</B>
2638
2639 exits. If the variable exists but does not have a numeric value, or
2640 has no value, the default value is 10. If it does not exist,
2641 <FONT SIZE=-1><B>EOF</B>
2642
2643 </FONT>
2644 signifies the end of input to the shell.
2645 <DT><B>INPUTRC</B>
2646
2647 <DD>
2648 The filename for the
2649 <B>readline</B>
2650
2651 startup file, overriding the default of
2652
2653 <A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>
2654
2655 (see
2656 <FONT SIZE=-1><B>READLINE</B>
2657
2658 </FONT>
2659 below).
2660 <DT><B>LANG</B>
2661
2662 <DD>
2663 Used to determine the locale category for any category not specifically
2664 selected with a variable starting with <B>LC_</B>.
2665 <DT><B>LC_ALL</B>
2666
2667 <DD>
2668 This variable overrides the value of
2669 <FONT SIZE=-1><B>LANG</B>
2670
2671 </FONT>
2672 and any other
2673 <B>LC_</B> variable specifying a locale category.
2674 <DT><B>LC_COLLATE</B>
2675
2676 <DD>
2677 This variable determines the collation order used when sorting the
2678 results of pathname expansion, and determines the behavior of range
2679 expressions, equivalence classes, and collating sequences within
2680 pathname expansion and pattern matching.
2681 <DT><B>LC_CTYPE</B>
2682
2683 <DD>
2684 This variable determines the interpretation of characters and the
2685 behavior of character classes within pathname expansion and pattern
2686 matching.
2687 <DT><B>LC_MESSAGES</B>
2688
2689 <DD>
2690 This variable determines the locale used to translate double-quoted
2691 strings preceded by a <B>$</B>.
2692 <DT><B>LC_NUMERIC</B>
2693
2694 <DD>
2695 This variable determines the locale category used for number formatting.
2696 <DT><B>LINES</B>
2697
2698 <DD>
2699 Used by the <B>select</B> builtin command to determine the column length
2700 for printing selection lists. Automatically set upon receipt of a
2701 <FONT SIZE=-1><B>SIGWINCH</B>.
2702
2703 </FONT>
2704 <DT><B>MAIL</B>
2705
2706 <DD>
2707 If this parameter is set to a file or directory name and the
2708 <FONT SIZE=-1><B>MAILPATH</B>
2709
2710 </FONT>
2711 variable is not set,
2712 <B>bash</B>
2713
2714 informs the user of the arrival of mail in the specified file or
2715 Maildir-format directory.
2716 <DT><B>MAILCHECK</B>
2717
2718 <DD>
2719 Specifies how
2720 often (in seconds)
2721 <B>bash</B>
2722
2723 checks for mail. The default is 60 seconds. When it is time to check
2724 for mail, the shell does so before displaying the primary prompt.
2725 If this variable is unset, or set to a value that is not a number
2726 greater than or equal to zero, the shell disables mail checking.
2727 <DT><B>MAILPATH</B>
2728
2729 <DD>
2730 A colon-separated list of file names to be checked for mail.
2731 The message to be printed when mail arrives in a particular file
2732 may be specified by separating the file name from the message with a `?'.
2733 When used in the text of the message, <B>$_</B> expands to the name of
2734 the current mailfile.
2735 Example:
2736 <DL COMPACT><DT><DD>
2737 <P>
2738
2739 <B>MAILPATH</B>=aq/var/mail/bfox?&quot;You have mail&quot;:~/shell-mail?&quot;$_ has mail!&quot;aq
2740 <P>
2741
2742 <B>Bash</B>
2743
2744 supplies a default value for this variable, but the location of the user
2745 mail files that it uses is system dependent (e.g., /var/mail/<B>$USER</B>).
2746 </DL>
2747
2748 <DT><B>OPTERR</B>
2749
2750 <DD>
2751 If set to the value 1,
2752 <B>bash</B>
2753
2754 displays error messages generated by the
2755 <B>getopts</B>
2756
2757 builtin command (see
2758 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2759
2760 </FONT>
2761 below).
2762 <FONT SIZE=-1><B>OPTERR</B>
2763
2764 </FONT>
2765 is initialized to 1 each time the shell is invoked or a shell
2766 script is executed.
2767 <DT><B>PATH</B>
2768
2769 <DD>
2770 The search path for commands. It
2771 is a colon-separated list of directories in which
2772 the shell looks for commands (see
2773 <FONT SIZE=-1><B>COMMAND EXECUTION</B>
2774
2775 </FONT>
2776 below).
2777 A zero-length (null) directory name in the value of
2778 <FONT SIZE=-1><B>PATH</B>
2779
2780 </FONT>
2781 indicates the current directory.
2782 A null directory name may appear as two adjacent colons, or as an initial
2783 or trailing colon.
2784 The default path is system-dependent,
2785 and is set by the administrator who installs
2786 <B>bash</B>.
2787
2788 A common value is
2789 <TT>/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin</TT>.
2790
2791 <DT><B>POSIXLY_CORRECT</B>
2792
2793 <DD>
2794 If this variable is in the environment when <B>bash</B> starts, the shell
2795 enters <I>posix mode</I> before reading the startup files, as if the
2796 <B>--posix</B>
2797
2798 invocation option had been supplied. If it is set while the shell is
2799 running, <B>bash</B> enables <I>posix mode</I>, as if the command
2800 <TT>set -o posix</TT>
2801
2802 had been executed.
2803 <DT><B>PROMPT_COMMAND</B>
2804
2805 <DD>
2806 If set, the value is executed as a command prior to issuing each primary
2807 prompt.
2808 <DT><B>PROMPT_DIRTRIM</B>
2809
2810 <DD>
2811 If set to a number greater than zero, the value is used as the number of
2812 trailing directory components to retain when expanding the <B>\w</B> and
2813 <B>\W</B> prompt string escapes (see
2814 <FONT SIZE=-1><B>PROMPTING</B>
2815
2816 </FONT>
2817 below). Characters removed are replaced with an ellipsis.
2818 <DT><B>PS1</B>
2819
2820 <DD>
2821 The value of this parameter is expanded (see
2822 <FONT SIZE=-1><B>PROMPTING</B>
2823
2824 </FONT>
2825 below) and used as the primary prompt string. The default value is
2826 ``<B>\s-\v\$ </B>''.
2827 <DT><B>PS2</B>
2828
2829 <DD>
2830 The value of this parameter is expanded as with
2831 <FONT SIZE=-1><B>PS1</B>
2832
2833 </FONT>
2834 and used as the secondary prompt string. The default is
2835 ``<B>&gt; </B>''.
2836 <DT><B>PS3</B>
2837
2838 <DD>
2839 The value of this parameter is used as the prompt for the
2840 <B>select</B>
2841
2842 command (see
2843 <FONT SIZE=-1><B>SHELL GRAMMAR</B>
2844
2845 </FONT>
2846 above).
2847 <DT><B>PS4</B>
2848
2849 <DD>
2850 The value of this parameter is expanded as with
2851 <FONT SIZE=-1><B>PS1</B>
2852
2853 </FONT>
2854 and the value is printed before each command
2855 <B>bash</B>
2856
2857 displays during an execution trace. The first character of
2858 <FONT SIZE=-1><B>PS4</B>
2859
2860 </FONT>
2861 is replicated multiple times, as necessary, to indicate multiple
2862 levels of indirection. The default is ``<B>+ </B>''.
2863 <DT><B>SHELL</B>
2864
2865 <DD>
2866 The full pathname to the shell is kept in this environment variable.
2867 If it is not set when the shell starts,
2868 <B>bash</B>
2869
2870 assigns to it the full pathname of the current user's login shell.
2871 <DT><B>TIMEFORMAT</B>
2872
2873 <DD>
2874 The value of this parameter is used as a format string specifying
2875 how the timing information for pipelines prefixed with the
2876 <B>time</B>
2877
2878 reserved word should be displayed.
2879 The <B>%</B> character introduces an escape sequence that is
2880 expanded to a time value or other information.
2881 The escape sequences and their meanings are as follows; the
2882 braces denote optional portions.
2883 <P>
2884 <DL COMPACT><DT><DD>
2885
2886 <DL COMPACT>
2887 <DT><B>%%</B>
2888
2889 <DD>
2890 A literal <B>%</B>.
2891 <DT><B>%[</B><I>p</I>][l]R
2892
2893 <DD>
2894 The elapsed time in seconds.
2895 <DT><B>%[</B><I>p</I>][l]U
2896
2897 <DD>
2898 The number of CPU seconds spent in user mode.
2899 <DT><B>%[</B><I>p</I>][l]S
2900
2901 <DD>
2902 The number of CPU seconds spent in system mode.
2903 <DT><B>%P</B>
2904
2905 <DD>
2906 The CPU percentage, computed as (%U + %S) / %R.
2907
2908 </DL></DL>
2909
2910 <DT><DD>
2911 The optional <I>p</I> is a digit specifying the <I>precision</I>,
2912 the number of fractional digits after a decimal point.
2913 A value of 0 causes no decimal point or fraction to be output.
2914 At most three places after the decimal point may be specified;
2915 values of <I>p</I> greater than 3 are changed to 3.
2916 If <I>p</I> is not specified, the value 3 is used.
2917 <DT><DD>
2918 The optional <B>l</B> specifies a longer format, including
2919 minutes, of the form <I>MM</I>m<I>SS</I>.<I>FF</I>s.
2920 The value of <I>p</I> determines whether or not the fraction is
2921 included.
2922 <DT><DD>
2923 If this variable is not set, <B>bash</B> acts as if it had the
2924 value <B>$aq\nreal\t%3lR\nuser\t%3lU\nsys %3lSaq</B>.
2925 If the value is null, no timing information is displayed.
2926 A trailing newline is added when the format string is displayed.
2927 <DT><B>TMOUT</B>
2928
2929 <DD>
2930 If set to a value greater than zero,
2931 <FONT SIZE=-1><B>TMOUT</B>
2932
2933 </FONT>
2934 is treated as the
2935 default timeout for the <B>read</B> builtin.
2936 The <B>select</B> command terminates if input does not arrive
2937 after
2938 <FONT SIZE=-1><B>TMOUT</B>
2939
2940 </FONT>
2941 seconds when input is coming from a terminal.
2942 In an interactive shell, the value is interpreted as the
2943 number of seconds to wait for input after issuing the primary prompt.
2944 <B>Bash</B>
2945
2946 terminates after waiting for that number of seconds if input does
2947 not arrive.
2948 <DT><B>TMPDIR</B>
2949
2950 <DD>
2951 If set, <B>bash</B> uses its value as the name of a directory in which
2952 <B>bash</B> creates temporary files for the shell's use.
2953 <DT><B>auto_resume</B>
2954
2955 <DD>
2956 This variable controls how the shell interacts with the user and
2957 job control. If this variable is set, single word simple
2958 commands without redirections are treated as candidates for resumption
2959 of an existing stopped job. There is no ambiguity allowed; if there is
2960 more than one job beginning with the string typed, the job most recently
2961 accessed is selected. The
2962 <I>name</I>
2963
2964 of a stopped job, in this context, is the command line used to
2965 start it.
2966 If set to the value
2967 <I>exact</I>,
2968
2969 the string supplied must match the name of a stopped job exactly;
2970 if set to
2971 <I>substring</I>,
2972
2973 the string supplied needs to match a substring of the name of a
2974 stopped job. The
2975 <I>substring</I>
2976
2977 value provides functionality analogous to the
2978 <B>%?</B>
2979
2980 job identifier (see
2981 <FONT SIZE=-1><B>JOB CONTROL</B>
2982
2983 </FONT>
2984 below). If set to any other value, the supplied string must
2985 be a prefix of a stopped job's name; this provides functionality
2986 analogous to the <B>%</B><I>string</I> job identifier.
2987 <DT><B>histchars</B>
2988
2989 <DD>
2990 The two or three characters which control history expansion
2991 and tokenization (see
2992 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
2993
2994 </FONT>
2995 below). The first character is the <I>history expansion</I> character,
2996 the character which signals the start of a history
2997 expansion, normally `<B>!</B>'.
2998 The second character is the <I>quick substitution</I>
2999 character, which is used as shorthand for re-running the previous
3000 command entered, substituting one string for another in the command.
3001 The default is `<B>^</B>'.
3002 The optional third character is the character
3003 which indicates that the remainder of the line is a comment when found
3004 as the first character of a word, normally `<B>#</B>'. The history
3005 comment character causes history substitution to be skipped for the
3006 remaining words on the line. It does not necessarily cause the shell
3007 parser to treat the rest of the line as a comment.
3008
3009 </DL>
3010 <A NAME="lbAX">&nbsp;</A>
3011 <H4>Arrays</H4>
3012
3013 <B>Bash</B>
3014
3015 provides one-dimensional indexed and associative array variables.
3016 Any variable may be used as an indexed array; the
3017 <B>declare</B>
3018
3019 builtin will explicitly declare an array.
3020 There is no maximum
3021 limit on the size of an array, nor any requirement that members
3022 be indexed or assigned contiguously.
3023 Indexed arrays are referenced using integers (including arithmetic
3024 expressions) and are zero-based; associative arrays are referenced
3025 using arbitrary strings.
3026 <P>
3027
3028 An indexed array is created automatically if any variable is assigned to
3029 using the syntax <I>name</I>[<I>subscript</I>]=<I>value</I>. The
3030 <I>subscript</I>
3031
3032 is treated as an arithmetic expression that must evaluate to a number.
3033 If
3034 <I>subscript</I>
3035
3036 evaluates to a number less than zero, it is used as
3037 an offset from one greater than the array's maximum index (so a subcript
3038 of -1 refers to the last element of the array).
3039 To explicitly declare an indexed array, use
3040 <B>declare -a </B><I>name</I>
3041
3042 (see
3043 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
3044
3045 </FONT>
3046 below).
3047 <B>declare -a </B><I>name</I>[<I>subscript</I>]
3048
3049 is also accepted; the <I>subscript</I> is ignored.
3050 <P>
3051
3052 Associative arrays are created using
3053 <B>declare -A </B><I>name</I>.
3054
3055 <P>
3056
3057 Attributes may be
3058 specified for an array variable using the
3059 <B>declare</B>
3060
3061 and
3062 <B>readonly</B>
3063
3064 builtins. Each attribute applies to all members of an array.
3065 <P>
3066
3067 Arrays are assigned to using compound assignments of the form
3068 <I>name</I>=<B>(</B>value<I>1</I> ... value<I>n</I><B>)</B>, where each
3069 <I>value</I> is of the form [<I>subscript</I>]=<I>string</I>.
3070 Indexed array assignments do not require the bracket and subscript.
3071 When assigning to indexed arrays, if the optional brackets and subscript
3072 are supplied, that index is assigned to;
3073 otherwise the index of the element assigned is the last index assigned
3074 to by the statement plus one. Indexing starts at zero.
3075 <P>
3076
3077 When assigning to an associative array, the subscript is required.
3078 <P>
3079
3080 This syntax is also accepted by the
3081 <B>declare</B>
3082
3083 builtin. Individual array elements may be assigned to using the
3084 <I>name</I>[<I>subscript</I>]=<I>value</I> syntax introduced above.
3085 <P>
3086
3087 Any element of an array may be referenced using
3088 ${<I>name</I>[<I>subscript</I>]}. The braces are required to avoid
3089 conflicts with pathname expansion. If
3090 <I>subscript</I> is <B>@</B> or <B>*</B>, the word expands to
3091 all members of <I>name</I>. These subscripts differ only when the
3092 word appears within double quotes. If the word is double-quoted,
3093 ${<I>name</I>[*]} expands to a single
3094 word with the value of each array member separated by the first
3095 character of the
3096 <FONT SIZE=-1><B>IFS</B>
3097
3098 </FONT>
3099 special variable, and ${<I>name</I>[@]} expands each element of
3100 <I>name</I> to a separate word. When there are no array members,
3101 ${<I>name</I>[@]} expands to nothing.
3102 If the double-quoted expansion occurs within a word, the expansion of
3103 the first parameter is joined with the beginning part of the original
3104 word, and the expansion of the last parameter is joined with the last
3105 part of the original word.
3106 This is analogous to the expansion
3107 of the special parameters <B>*</B> and <B>@</B> (see
3108 <B>Special Parameters</B>
3109
3110 above). ${#<I>name</I>[<I>subscript</I>]} expands to the length of
3111 ${<I>name</I>[<I>subscript</I>]}. If <I>subscript</I> is <B>*</B> or
3112 <B>@</B>, the expansion is the number of elements in the array.
3113 Referencing an array variable without a subscript is equivalent to
3114 referencing the array with a subscript of 0.
3115 <P>
3116
3117 An array variable is considered set if a subscript has been assigned a
3118 value. The null string is a valid value.
3119 <P>
3120
3121 The
3122 <B>unset</B>
3123
3124 builtin is used to destroy arrays. <B>unset</B> <I>name</I>[<I>subscript</I>]
3125 destroys the array element at index <I>subscript</I>.
3126 Care must be taken to avoid unwanted side effects caused by pathname
3127 expansion.
3128 <B>unset</B> <I>name</I>, where <I>name</I> is an array, or
3129 <B>unset</B> <I>name</I>[<I>subscript</I>], where
3130 <I>subscript</I> is <B>*</B> or <B>@</B>, removes the entire array.
3131 <P>
3132
3133 The
3134 <B>declare</B>,
3135
3136 <B>local</B>,
3137
3138 and
3139 <B>readonly</B>
3140
3141 builtins each accept a
3142 <B>-a</B>
3143
3144 option to specify an indexed array and a
3145 <B>-A</B>
3146
3147 option to specify an associative array.
3148 The
3149 <B>read</B>
3150
3151 builtin accepts a
3152 <B>-a</B>
3153
3154 option to assign a list of words read from the standard input
3155 to an array. The
3156 <B>set</B>
3157
3158 and
3159 <B>declare</B>
3160
3161 builtins display array values in a way that allows them to be
3162 reused as assignments.
3163 <A NAME="lbAY">&nbsp;</A>
3164 <H3>EXPANSION</H3>
3165
3166 Expansion is performed on the command line after it has been split into
3167 words. There are seven kinds of expansion performed:
3168 <I>brace expansion</I>,
3169
3170 <I>tilde expansion</I>,
3171
3172 <I>parameter and variable expansion</I>,
3173
3174 <I>command substitution</I>,
3175
3176 <I>arithmetic expansion</I>,
3177
3178 <I>word splitting</I>,
3179
3180 and
3181 <I>pathname expansion</I>.
3182
3183 <P>
3184
3185 The order of expansions is: brace expansion, tilde expansion,
3186 parameter, variable and arithmetic expansion and
3187 command substitution
3188 (done in a left-to-right fashion), word splitting, and pathname
3189 expansion.
3190 <P>
3191
3192 On systems that can support it, there is an additional expansion
3193 available: <I>process substitution</I>.
3194 <P>
3195
3196 Only brace expansion, word splitting, and pathname expansion
3197 can change the number of words of the expansion; other expansions
3198 expand a single word to a single word.
3199 The only exceptions to this are the expansions of
3200 &quot;<B>$@</B>&quot; and &quot;<B>${</B><I>name</I><B>[@]}</B>&quot;
3201 as explained above (see
3202 <FONT SIZE=-1><B>PARAMETERS</B>).
3203
3204 </FONT>
3205 <A NAME="lbAZ">&nbsp;</A>
3206 <H4>Brace Expansion</H4>
3207
3208 <P>
3209
3210 <I>Brace expansion</I>
3211
3212 is a mechanism by which arbitrary strings
3213 may be generated. This mechanism is similar to
3214 <I>pathname expansion</I>, but the filenames generated
3215 need not exist. Patterns to be brace expanded take
3216 the form of an optional
3217 <I>preamble</I>,
3218
3219 followed by either a series of comma-separated strings or
3220 a sequence expression between a pair of braces, followed by
3221 an optional
3222 <I>postscript</I>.
3223
3224 The preamble is prefixed to each string contained
3225 within the braces, and the postscript is then appended
3226 to each resulting string, expanding left to right.
3227 <P>
3228
3229 Brace expansions may be nested. The results of each expanded
3230 string are not sorted; left to right order is preserved.
3231 For example, a<B>{</B>d,c,b<B>}</B>e expands into `ade ace abe'.
3232 <P>
3233
3234 A sequence expression takes the form
3235 <B>{</B><I>x</I><B>..</B><I>y</I><B>[..</B><I>incr</I><B>]}</B>,
3236 where <I>x</I> and <I>y</I> are either integers or single characters,
3237 and <I>incr</I>, an optional increment, is an integer.
3238 When integers are supplied, the expression expands to each number between
3239 <I>x</I> and <I>y</I>, inclusive.
3240 Supplied integers may be prefixed with <I>0</I> to force each term to have the
3241 same width. When either <I>x</I> or y begins with a zero, the shell
3242 attempts to force all generated terms to contain the same number of digits,
3243 zero-padding where necessary.
3244 When characters are supplied, the expression expands to each character
3245 lexicographically between <I>x</I> and <I>y</I>, inclusive. Note that
3246 both <I>x</I> and <I>y</I> must be of the same type.
3247 When the increment is supplied, it is used as the difference between
3248 each term. The default increment is 1 or -1 as appropriate.
3249 <P>
3250
3251 Brace expansion is performed before any other expansions,
3252 and any characters special to other expansions are preserved
3253 in the result. It is strictly textual.
3254 <B>Bash</B>
3255
3256 does not apply any syntactic interpretation to the context of the
3257 expansion or the text between the braces.
3258 <P>
3259
3260 A correctly-formed brace expansion must contain unquoted opening
3261 and closing braces, and at least one unquoted comma or a valid
3262 sequence expression.
3263 Any incorrectly formed brace expansion is left unchanged.
3264 A <B>{</B> or <B>,</B> may be quoted with a backslash to prevent its
3265 being considered part of a brace expression.
3266 To avoid conflicts with parameter expansion, the string <B>${</B>
3267 is not considered eligible for brace expansion.
3268 <P>
3269
3270 This construct is typically used as shorthand when the common
3271 prefix of the strings to be generated is longer than in the
3272 above example:
3273 <DL COMPACT><DT><DD>
3274 <P>
3275
3276 mkdir /usr/local/src/bash/{old,new,dist,bugs}
3277 </DL>
3278
3279 or
3280 <DL COMPACT><DT><DD>
3281 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
3282 </DL>
3283
3284 <P>
3285
3286 Brace expansion introduces a slight incompatibility with
3287 historical versions of
3288 <B>sh</B>.
3289
3290 <B>sh</B>
3291
3292 does not treat opening or closing braces specially when they
3293 appear as part of a word, and preserves them in the output.
3294 <B>Bash</B>
3295
3296 removes braces from words as a consequence of brace
3297 expansion. For example, a word entered to
3298 <B>sh</B>
3299
3300 as <I>file{1,2}</I>
3301 appears identically in the output. The same word is
3302 output as
3303 <I>file1 file2</I>
3304
3305 after expansion by
3306 <B>bash</B>.
3307
3308 If strict compatibility with
3309 <B>sh</B>
3310
3311 is desired, start
3312 <B>bash</B>
3313
3314 with the
3315 <B>+B </B>
3316
3317 option or disable brace expansion with the
3318 <B>+B</B>
3319
3320 option to the
3321 <B>set</B>
3322
3323 command (see
3324 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
3325
3326 </FONT>
3327 below).
3328 <A NAME="lbBA">&nbsp;</A>
3329 <H4>Tilde Expansion</H4>
3330
3331 <P>
3332
3333 If a word begins with an unquoted tilde character (`<B>~</B>'), all of
3334 the characters preceding the first unquoted slash (or all characters,
3335 if there is no unquoted slash) are considered a <I>tilde-prefix</I>.
3336 If none of the characters in the tilde-prefix are quoted, the
3337 characters in the tilde-prefix following the tilde are treated as a
3338 possible <I>login name</I>.
3339 If this login name is the null string, the tilde is replaced with the
3340 value of the shell parameter
3341 <FONT SIZE=-1><B>HOME</B>.
3342
3343 </FONT>
3344 If
3345 <FONT SIZE=-1><B>HOME</B>
3346
3347 </FONT>
3348 is unset, the home directory of the user executing the shell is
3349 substituted instead.
3350 Otherwise, the tilde-prefix is replaced with the home directory
3351 associated with the specified login name.
3352 <P>
3353
3354 If the tilde-prefix is a `~+', the value of the shell variable
3355 <FONT SIZE=-1><B>PWD</B>
3356
3357 </FONT>
3358 replaces the tilde-prefix.
3359 If the tilde-prefix is a `~-', the value of the shell variable
3360 <FONT SIZE=-1><B>OLDPWD</B>,
3361
3362 </FONT>
3363 if it is set, is substituted.
3364 If the characters following the tilde in the tilde-prefix consist
3365 of a number <I>N</I>, optionally prefixed
3366 by a `+' or a `-', the tilde-prefix is replaced with the corresponding
3367 element from the directory stack, as it would be displayed by the
3368 <B>dirs</B>
3369
3370 builtin invoked with the tilde-prefix as an argument.
3371 If the characters following the tilde in the tilde-prefix consist of a
3372 number without a leading `+' or `-', `+' is assumed.
3373 <P>
3374
3375 If the login name is invalid, or the tilde expansion fails, the word
3376 is unchanged.
3377 <P>
3378
3379 Each variable assignment is checked for unquoted tilde-prefixes immediately
3380 following a
3381 <B>:</B>
3382
3383 or the first
3384 <B>=</B>.
3385
3386 In these cases, tilde expansion is also performed.
3387 Consequently, one may use file names with tildes in assignments to
3388 <FONT SIZE=-1><B>PATH</B>,
3389
3390 </FONT>
3391 <FONT SIZE=-1><B>MAILPATH</B>,
3392
3393 </FONT>
3394 and
3395 <FONT SIZE=-1><B>CDPATH</B>,
3396
3397 </FONT>
3398 and the shell assigns the expanded value.
3399 <A NAME="lbBB">&nbsp;</A>
3400 <H4>Parameter Expansion</H4>
3401
3402 <P>
3403
3404 The `<B>$</B>' character introduces parameter expansion,
3405 command substitution, or arithmetic expansion. The parameter name
3406 or symbol to be expanded may be enclosed in braces, which
3407 are optional but serve to protect the variable to be expanded from
3408 characters immediately following it which could be
3409 interpreted as part of the name.
3410 <P>
3411
3412 When braces are used, the matching ending brace is the first `<B>}</B>'
3413 not escaped by a backslash or within a quoted string, and not within an
3414 embedded arithmetic expansion, command substitution, or parameter
3415 expansion.
3416 <P>
3417
3418
3419 <DL COMPACT>
3420 <DT>${<I>parameter</I>}<DD>
3421 The value of <I>parameter</I> is substituted. The braces are required
3422 when
3423 <I>parameter</I>
3424
3425 is a positional parameter with more than one digit,
3426 or when
3427 <I>parameter</I>
3428
3429 is followed by a character which is not to be
3430 interpreted as part of its name.
3431
3432 </DL>
3433 <P>
3434
3435 If the first character of <I>parameter</I> is an exclamation point (<B>!</B>),
3436 a level of variable indirection is introduced.
3437 <B>Bash</B> uses the value of the variable formed from the rest of
3438 <I>parameter</I> as the name of the variable; this variable is then
3439 expanded and that value is used in the rest of the substitution, rather
3440 than the value of <I>parameter</I> itself.
3441 This is known as <I>indirect expansion</I>.
3442 The exceptions to this are the expansions of ${<B>!\fPfIprefix</B><B>*</B>} and
3443 ${<B>!</B><I>name</I>[<I>@</I>]} described below.
3444 The exclamation point must immediately follow the left brace in order to
3445 introduce indirection.
3446 <P>
3447
3448 In each of the cases below, <I>word</I> is subject to tilde expansion,
3449 parameter expansion, command substitution, and arithmetic expansion.
3450 <P>
3451
3452 When not performing substring expansion, using the forms documented below,
3453 <B>bash</B> tests for a parameter that is unset or null. Omitting the colon
3454 results in a test only for a parameter that is unset.
3455 <P>
3456
3457
3458 <DL COMPACT>
3459 <DT>${<I>parameter</I><B>:-</B><I>word</I>}<DD>
3460 <B>Use Default Values</B>. If
3461 <I>parameter</I>
3462
3463 is unset or null, the expansion of
3464 <I>word</I>
3465
3466 is substituted. Otherwise, the value of
3467 <I>parameter</I>
3468
3469 is substituted.
3470 <DT>${<I>parameter</I><B>:=</B><I>word</I>}<DD>
3471 <B>Assign Default Values</B>.
3472 If
3473 <I>parameter</I>
3474
3475 is unset or null, the expansion of
3476 <I>word</I>
3477
3478 is assigned to
3479 <I>parameter</I>.
3480
3481 The value of
3482 <I>parameter</I>
3483
3484 is then substituted. Positional parameters and special parameters may
3485 not be assigned to in this way.
3486 <DT>${<I>parameter</I><B>:?</B><I>word</I>}<DD>
3487 <B>Display Error if Null or Unset</B>.
3488 If
3489 <I>parameter</I>
3490
3491 is null or unset, the expansion of <I>word</I> (or a message to that effect
3492 if
3493 <I>word</I>
3494
3495 is not present) is written to the standard error and the shell, if it
3496 is not interactive, exits. Otherwise, the value of <I>parameter</I> is
3497 substituted.
3498 <DT>${<I>parameter</I><B>:+</B><I>word</I>}<DD>
3499 <B>Use Alternate Value</B>.
3500 If
3501 <I>parameter</I>
3502
3503 is null or unset, nothing is substituted, otherwise the expansion of
3504 <I>word</I>
3505
3506 is substituted.
3507 <DT>${<I>parameter</I><B>:</B><I>offset</I>}<DD>
3508
3509 <DT>${<I>parameter</I><B>:</B><I>offset</I><B>:</B><I>length</I>}<DD>
3510
3511 <B>Substring Expansion</B>.
3512 Expands to up to <I>length</I> characters of <I>parameter</I>
3513 starting at the character specified by <I>offset</I>.
3514 If <I>length</I> is omitted, expands to the substring of
3515 <I>parameter</I> starting at the character specified by <I>offset</I>.
3516 <I>length</I> and <I>offset</I> are arithmetic expressions (see
3517 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
3518
3519 </FONT>
3520 below).
3521 If <I>offset</I> evaluates to a number less than zero, the value
3522 is used as an offset from the end of the value of <I>parameter</I>.
3523 If <I>length</I> evaluates to a number less than zero, and <I>parameter</I>
3524 is not <B>@</B> and not an indexed or associative array, it is interpreted
3525 as an offset from the end of the value of <I>parameter</I> rather than
3526 a number of characters, and the expansion is the characters between the
3527 two offsets.
3528 If <I>parameter</I> is <B>@</B>, the result is <I>length</I> positional
3529 parameters beginning at <I>offset</I>.
3530 If <I>parameter</I> is an indexed array name subscripted by @ or *,
3531 the result is the <I>length</I>
3532 members of the array beginning with ${<I>parameter</I>[<I>offset</I>]}.
3533 A negative <I>offset</I> is taken relative to one greater than the maximum
3534 index of the specified array.
3535 Substring expansion applied to an associative array produces undefined
3536 results.
3537 Note that a negative offset must be separated from the colon by at least
3538 one space to avoid being confused with the :- expansion.
3539 Substring indexing is zero-based unless the positional parameters
3540 are used, in which case the indexing starts at 1 by default.
3541 If <I>offset</I> is 0, and the positional parameters are used, <B>$0</B> is
3542 prefixed to the list.
3543 <DT>${<B>!</B><I>prefix</I><B>*</B>}<DD>
3544
3545 <DT>${<B>!</B><I>prefix</I><B>@</B>}<DD>
3546
3547 <B>Names matching prefix</B>.
3548 Expands to the names of variables whose names begin with <I>prefix</I>,
3549 separated by the first character of the
3550 <FONT SIZE=-1><B>IFS</B>
3551
3552 </FONT>
3553 special variable.
3554 When <I>@</I> is used and the expansion appears within double quotes, each
3555 variable name expands to a separate word.
3556 <DT>${<B>!</B><I>name</I>[<I>@</I>]}<DD>
3557
3558 <DT>${<B>!</B><I>name</I>[<I>*</I>]}<DD>
3559
3560 <B>List of array keys</B>.
3561 If <I>name</I> is an array variable, expands to the list of array indices
3562 (keys) assigned in <I>name</I>.
3563 If <I>name</I> is not an array, expands to 0 if <I>name</I> is set and null
3564 otherwise.
3565 When <I>@</I> is used and the expansion appears within double quotes, each
3566 key expands to a separate word.
3567 <DT>${<B>#</B><I>parameter</I>}<DD>
3568 <B>Parameter length</B>.
3569 The length in characters of the value of <I>parameter</I> is substituted.
3570 If
3571 <I>parameter</I>
3572
3573 is
3574 <B>*</B>
3575
3576 or
3577 <B>@</B>,
3578
3579 the value substituted is the number of positional parameters.
3580 If
3581 <I>parameter</I>
3582
3583 is an array name subscripted by
3584 <B>*</B>
3585
3586 or
3587 <B>@</B>,
3588
3589 the value substituted is the number of elements in the array.
3590 <DT>${<I>parameter</I><B>#</B><I>word</I>}<DD>
3591
3592 <DT>${<I>parameter</I><B>##</B><I>word</I>}<DD>
3593
3594 <B>Remove matching prefix pattern</B>.
3595 The
3596 <I>word</I>
3597
3598 is expanded to produce a pattern just as in pathname
3599 expansion. If the pattern matches the beginning of
3600 the value of
3601 <I>parameter</I>,
3602
3603 then the result of the expansion is the expanded value of
3604 <I>parameter</I>
3605
3606 with the shortest matching pattern (the ``<B>#</B>'' case) or the
3607 longest matching pattern (the ``<B>##</B>'' case) deleted.
3608 If
3609 <I>parameter</I>
3610
3611 is
3612 <B>@</B>
3613
3614 or
3615 <B>*</B>,
3616
3617 the pattern removal operation is applied to each positional
3618 parameter in turn, and the expansion is the resultant list.
3619 If
3620 <I>parameter</I>
3621
3622 is an array variable subscripted with
3623 <B>@</B>
3624
3625 or
3626 <B>*</B>,
3627
3628 the pattern removal operation is applied to each member of the
3629 array in turn, and the expansion is the resultant list.
3630 <DT>${<I>parameter</I><B>%</B><I>word</I>}<DD>
3631
3632 <DT>${<I>parameter</I><B>%%</B><I>word</I>}<DD>
3633
3634 <B>Remove matching suffix pattern</B>.
3635 The <I>word</I> is expanded to produce a pattern just as in
3636 pathname expansion.
3637 If the pattern matches a trailing portion of the expanded value of
3638 <I>parameter</I>,
3639
3640 then the result of the expansion is the expanded value of
3641 <I>parameter</I>
3642
3643 with the shortest matching pattern (the ``<B>%</B>'' case) or the
3644 longest matching pattern (the ``<B>%%</B>'' case) deleted.
3645 If
3646 <I>parameter</I>
3647
3648 is
3649 <B>@</B>
3650
3651 or
3652 <B>*</B>,
3653
3654 the pattern removal operation is applied to each positional
3655 parameter in turn, and the expansion is the resultant list.
3656 If
3657 <I>parameter</I>
3658
3659 is an array variable subscripted with
3660 <B>@</B>
3661
3662 or
3663 <B>*</B>,
3664
3665 the pattern removal operation is applied to each member of the
3666 array in turn, and the expansion is the resultant list.
3667 <DT>${<I>parameter</I><B>/</B><I>pattern</I><B>/</B><I>string</I>}<DD>
3668 <B>Pattern substitution</B>.
3669 The <I>pattern</I> is expanded to produce a pattern just as in
3670 pathname expansion.
3671 <I>Parameter</I> is expanded and the longest match of <I>pattern</I>
3672 against its value is replaced with <I>string</I>.
3673 If <I>pattern</I> begins with <B>/</B>, all matches of <I>pattern</I> are
3674 replaced with <I>string</I>. Normally only the first match is replaced.
3675 If <I>pattern</I> begins with <B>#</B>, it must match at the beginning
3676 of the expanded value of <I>parameter</I>.
3677 If <I>pattern</I> begins with <B>%</B>, it must match at the end
3678 of the expanded value of <I>parameter</I>.
3679 If <I>string</I> is null, matches of <I>pattern</I> are deleted
3680 and the <B>/</B> following <I>pattern</I> may be omitted.
3681 If
3682 <I>parameter</I>
3683
3684 is
3685 <B>@</B>
3686
3687 or
3688 <B>*</B>,
3689
3690 the substitution operation is applied to each positional
3691 parameter in turn, and the expansion is the resultant list.
3692 If
3693 <I>parameter</I>
3694
3695 is an array variable subscripted with
3696 <B>@</B>
3697
3698 or
3699 <B>*</B>,
3700
3701 the substitution operation is applied to each member of the
3702 array in turn, and the expansion is the resultant list.
3703 <DT>${<I>parameter</I><B>^</B><I>pattern</I>}<DD>
3704
3705 <DT>${<I>parameter</I><B>^^</B><I>pattern</I>}<DD>
3706 <DT>${<I>parameter</I><B>,</B><I>pattern</I>}<DD>
3707 <DT>${<I>parameter</I><B>,,</B><I>pattern</I>}<DD>
3708
3709 <B>Case modification</B>.
3710 This expansion modifies the case of alphabetic characters in <I>parameter</I>.
3711 The <I>pattern</I> is expanded to produce a pattern just as in
3712 pathname expansion.
3713 The <B>^</B> operator converts lowercase letters matching <I>pattern</I>
3714 to uppercase; the <B>,</B> operator converts matching uppercase letters
3715 to lowercase.
3716 The <B>^^</B> and <B>,,</B> expansions convert each matched character in the
3717 expanded value; the <B>^</B> and <B>,</B> expansions match and convert only
3718 the first character in the expanded value.
3719 If <I>pattern</I> is omitted, it is treated like a <B>?</B>, which matches
3720 every character.
3721 If
3722 <I>parameter</I>
3723
3724 is
3725 <B>@</B>
3726
3727 or
3728 <B>*</B>,
3729
3730 the case modification operation is applied to each positional
3731 parameter in turn, and the expansion is the resultant list.
3732 If
3733 <I>parameter</I>
3734
3735 is an array variable subscripted with
3736 <B>@</B>
3737
3738 or
3739 <B>*</B>,
3740
3741 the case modification operation is applied to each member of the
3742 array in turn, and the expansion is the resultant list.
3743 </DL>
3744 <A NAME="lbBC">&nbsp;</A>
3745 <H4>Command Substitution</H4>
3746
3747 <P>
3748
3749 <I>Command substitution</I> allows the output of a command to replace
3750 the command name. There are two forms:
3751 <P>
3752
3753 <DL COMPACT><DT><DD>
3754 <P>
3755
3756 <B>$(</B><I>command</I><B>)</B>
3757 </DL>
3758
3759 or
3760 <DL COMPACT><DT><DD>
3761 <B>`</B><I>command</I><B>`</B>
3762 </DL>
3763
3764 <P>
3765
3766 <B>Bash</B>
3767
3768 performs the expansion by executing <I>command</I> and
3769 replacing the command substitution with the standard output of the
3770 command, with any trailing newlines deleted.
3771 Embedded newlines are not deleted, but they may be removed during
3772 word splitting.
3773 The command substitution <B>$(cat </B><I>file</I>) can be replaced by
3774 the equivalent but faster <B>$(&lt; </B><I>file</I>).
3775 <P>
3776
3777 When the old-style backquote form of substitution is used,
3778 backslash retains its literal meaning except when followed by
3779 <B>$</B>,
3780
3781 <B>`</B>,
3782
3783 or
3784 <B>\</B>.
3785
3786 The first backquote not preceded by a backslash terminates the
3787 command substitution.
3788 When using the $(<I>command</I>) form, all characters between the
3789 parentheses make up the command; none are treated specially.
3790 <P>
3791
3792 Command substitutions may be nested. To nest when using the backquoted form,
3793 escape the inner backquotes with backslashes.
3794 <P>
3795
3796 If the substitution appears within double quotes, word splitting and
3797 pathname expansion are not performed on the results.
3798 <A NAME="lbBD">&nbsp;</A>
3799 <H4>Arithmetic Expansion</H4>
3800
3801 <P>
3802
3803 Arithmetic expansion allows the evaluation of an arithmetic expression
3804 and the substitution of the result. The format for arithmetic expansion is:
3805 <DL COMPACT><DT><DD>
3806 <P>
3807
3808 <B>$((</B><I>expression</I><B>))</B>
3809 </DL>
3810
3811 <P>
3812
3813 The
3814 <I>expression</I>
3815
3816 is treated as if it were within double quotes, but a double quote
3817 inside the parentheses is not treated specially.
3818 All tokens in the expression undergo parameter expansion, string
3819 expansion, command substitution, and quote removal.
3820 Arithmetic expansions may be nested.
3821 <P>
3822
3823 The evaluation is performed according to the rules listed below under
3824 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
3825
3826 </FONT>
3827 If
3828 <I>expression</I>
3829
3830 is invalid,
3831 <B>bash</B>
3832
3833 prints a message indicating failure and no substitution occurs.
3834 <A NAME="lbBE">&nbsp;</A>
3835 <H4>Process Substitution</H4>
3836
3837 <P>
3838
3839 <I>Process substitution</I> is supported on systems that support named
3840 pipes (<I>FIFOs</I>) or the <B>/dev/fd</B> method of naming open files.
3841 It takes the form of
3842 <B>&lt;(</B><I>list</I><B>)</B>
3843 or
3844 <B>&gt;(</B><I>list</I><B>)</B>.
3845 The process <I>list</I> is run with its input or output connected to a
3846 <I>FIFO</I> or some file in <B>/dev/fd</B>. The name of this file is
3847 passed as an argument to the current command as the result of the
3848 expansion. If the <B>&gt;(</B><I>list</I><B>)</B> form is used, writing to
3849 the file will provide input for <I>list</I>. If the
3850 <B>&lt;(</B><I>list</I><B>)</B> form is used, the file passed as an
3851 argument should be read to obtain the output of <I>list</I>.
3852 <P>
3853
3854 When available, process substitution is performed
3855 simultaneously with parameter and variable expansion,
3856 command substitution,
3857 and arithmetic expansion.
3858 <A NAME="lbBF">&nbsp;</A>
3859 <H4>Word Splitting</H4>
3860
3861 <P>
3862
3863 The shell scans the results of
3864 parameter expansion,
3865 command substitution,
3866 and
3867 arithmetic expansion
3868 that did not occur within double quotes for
3869 <I>word splitting</I>.
3870
3871 <P>
3872
3873 The shell treats each character of
3874 <FONT SIZE=-1><B>IFS</B>
3875
3876 </FONT>
3877 as a delimiter, and splits the results of the other
3878 expansions into words on these characters. If
3879 <FONT SIZE=-1><B>IFS</B>
3880
3881 </FONT>
3882 is unset, or its
3883 value is exactly
3884 <B>&lt;space&gt;&lt;tab&gt;&lt;newline&gt;</B>,
3885
3886 the default, then
3887 sequences of
3888 <B>&lt;space&gt;</B>,
3889
3890 <B>&lt;tab&gt;</B>,
3891
3892 and
3893 <B>&lt;newline&gt;</B>
3894
3895 at the beginning and end of the results of the previous
3896 expansions are ignored, and
3897 any sequence of
3898 <FONT SIZE=-1><B>IFS</B>
3899
3900 </FONT>
3901 characters not at the beginning or end serves to delimit words.
3902 If
3903 <FONT SIZE=-1><B>IFS</B>
3904
3905 </FONT>
3906 has a value other than the default, then sequences of
3907 the whitespace characters
3908 <B>space</B>
3909
3910 and
3911 <B>tab</B>
3912
3913 are ignored at the beginning and end of the
3914 word, as long as the whitespace character is in the
3915 value of
3916 <FONT SIZE=-1><B>IFS</B>
3917
3918 </FONT>
3919 (an
3920 <FONT SIZE=-1><B>IFS</B>
3921
3922 </FONT>
3923 whitespace character).
3924 Any character in
3925 <FONT SIZE=-1><B>IFS</B>
3926
3927 </FONT>
3928 that is not
3929 <FONT SIZE=-1><B>IFS</B>
3930
3931 </FONT>
3932 whitespace, along with any adjacent
3933 <FONT SIZE=-1><B>IFS</B>
3934
3935 </FONT>
3936 whitespace characters, delimits a field.
3937 A sequence of
3938 <FONT SIZE=-1><B>IFS</B>
3939
3940 </FONT>
3941 whitespace characters is also treated as a delimiter.
3942 If the value of
3943 <FONT SIZE=-1><B>IFS</B>
3944
3945 </FONT>
3946 is null, no word splitting occurs.
3947 <P>
3948
3949 Explicit null arguments (<B>&quot;&quot;</B> or <B>aqaq</B>) are retained.
3950 Unquoted implicit null arguments, resulting from the expansion of
3951 parameters that have no values, are removed.
3952 If a parameter with no value is expanded within double quotes, a
3953 null argument results and is retained.
3954 <P>
3955
3956 Note that if no expansion occurs, no splitting
3957 is performed.
3958 <A NAME="lbBG">&nbsp;</A>
3959 <H4>Pathname Expansion</H4>
3960
3961 <P>
3962
3963 After word splitting,
3964 unless the
3965 <B>-f</B>
3966
3967 option has been set,
3968 <B>bash</B>
3969
3970 scans each word for the characters
3971 <B>*</B>,
3972
3973 <B>?</B>,
3974
3975 and
3976 <B>[</B>.
3977
3978 If one of these characters appears, then the word is
3979 regarded as a
3980 <I>pattern</I>,
3981
3982 and replaced with an alphabetically sorted list of
3983 file names matching the pattern.
3984 If no matching file names are found,
3985 and the shell option
3986 <B>nullglob</B>
3987
3988 is not enabled, the word is left unchanged.
3989 If the
3990 <B>nullglob</B>
3991
3992 option is set, and no matches are found,
3993 the word is removed.
3994 If the
3995 <B>failglob</B>
3996
3997 shell option is set, and no matches are found, an error message
3998 is printed and the command is not executed.
3999 If the shell option
4000 <B>nocaseglob</B>
4001
4002 is enabled, the match is performed without regard to the case
4003 of alphabetic characters.
4004 When a pattern is used for pathname expansion,
4005 the character
4006 <B>``.''</B>
4007
4008 at the start of a name or immediately following a slash
4009 must be matched explicitly, unless the shell option
4010 <B>dotglob</B>
4011
4012 is set.
4013 When matching a pathname, the slash character must always be
4014 matched explicitly.
4015 In other cases, the
4016 <B>``.''</B>
4017
4018 character is not treated specially.
4019 See the description of
4020 <B>shopt</B>
4021
4022 below under
4023 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
4024
4025 </FONT>
4026 for a description of the
4027 <B>nocaseglob</B>,
4028
4029 <B>nullglob</B>,
4030
4031 <B>failglob</B>,
4032
4033 and
4034 <B>dotglob</B>
4035
4036 shell options.
4037 <P>
4038
4039 The
4040 <FONT SIZE=-1><B>GLOBIGNORE</B>
4041
4042 </FONT>
4043 shell variable may be used to restrict the set of file names matching a
4044 <I>pattern</I>.
4045
4046 If
4047 <FONT SIZE=-1><B>GLOBIGNORE</B>
4048
4049 </FONT>
4050 is set, each matching file name that also matches one of the patterns in
4051 <FONT SIZE=-1><B>GLOBIGNORE</B>
4052
4053 </FONT>
4054 is removed from the list of matches.
4055 The file names
4056 <B>``.''</B>
4057
4058 and
4059 <B>``..''</B>
4060
4061 are always ignored when
4062 <FONT SIZE=-1><B>GLOBIGNORE</B>
4063
4064 </FONT>
4065 is set and not null. However, setting
4066 <FONT SIZE=-1><B>GLOBIGNORE</B>
4067
4068 </FONT>
4069 to a non-null value has the effect of enabling the
4070 <B>dotglob</B>
4071
4072 shell option, so all other file names beginning with a
4073 <B>``.''</B>
4074
4075 will match.
4076 To get the old behavior of ignoring file names beginning with a
4077 <B>``.''</B>,
4078
4079 make
4080 <B>``.*''</B>
4081
4082 one of the patterns in
4083 <FONT SIZE=-1><B>GLOBIGNORE</B>.
4084
4085 </FONT>
4086 The
4087 <B>dotglob</B>
4088
4089 option is disabled when
4090 <FONT SIZE=-1><B>GLOBIGNORE</B>
4091
4092 </FONT>
4093 is unset.
4094 <P>
4095
4096 <B>Pattern Matching</B>
4097 <P>
4098
4099 Any character that appears in a pattern, other than the special pattern
4100 characters described below, matches itself. The NUL character may not
4101 occur in a pattern. A backslash escapes the following character; the
4102 escaping backslash is discarded when matching.
4103 The special pattern characters must be quoted if
4104 they are to be matched literally.
4105 <P>
4106
4107 The special pattern characters have the following meanings:
4108 <P>
4109
4110
4111 <DL COMPACT>
4112 <DT><B>*</B>
4113
4114 <DD>
4115 Matches any string, including the null string.
4116 When the <B>globstar</B> shell option is enabled, and <B>*</B> is used in
4117 a pathname expansion context, two adjacent <B>*</B>s used as a single
4118 pattern will match all files and zero or more directories and
4119 subdirectories.
4120 If followed by a <B>/</B>, two adjacent <B>*</B>s will match only directories
4121 and subdirectories.
4122 <DT><B>?</B>
4123
4124 <DD>
4125 Matches any single character.
4126 <DT><B>[...]</B>
4127
4128 <DD>
4129 Matches any one of the enclosed characters. A pair of characters
4130 separated by a hyphen denotes a
4131 <I>range expression</I>;
4132 any character that sorts between those two characters, inclusive,
4133 using the current locale's collating sequence and character set,
4134 is matched. If the first character following the
4135 <B>[</B>
4136
4137 is a
4138 <B>!</B>
4139
4140 or a
4141 <B>^</B>
4142
4143 then any character not enclosed is matched.
4144 The sorting order of characters in range expressions is determined by
4145 the current locale and the value of the
4146 <FONT SIZE=-1><B>LC_COLLATE</B>
4147
4148 </FONT>
4149 shell variable,
4150 if set.
4151 A
4152 <B>-</B>
4153
4154 may be matched by including it as the first or last character
4155 in the set.
4156 A
4157 <B>]</B>
4158
4159 may be matched by including it as the first character
4160 in the set.
4161 <BR>
4162
4163 <P>
4164
4165
4166 Within
4167 <B>[</B>
4168
4169 and
4170 <B>]</B>,
4171
4172 <I>character classes</I> can be specified using the syntax
4173 <B>[:</B><I>class</I><B>:]</B>, where <I>class</I> is one of the
4174 following classes defined in the POSIX standard:
4175 </DL>
4176 <P>
4177
4178 <DL COMPACT><DT><DD>
4179 <B>
4180 </B>
4181
4182 alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
4183 <BR>
4184
4185 A character class matches any character belonging to that class.
4186 The <B>word</B> character class matches letters, digits, and the character _.
4187 <BR>
4188
4189 <P>
4190
4191
4192 Within
4193 <B>[</B>
4194
4195 and
4196 <B>]</B>,
4197
4198 an <I>equivalence class</I> can be specified using the syntax
4199 <B>[=</B><I>c</I><B>=]</B>, which matches all characters with the
4200 same collation weight (as defined by the current locale) as
4201 the character <I>c</I>.
4202 <BR>
4203
4204 <P>
4205
4206
4207 Within
4208 <B>[</B>
4209
4210 and
4211 <B>]</B>,
4212
4213 the syntax <B>[.</B><I>symbol</I><B>.]</B> matches the collating symbol
4214 <I>symbol</I>.
4215 </DL>
4216
4217
4218 <P>
4219
4220 If the <B>extglob</B> shell option is enabled using the <B>shopt</B>
4221 builtin, several extended pattern matching operators are recognized.
4222 In the following description, a <I>pattern-list</I> is a list of one
4223 or more patterns separated by a <B>|</B>.
4224 Composite patterns may be formed using one or more of the following
4225 sub-patterns:
4226 <P>
4227
4228 <DL COMPACT><DT><DD>
4229 <DL COMPACT>
4230 <DT><B>?(</B><I>pattern-list</I><B>)</B><DD>
4231 Matches zero or one occurrence of the given patterns
4232 <DT><B>*(</B><I>pattern-list</I><B>)</B><DD>
4233 Matches zero or more occurrences of the given patterns
4234 <DT><B>+(</B><I>pattern-list</I><B>)</B><DD>
4235 Matches one or more occurrences of the given patterns
4236 <DT><B>@(</B><I>pattern-list</I><B>)</B><DD>
4237 Matches one of the given patterns
4238 <DT><B>!(</B><I>pattern-list</I><B>)</B><DD>
4239 Matches anything except one of the given patterns
4240 </DL></DL>
4241
4242
4243 <A NAME="lbBH">&nbsp;</A>
4244 <H4>Quote Removal</H4>
4245
4246 <P>
4247
4248 After the preceding expansions, all unquoted occurrences of the
4249 characters
4250 <B>\</B>,
4251
4252 <B>aq</B>,
4253
4254 and <B>&quot;</B> that did not result from one of the above
4255 expansions are removed.
4256 <A NAME="lbBI">&nbsp;</A>
4257 <H3>REDIRECTION</H3>
4258
4259 Before a command is executed, its input and output
4260 may be
4261 <I>redirected</I>
4262
4263 using a special notation interpreted by the shell.
4264 Redirection may also be used to open and close files for the
4265 current shell execution environment. The following redirection
4266 operators may precede or appear anywhere within a
4267 <I>simple command</I>
4268
4269 or may follow a
4270 <I>command</I>.
4271
4272 Redirections are processed in the order they appear, from
4273 left to right.
4274 <P>
4275
4276 Each redirection that may be preceded by a file descriptor number
4277 may instead be preceded by a word of the form {<I>varname</I>}.
4278 In this case, for each redirection operator except
4279 &gt;&amp;- and &lt;&amp;-, the shell will allocate a file descriptor greater
4280 than 10 and assign it to <I>varname</I>. If &gt;&amp;- or &lt;&amp;- is preceded
4281 by {<I>varname</I>}, the value of <I>varname</I> defines the file
4282 descriptor to close.
4283 <P>
4284
4285 In the following descriptions, if the file descriptor number is
4286 omitted, and the first character of the redirection operator is
4287 <B>&lt;</B>,
4288
4289 the redirection refers to the standard input (file descriptor
4290 0). If the first character of the redirection operator is
4291 <B>&gt;</B>,
4292
4293 the redirection refers to the standard output (file descriptor
4294 1).
4295 <P>
4296
4297 The word following the redirection operator in the following
4298 descriptions, unless otherwise noted, is subjected to brace expansion,
4299 tilde expansion, parameter expansion, command substitution, arithmetic
4300 expansion, quote removal, pathname expansion, and word splitting.
4301 If it expands to more than one word,
4302 <B>bash</B>
4303
4304 reports an error.
4305 <P>
4306
4307 Note that the order of redirections is significant. For example,
4308 the command
4309 <DL COMPACT><DT><DD>
4310 <P>
4311
4312 ls <B>&gt;</B> dirlist 2<B>&gt;&amp;</B>1
4313 </DL>
4314
4315 <P>
4316
4317 directs both standard output and standard error to the file
4318 <I>dirlist</I>,
4319
4320 while the command
4321 <DL COMPACT><DT><DD>
4322 <P>
4323
4324 ls 2<B>&gt;&amp;</B>1 <B>&gt;</B> dirlist
4325 </DL>
4326
4327 <P>
4328
4329 directs only the standard output to file
4330 <I>dirlist</I>,
4331
4332 because the standard error was duplicated from the standard output
4333 before the standard output was redirected to
4334 <I>dirlist</I>.
4335
4336 <P>
4337
4338 <B>Bash</B> handles several filenames specially when they are used in
4339 redirections, as described in the following table:
4340 <DL COMPACT><DT><DD>
4341 <P>
4342
4343
4344 <DL COMPACT>
4345 <DT><B>/dev/fd/</B><I>fd</I>
4346
4347 <DD>
4348 If <I>fd</I> is a valid integer, file descriptor <I>fd</I> is duplicated.
4349 <DT><B>/dev/stdin</B>
4350
4351 <DD>
4352 File descriptor 0 is duplicated.
4353 <DT><B>/dev/stdout</B>
4354
4355 <DD>
4356 File descriptor 1 is duplicated.
4357 <DT><B>/dev/stderr</B>
4358
4359 <DD>
4360 File descriptor 2 is duplicated.
4361 <DT><B>/dev/tcp/</B><I>host</I>/<I>port</I>
4362
4363 <DD>
4364 If <I>host</I> is a valid hostname or Internet address, and <I>port</I>
4365 is an integer port number or service name, <B>bash</B> attempts to open
4366 a TCP connection to the corresponding socket.
4367 <DT><B>/dev/udp/</B><I>host</I>/<I>port</I>
4368
4369 <DD>
4370 If <I>host</I> is a valid hostname or Internet address, and <I>port</I>
4371 is an integer port number or service name, <B>bash</B> attempts to open
4372 a UDP connection to the corresponding socket.
4373
4374 </DL></DL>
4375
4376 <P>
4377
4378 A failure to open or create a file causes the redirection to fail.
4379 <P>
4380
4381 Redirections using file descriptors greater than 9 should be used with
4382 care, as they may conflict with file descriptors the shell uses
4383 internally.
4384 <A NAME="lbBJ">&nbsp;</A>
4385 <H4>Redirecting Input</H4>
4386
4387 <P>
4388
4389 Redirection of input causes the file whose name results from
4390 the expansion of
4391 <I>word</I>
4392
4393 to be opened for reading on file descriptor
4394 <I>n</I>,
4395
4396 or the standard input (file descriptor 0) if
4397 <I>n</I>
4398
4399 is not specified.
4400 <P>
4401
4402 The general format for redirecting input is:
4403 <DL COMPACT><DT><DD>
4404 <P>
4405
4406 [<I>n</I>]<B>&lt;</B><I>word</I>
4407 </DL>
4408
4409 <A NAME="lbBK">&nbsp;</A>
4410 <H4>Redirecting Output</H4>
4411
4412 <P>
4413
4414 Redirection of output causes the file whose name results from
4415 the expansion of
4416 <I>word</I>
4417
4418 to be opened for writing on file descriptor
4419 <I>n</I>,
4420
4421 or the standard output (file descriptor 1) if
4422 <I>n</I>
4423
4424 is not specified. If the file does not exist it is created;
4425 if it does exist it is truncated to zero size.
4426 <P>
4427
4428 The general format for redirecting output is:
4429 <DL COMPACT><DT><DD>
4430 <P>
4431
4432 [<I>n</I>]<B>&gt;</B><I>word</I>
4433 </DL>
4434
4435 <P>
4436
4437 If the redirection operator is
4438 <B>&gt;</B>,
4439
4440 and the
4441 <B>noclobber</B>
4442
4443 option to the
4444 <B>set</B>
4445
4446 builtin has been enabled, the redirection will fail if the file
4447 whose name results from the expansion of <I>word</I> exists and is
4448 a regular file.
4449 If the redirection operator is
4450 <B>&gt;|</B>,
4451
4452 or the redirection operator is
4453 <B>&gt;</B>
4454
4455 and the
4456 <B>noclobber</B>
4457
4458 option to the
4459 <B>set</B>
4460
4461 builtin command is not enabled, the redirection is attempted even
4462 if the file named by <I>word</I> exists.
4463 <A NAME="lbBL">&nbsp;</A>
4464 <H4>Appending Redirected Output</H4>
4465
4466 <P>
4467
4468 Redirection of output in this fashion
4469 causes the file whose name results from
4470 the expansion of
4471 <I>word</I>
4472
4473 to be opened for appending on file descriptor
4474 <I>n</I>,
4475
4476 or the standard output (file descriptor 1) if
4477 <I>n</I>
4478
4479 is not specified. If the file does not exist it is created.
4480 <P>
4481
4482 The general format for appending output is:
4483 <DL COMPACT><DT><DD>
4484 <P>
4485
4486 [<I>n</I>]<B>&gt;&gt;</B><I>word</I>
4487 </DL>
4488
4489 <P>
4490
4491 <A NAME="lbBM">&nbsp;</A>
4492 <H4>Redirecting Standard Output and Standard Error</H4>
4493
4494 <P>
4495
4496 This construct allows both the
4497 standard output (file descriptor 1) and
4498 the standard error output (file descriptor 2)
4499 to be redirected to the file whose name is the
4500 expansion of
4501 <I>word</I>.
4502
4503 <P>
4504
4505 There are two formats for redirecting standard output and
4506 standard error:
4507 <DL COMPACT><DT><DD>
4508 <P>
4509
4510 <B>&amp;&gt;</B><I>word</I>
4511 </DL>
4512
4513 and
4514 <DL COMPACT><DT><DD>
4515 <B>&gt;&amp;</B><I>word</I>
4516 </DL>
4517
4518 <P>
4519
4520 Of the two forms, the first is preferred.
4521 This is semantically equivalent to
4522 <DL COMPACT><DT><DD>
4523 <P>
4524
4525 <B>&gt;</B><I>word</I> 2<B>&gt;&amp;</B>1
4526 </DL>
4527
4528 <P>
4529
4530 <A NAME="lbBN">&nbsp;</A>
4531 <H4>Appending Standard Output and Standard Error</H4>
4532
4533 <P>
4534
4535 This construct allows both the
4536 standard output (file descriptor 1) and
4537 the standard error output (file descriptor 2)
4538 to be appended to the file whose name is the
4539 expansion of
4540 <I>word</I>.
4541
4542 <P>
4543
4544 The format for appending standard output and standard error is:
4545 <DL COMPACT><DT><DD>
4546 <P>
4547
4548 <B>&amp;&gt;&gt;</B><I>word</I>
4549 </DL>
4550
4551 <P>
4552
4553 This is semantically equivalent to
4554 <DL COMPACT><DT><DD>
4555 <P>
4556
4557 <B>&gt;&gt;</B><I>word</I> 2<B>&gt;&amp;</B>1
4558 </DL>
4559
4560 <A NAME="lbBO">&nbsp;</A>
4561 <H4>Here Documents</H4>
4562
4563 <P>
4564
4565 This type of redirection instructs the shell to read input from the
4566 current source until a line containing only
4567 <I>delimiter</I>
4568
4569 (with no trailing blanks)
4570 is seen. All of
4571 the lines read up to that point are then used as the standard
4572 input for a command.
4573 <P>
4574
4575 The format of here-documents is:
4576 <DL COMPACT><DT><DD>
4577 <P>
4578
4579 <PRE>
4580 <B>&lt;&lt;</B>[<B>-</B>]<I>word</I>
4581 <I>here-document</I>
4582 <I>delimiter</I>
4583 </PRE>
4584
4585 </DL>
4586
4587 <P>
4588
4589 No parameter expansion, command substitution, arithmetic expansion,
4590 or pathname expansion is performed on
4591 <I>word</I>.
4592
4593 If any characters in
4594 <I>word</I>
4595
4596 are quoted, the
4597 <I>delimiter</I>
4598
4599 is the result of quote removal on
4600 <I>word</I>,
4601
4602 and the lines in the here-document are not expanded.
4603 If <I>word</I> is unquoted,
4604 all lines of the here-document are subjected to parameter expansion,
4605 command substitution, and arithmetic expansion. In the latter
4606 case, the character sequence
4607 <B>\&lt;newline&gt;</B>
4608
4609 is ignored, and
4610 <B>\</B>
4611
4612 must be used to quote the characters
4613 <B>\</B>,
4614
4615 <B>$</B>,
4616
4617 and
4618 <B>`</B>.
4619
4620 <P>
4621
4622 If the redirection operator is
4623 <B>&lt;&lt;-</B>,
4624
4625 then all leading tab characters are stripped from input lines and the
4626 line containing
4627 <I>delimiter</I>.
4628
4629 This allows
4630 here-documents within shell scripts to be indented in a
4631 natural fashion.
4632 <A NAME="lbBP">&nbsp;</A>
4633 <H4>Here Strings</H4>
4634
4635 A variant of here documents, the format is:
4636 <DL COMPACT><DT><DD>
4637 <P>
4638
4639 <PRE>
4640 <B>&lt;&lt;&lt;</B><I>word</I>
4641 </PRE>
4642
4643 </DL>
4644
4645 <P>
4646
4647 The <I>word</I> is expanded and supplied to the command on its standard
4648 input.
4649 <A NAME="lbBQ">&nbsp;</A>
4650 <H4>Duplicating File Descriptors</H4>
4651
4652 <P>
4653
4654 The redirection operator
4655 <DL COMPACT><DT><DD>
4656 <P>
4657
4658 [<I>n</I>]<B>&lt;&amp;</B><I>word</I>
4659 </DL>
4660
4661 <P>
4662
4663 is used to duplicate input file descriptors.
4664 If
4665 <I>word</I>
4666
4667 expands to one or more digits, the file descriptor denoted by
4668 <I>n</I>
4669
4670 is made to be a copy of that file descriptor.
4671 If the digits in
4672 <I>word</I>
4673
4674 do not specify a file descriptor open for input, a redirection error occurs.
4675 If
4676 <I>word</I>
4677
4678 evaluates to
4679 <B>-</B>,
4680
4681 file descriptor
4682 <I>n</I>
4683
4684 is closed. If
4685 <I>n</I>
4686
4687 is not specified, the standard input (file descriptor 0) is used.
4688 <P>
4689
4690 The operator
4691 <DL COMPACT><DT><DD>
4692 <P>
4693
4694 [<I>n</I>]<B>&gt;&amp;</B><I>word</I>
4695 </DL>
4696
4697 <P>
4698
4699 is used similarly to duplicate output file descriptors. If
4700 <I>n</I>
4701
4702 is not specified, the standard output (file descriptor 1) is used.
4703 If the digits in
4704 <I>word</I>
4705
4706 do not specify a file descriptor open for output, a redirection error occurs.
4707 As a special case, if <I>n</I> is omitted, and <I>word</I> does not
4708 expand to one or more digits, the standard output and standard
4709 error are redirected as described previously.
4710 <A NAME="lbBR">&nbsp;</A>
4711 <H4>Moving File Descriptors</H4>
4712
4713 <P>
4714
4715 The redirection operator
4716 <DL COMPACT><DT><DD>
4717 <P>
4718
4719 [<I>n</I>]<B>&lt;&amp;</B><I>digit</I><B>-</B>
4720 </DL>
4721
4722 <P>
4723
4724 moves the file descriptor <I>digit</I> to file descriptor
4725 <I>n</I>,
4726
4727 or the standard input (file descriptor 0) if <I>n</I> is not specified.
4728 <I>digit</I> is closed after being duplicated to <I>n</I>.
4729 <P>
4730
4731 Similarly, the redirection operator
4732 <DL COMPACT><DT><DD>
4733 <P>
4734
4735 [<I>n</I>]<B>&gt;&amp;</B><I>digit</I><B>-</B>
4736 </DL>
4737
4738 <P>
4739
4740 moves the file descriptor <I>digit</I> to file descriptor
4741 <I>n</I>,
4742
4743 or the standard output (file descriptor 1) if <I>n</I> is not specified.
4744 <A NAME="lbBS">&nbsp;</A>
4745 <H4>Opening File Descriptors for Reading and Writing</H4>
4746
4747 <P>
4748
4749 The redirection operator
4750 <DL COMPACT><DT><DD>
4751 <P>
4752
4753 [<I>n</I>]<B>&lt;&gt;</B><I>word</I>
4754 </DL>
4755
4756 <P>
4757
4758 causes the file whose name is the expansion of
4759 <I>word</I>
4760
4761 to be opened for both reading and writing on file descriptor
4762 <I>n</I>,
4763
4764 or on file descriptor 0 if
4765 <I>n</I>
4766
4767 is not specified. If the file does not exist, it is created.
4768 <A NAME="lbBT">&nbsp;</A>
4769 <H3>ALIASES</H3>
4770
4771 <I>Aliases</I> allow a string to be substituted for a word when it is used
4772 as the first word of a simple command.
4773 The shell maintains a list of aliases that may be set and unset with the
4774 <B>alias</B>
4775
4776 and
4777 <B>unalias</B>
4778
4779 builtin commands (see
4780 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
4781
4782 </FONT>
4783 below).
4784 The first word of each simple command, if unquoted,
4785 is checked to see if it has an
4786 alias. If so, that word is replaced by the text of the alias.
4787 The characters <B>/</B>, <B>$</B>, <B>`</B>, and <B>=</B> and
4788 any of the shell <I>metacharacters</I> or quoting characters
4789 listed above may not appear in an alias name.
4790 The replacement text may contain any valid shell input,
4791 including shell metacharacters.
4792 The first word of the replacement text is tested
4793 for aliases, but a word that is identical to an alias being expanded
4794 is not expanded a second time.
4795 This means that one may alias
4796 <B>ls</B>
4797
4798 to
4799 <B>ls -F</B>,
4800
4801 for instance, and
4802 <B>bash</B>
4803
4804 does not try to recursively expand the replacement text.
4805 If the last character of the alias value is a
4806 <I>blank</I>,
4807
4808 then the next command
4809 word following the alias is also checked for alias expansion.
4810 <P>
4811
4812 Aliases are created and listed with the
4813 <B>alias</B>
4814
4815 command, and removed with the
4816 <B>unalias</B>
4817
4818 command.
4819 <P>
4820
4821 There is no mechanism for using arguments in the replacement text.
4822 If arguments are needed, a shell function should be used (see
4823 <FONT SIZE=-1><B>FUNCTIONS</B>
4824
4825 </FONT>
4826 below).
4827 <P>
4828
4829 Aliases are not expanded when the shell is not interactive, unless
4830 the
4831 <B>expand_aliases</B>
4832
4833 shell option is set using
4834 <B>shopt</B>
4835
4836 (see the description of
4837 <B>shopt</B>
4838
4839 under
4840 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B></FONT>
4841 below).
4842 <P>
4843
4844 The rules concerning the definition and use of aliases are
4845 somewhat confusing.
4846 <B>Bash</B>
4847
4848 always reads at least one complete line
4849 of input before executing any
4850 of the commands on that line. Aliases are expanded when a
4851 command is read, not when it is executed. Therefore, an
4852 alias definition appearing on the same line as another
4853 command does not take effect until the next line of input is read.
4854 The commands following the alias definition
4855 on that line are not affected by the new alias.
4856 This behavior is also an issue when functions are executed.
4857 Aliases are expanded when a function definition is read,
4858 not when the function is executed, because a function definition
4859 is itself a compound command. As a consequence, aliases
4860 defined in a function are not available until after that
4861 function is executed. To be safe, always put
4862 alias definitions on a separate line, and do not use
4863 <B>alias</B>
4864
4865 in compound commands.
4866 <P>
4867
4868 For almost every purpose, aliases are superseded by
4869 shell functions.
4870 <A NAME="lbBU">&nbsp;</A>
4871 <H3>FUNCTIONS</H3>
4872
4873 A shell function, defined as described above under
4874 <FONT SIZE=-1><B>SHELL GRAMMAR</B>,
4875
4876 </FONT>
4877 stores a series of commands for later execution.
4878 When the name of a shell function is used as a simple command name,
4879 the list of commands associated with that function name is executed.
4880 Functions are executed in the context of the
4881 current shell; no new process is created to interpret
4882 them (contrast this with the execution of a shell script).
4883 When a function is executed, the arguments to the
4884 function become the positional parameters
4885 during its execution.
4886 The special parameter
4887 <B>#</B>
4888
4889 is updated to reflect the change. Special parameter <B>0</B>
4890 is unchanged.
4891 The first element of the
4892 <FONT SIZE=-1><B>FUNCNAME</B>
4893
4894 </FONT>
4895 variable is set to the name of the function while the function
4896 is executing.
4897 <P>
4898
4899 All other aspects of the shell execution
4900 environment are identical between a function and its caller
4901 with these exceptions: the
4902 <FONT SIZE=-1><B>DEBUG</B>
4903
4904 </FONT>
4905 and
4906 <B>RETURN</B>
4907
4908 traps (see the description of the
4909 <B>trap</B>
4910
4911 builtin under
4912 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
4913
4914 </FONT>
4915 below) are not inherited unless the function has been given the
4916 <B>trace</B> attribute (see the description of the
4917 <FONT SIZE=-1><B>declare</B>
4918
4919 </FONT>
4920 builtin below) or the
4921 <B>-o functrace</B> shell option has been enabled with
4922 the <B>set</B> builtin
4923 (in which case all functions inherit the <B>DEBUG</B> and <B>RETURN</B> traps),
4924 and the
4925 <FONT SIZE=-1><B>ERR</B>
4926
4927 </FONT>
4928 trap is not inherited unless the <B>-o errtrace</B> shell option has
4929 been enabled.
4930 <P>
4931
4932 Variables local to the function may be declared with the
4933 <B>local</B>
4934
4935 builtin command. Ordinarily, variables and their values
4936 are shared between the function and its caller.
4937 <P>
4938
4939 The <B>FUNCNEST</B> variable, if set to a numeric value greater
4940 than 0, defines a maximum function nesting level. Function
4941 invocations that exceed the limit cause the entire command to
4942 abort.
4943 <P>
4944
4945 If the builtin command
4946 <B>return</B>
4947
4948 is executed in a function, the function completes and
4949 execution resumes with the next command after the function
4950 call.
4951 Any command associated with the <B>RETURN</B> trap is executed
4952 before execution resumes.
4953 When a function completes, the values of the
4954 positional parameters and the special parameter
4955 <B>#</B>
4956
4957 are restored to the values they had prior to the function's
4958 execution.
4959 <P>
4960
4961 Function names and definitions may be listed with the
4962 <B>-f</B>
4963
4964 option to the
4965 <B>declare</B>
4966
4967 or
4968 <B>typeset</B>
4969
4970 builtin commands. The
4971 <B>-F</B>
4972
4973 option to
4974 <B>declare</B>
4975
4976 or
4977 <B>typeset</B>
4978
4979 will list the function names only
4980 (and optionally the source file and line number, if the <B>extdebug</B>
4981 shell option is enabled).
4982 Functions may be exported so that subshells
4983 automatically have them defined with the
4984 <B>-f</B>
4985
4986 option to the
4987 <B>export</B>
4988
4989 builtin.
4990 A function definition may be deleted using the <B>-f</B> option to
4991 the
4992 <B>unset</B>
4993
4994 builtin.
4995 Note that shell functions and variables with the same name may result
4996 in multiple identically-named entries in the environment passed to the
4997 shell's children.
4998 Care should be taken in cases where this may cause a problem.
4999 <P>
5000
5001 Functions may be recursive.
5002 The <B>FUNCNEST</B> variable may be used to limit the depth of the
5003 function call stack and restrict the number of function invocations.
5004 By default, no limit is imposed on the number of recursive calls.
5005 <A NAME="lbBV">&nbsp;</A>
5006 <H3>ARITHMETIC EVALUATION</H3>
5007
5008 The shell allows arithmetic expressions to be evaluated, under
5009 certain circumstances (see the <B>let</B> and <B>declare</B> builtin
5010 commands and <B>Arithmetic Expansion</B>).
5011 Evaluation is done in fixed-width integers with no check for overflow,
5012 though division by 0 is trapped and flagged as an error.
5013 The operators and their precedence, associativity, and values
5014 are the same as in the C language.
5015 The following list of operators is grouped into levels of
5016 equal-precedence operators.
5017 The levels are listed in order of decreasing precedence.
5018 <P>
5019
5020
5021 <DL COMPACT>
5022 <DT><B></B><I>id</I>++ <I>id</I>--
5023
5024 <DD>
5025 variable post-increment and post-decrement
5026 <DT><B>++</B><I>id</I> --<I>id</I>
5027
5028 <DD>
5029 variable pre-increment and pre-decrement
5030 <DT><B>- +</B>
5031
5032 <DD>
5033 unary minus and plus
5034 <DT><B>! ~</B>
5035
5036 <DD>
5037 logical and bitwise negation
5038 <DT><B>**</B>
5039
5040 <DD>
5041 exponentiation
5042 <DT><B>* / %</B>
5043
5044 <DD>
5045 multiplication, division, remainder
5046 <DT><B>+ -</B>
5047
5048 <DD>
5049 addition, subtraction
5050 <DT><B>&lt;&lt; &gt;&gt;</B>
5051
5052 <DD>
5053 left and right bitwise shifts
5054 <DT><B>&lt;= &gt;= &lt; &gt;</B>
5055
5056 <DD>
5057 comparison
5058 <DT><B>== !=</B>
5059
5060 <DD>
5061 equality and inequality
5062 <DT><B>&amp;</B>
5063
5064 <DD>
5065 bitwise AND
5066 <DT><B>^</B>
5067
5068 <DD>
5069 bitwise exclusive OR
5070 <DT><B>|</B>
5071
5072 <DD>
5073 bitwise OR
5074 <DT><B>&amp;&amp;</B>
5075
5076 <DD>
5077 logical AND
5078 <DT><B>||</B>
5079
5080 <DD>
5081 logical OR
5082 <DT><B></B><I>expr</I>?<I>expr</I>:<I>expr</I>
5083
5084 <DD>
5085 conditional operator
5086 <DT><B>= *= /= %= += -= &lt;&lt;= &gt;&gt;= &amp;= ^= |=</B>
5087
5088 <DD>
5089 assignment
5090 <DT><B></B><I>expr1</I> , <I>expr2</I>
5091
5092 <DD>
5093 comma
5094
5095 </DL>
5096 <P>
5097
5098 Shell variables are allowed as operands; parameter expansion is
5099 performed before the expression is evaluated.
5100 Within an expression, shell variables may also be referenced by name
5101 without using the parameter expansion syntax.
5102 A shell variable that is null or unset evaluates to 0 when referenced
5103 by name without using the parameter expansion syntax.
5104 The value of a variable is evaluated as an arithmetic expression
5105 when it is referenced, or when a variable which has been given the
5106 <I>integer</I> attribute using <B>declare -i</B> is assigned a value.
5107 A null value evaluates to 0.
5108 A shell variable need not have its <I>integer</I> attribute
5109 turned on to be used in an expression.
5110 <P>
5111
5112 Constants with a leading 0 are interpreted as octal numbers.
5113 A leading 0x or 0X denotes hexadecimal.
5114 Otherwise, numbers take the form [<I>base#</I>]n, where the optional <I>base</I>
5115 is a decimal number between 2 and 64 representing the arithmetic
5116 base, and <I>n</I> is a number in that base.
5117 If <I>base#</I> is omitted, then base 10 is used.
5118 The digits greater than 9 are represented by the lowercase letters,
5119 the uppercase letters, @, and _, in that order.
5120 If <I>base</I> is less than or equal to 36, lowercase and uppercase
5121 letters may be used interchangeably to represent numbers between 10
5122 and 35.
5123 <P>
5124
5125 Operators are evaluated in order of precedence. Sub-expressions in
5126 parentheses are evaluated first and may override the precedence
5127 rules above.
5128 <A NAME="lbBW">&nbsp;</A>
5129 <H3>CONDITIONAL EXPRESSIONS</H3>
5130
5131 Conditional expressions are used by the <B>[[</B> compound command and
5132 the <B>test</B> and <B>[</B> builtin commands to test file attributes
5133 and perform string and arithmetic comparisons.
5134 Expressions are formed from the following unary or binary primaries.
5135 If any <I>file</I> argument to one of the primaries is of the form
5136 <I>/dev/fd/n</I>, then file descriptor <I>n</I> is checked.
5137 If the <I>file</I> argument to one of the primaries is one of
5138 <I>/dev/stdin</I>, <I>/dev/stdout</I>, or <I>/dev/stderr</I>, file
5139 descriptor 0, 1, or 2, respectively, is checked.
5140 <P>
5141
5142 Unless otherwise specified, primaries that operate on files follow symbolic
5143 links and operate on the target of the link, rather than the link itself.
5144 <P>
5145
5146
5147 When used with <B>[[</B>, The <B>&lt;</B> and <B>&gt;</B> operators sort
5148 lexicographically using the current locale.
5149 <P>
5150
5151 <DL COMPACT>
5152 <DT><B>-a </B><I>file</I>
5153
5154 <DD>
5155 True if <I>file</I> exists.
5156 <DT><B>-b </B><I>file</I>
5157
5158 <DD>
5159 True if <I>file</I> exists and is a block special file.
5160 <DT><B>-c </B><I>file</I>
5161
5162 <DD>
5163 True if <I>file</I> exists and is a character special file.
5164 <DT><B>-d </B><I>file</I>
5165
5166 <DD>
5167 True if <I>file</I> exists and is a directory.
5168 <DT><B>-e </B><I>file</I>
5169
5170 <DD>
5171 True if <I>file</I> exists.
5172 <DT><B>-f </B><I>file</I>
5173
5174 <DD>
5175 True if <I>file</I> exists and is a regular file.
5176 <DT><B>-g </B><I>file</I>
5177
5178 <DD>
5179 True if <I>file</I> exists and is set-group-id.
5180 <DT><B>-h </B><I>file</I>
5181
5182 <DD>
5183 True if <I>file</I> exists and is a symbolic link.
5184 <DT><B>-k </B><I>file</I>
5185
5186 <DD>
5187 True if <I>file</I> exists and its ``sticky'' bit is set.
5188 <DT><B>-p </B><I>file</I>
5189
5190 <DD>
5191 True if <I>file</I> exists and is a named pipe (FIFO).
5192 <DT><B>-r </B><I>file</I>
5193
5194 <DD>
5195 True if <I>file</I> exists and is readable.
5196 <DT><B>-s </B><I>file</I>
5197
5198 <DD>
5199 True if <I>file</I> exists and has a size greater than zero.
5200 <DT><B>-t </B><I>fd</I>
5201
5202 <DD>
5203 True if file descriptor
5204 <I>fd</I>
5205
5206 is open and refers to a terminal.
5207 <DT><B>-u </B><I>file</I>
5208
5209 <DD>
5210 True if <I>file</I> exists and its set-user-id bit is set.
5211 <DT><B>-w </B><I>file</I>
5212
5213 <DD>
5214 True if <I>file</I> exists and is writable.
5215 <DT><B>-x </B><I>file</I>
5216
5217 <DD>
5218 True if <I>file</I> exists and is executable.
5219 <DT><B>-G </B><I>file</I>
5220
5221 <DD>
5222 True if <I>file</I> exists and is owned by the effective group id.
5223 <DT><B>-L </B><I>file</I>
5224
5225 <DD>
5226 True if <I>file</I> exists and is a symbolic link.
5227 <DT><B>-N </B><I>file</I>
5228
5229 <DD>
5230 True if <I>file</I> exists and has been modified since it was last read.
5231 <DT><B>-O </B><I>file</I>
5232
5233 <DD>
5234 True if <I>file</I> exists and is owned by the effective user id.
5235 <DT><B>-S </B><I>file</I>
5236
5237 <DD>
5238 True if <I>file</I> exists and is a socket.
5239 <DT><I>file1</I> <B>-ef</B> <I>file2</I><DD>
5240 True if <I>file1</I> and <I>file2</I> refer to the same device and
5241 inode numbers.
5242 <DT><I>file1</I> -<B>nt</B> <I>file2</I><DD>
5243 True if <I>file1</I> is newer (according to modification date) than <I>file2</I>,
5244 or if <I>file1</I> exists and file2 does not.
5245 <DT><I>file1</I> -<B>ot</B> <I>file2</I><DD>
5246 True if <I>file1</I> is older than <I>file2</I>, or if <I>file2</I> exists
5247 and <I>file1</I> does not.
5248 <DT><B>-o </B><I>optname</I>
5249
5250 <DD>
5251 True if the shell option
5252 <I>optname</I>
5253
5254 is enabled.
5255 See the list of options under the description of the
5256 <B>-o</B>
5257
5258 option to the
5259 <B>set</B>
5260
5261 builtin below.
5262 <DT><B>-v </B><I>varname</I>
5263
5264 <DD>
5265 True if the shell variable
5266 <I>varname</I>
5267
5268 is set (has been assigned a value).
5269 <DT><B>-z </B><I>string</I>
5270
5271 <DD>
5272 True if the length of <I>string</I> is zero.
5273 <DT><I>string</I><DD>
5274
5275 <DT><B>-n </B><I>string</I>
5276
5277 <DD>
5278
5279 True if the length of
5280 <I>string</I>
5281
5282 is non-zero.
5283 <DT><I>string1</I> <B>==</B> <I>string2</I><DD>
5284
5285 <DT><I>string1</I> <B>=</B> <I>string2</I><DD>
5286
5287 True if the strings are equal. <B>=</B> should be used
5288 with the <B>test</B> command for POSIX conformance.
5289 <DT><I>string1</I> <B>!=</B> <I>string2</I><DD>
5290 True if the strings are not equal.
5291 <DT><I>string1</I> <B>&lt;</B> <I>string2</I><DD>
5292 True if <I>string1</I> sorts before <I>string2</I> lexicographically.
5293 <DT><I>string1</I> <B>&gt;</B> <I>string2</I><DD>
5294 True if <I>string1</I> sorts after <I>string2</I> lexicographically.
5295 <DT><I>arg1</I> <B>OP</B> <I>arg2</I>
5296
5297 <DD>
5298 <FONT SIZE=-1><B>OP</B>
5299
5300 </FONT>
5301 is one of
5302 <B>-eq</B>,
5303
5304 <B>-ne</B>,
5305
5306 <B>-lt</B>,
5307
5308 <B>-le</B>,
5309
5310 <B>-gt</B>,
5311
5312 or
5313 <B>-ge</B>.
5314
5315 These arithmetic binary operators return true if <I>arg1</I>
5316 is equal to, not equal to, less than, less than or equal to,
5317 greater than, or greater than or equal to <I>arg2</I>, respectively.
5318 <I>Arg1</I>
5319
5320 and
5321 <I>arg2</I>
5322
5323 may be positive or negative integers.
5324
5325 </DL>
5326 <A NAME="lbBX">&nbsp;</A>
5327 <H3>SIMPLE COMMAND EXPANSION</H3>
5328
5329 When a simple command is executed, the shell performs the following
5330 expansions, assignments, and redirections, from left to right.
5331 <DL COMPACT>
5332 <DT>1.<DD>
5333 The words that the parser has marked as variable assignments (those
5334 preceding the command name) and redirections are saved for later
5335 processing.
5336 <DT>2.<DD>
5337 The words that are not variable assignments or redirections are
5338 expanded. If any words remain after expansion, the first word
5339 is taken to be the name of the command and the remaining words are
5340 the arguments.
5341 <DT>3.<DD>
5342 Redirections are performed as described above under
5343 <FONT SIZE=-1><B>REDIRECTION</B>.
5344
5345 </FONT>
5346 <DT>4.<DD>
5347 The text after the <B>=</B> in each variable assignment undergoes tilde
5348 expansion, parameter expansion, command substitution, arithmetic expansion,
5349 and quote removal before being assigned to the variable.
5350 </DL>
5351 <P>
5352
5353 If no command name results, the variable assignments affect the current
5354 shell environment. Otherwise, the variables are added to the environment
5355 of the executed command and do not affect the current shell environment.
5356 If any of the assignments attempts to assign a value to a readonly variable,
5357 an error occurs, and the command exits with a non-zero status.
5358 <P>
5359
5360 If no command name results, redirections are performed, but do not
5361 affect the current shell environment. A redirection error causes the
5362 command to exit with a non-zero status.
5363 <P>
5364
5365 If there is a command name left after expansion, execution proceeds as
5366 described below. Otherwise, the command exits. If one of the expansions
5367 contained a command substitution, the exit status of the command is
5368 the exit status of the last command substitution performed. If there
5369 were no command substitutions, the command exits with a status of zero.
5370 <A NAME="lbBY">&nbsp;</A>
5371 <H3>COMMAND EXECUTION</H3>
5372
5373 After a command has been split into words, if it results in a
5374 simple command and an optional list of arguments, the following
5375 actions are taken.
5376 <P>
5377
5378 If the command name contains no slashes, the shell attempts to
5379 locate it. If there exists a shell function by that name, that
5380 function is invoked as described above in
5381 <FONT SIZE=-1><B>FUNCTIONS</B>.
5382
5383 </FONT>
5384 If the name does not match a function, the shell searches for
5385 it in the list of shell builtins. If a match is found, that
5386 builtin is invoked.
5387 <P>
5388
5389 If the name is neither a shell function nor a builtin,
5390 and contains no slashes,
5391 <B>bash</B>
5392
5393 searches each element of the
5394 <FONT SIZE=-1><B>PATH</B>
5395
5396 </FONT>
5397 for a directory containing an executable file by that name.
5398 <B>Bash</B>
5399
5400 uses a hash table to remember the full pathnames of executable
5401 files (see
5402 <B>hash</B>
5403
5404 under
5405 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
5406
5407 </FONT>
5408 below).
5409 A full search of the directories in
5410 <FONT SIZE=-1><B>PATH</B>
5411
5412 </FONT>
5413 is performed only if the command is not found in the hash table.
5414 If the search is unsuccessful, the shell searches for a defined shell
5415 function named <B>command_not_found_handle</B>.
5416 If that function exists, it is invoked with the original command and
5417 the original command's arguments as its arguments, and the function's
5418 exit status becomes the exit status of the shell.
5419 If that function is not defined, the shell prints an error
5420 message and returns an exit status of 127.
5421 <P>
5422
5423 If the search is successful, or if the command name contains
5424 one or more slashes, the shell executes the named program in a
5425 separate execution environment.
5426 Argument 0 is set to the name given, and the remaining arguments
5427 to the command are set to the arguments given, if any.
5428 <P>
5429
5430 If this execution fails because the file is not in executable
5431 format, and the file is not a directory, it is assumed to be
5432 a <I>shell script</I>, a file
5433 containing shell commands. A subshell is spawned to execute
5434 it. This subshell reinitializes itself, so
5435 that the effect is as if a new shell had been invoked
5436 to handle the script, with the exception that the locations of
5437 commands remembered by the parent (see
5438 <B>hash</B>
5439
5440 below under
5441 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>)</FONT>
5442 are retained by the child.
5443 <P>
5444
5445 If the program is a file beginning with
5446 <B>#!</B>,
5447
5448 the remainder of the first line specifies an interpreter
5449 for the program. The shell executes the
5450 specified interpreter on operating systems that do not
5451 handle this executable format themselves. The arguments to the
5452 interpreter consist of a single optional argument following the
5453 interpreter name on the first line of the program, followed
5454 by the name of the program, followed by the command
5455 arguments, if any.
5456 <A NAME="lbBZ">&nbsp;</A>
5457 <H3>COMMAND EXECUTION ENVIRONMENT</H3>
5458
5459 The shell has an <I>execution environment</I>, which consists of the
5460 following:
5461
5462 <DL COMPACT>
5463 <DT>*<DD>
5464 open files inherited by the shell at invocation, as modified by
5465 redirections supplied to the <B>exec</B> builtin
5466 <DT>*<DD>
5467 the current working directory as set by <B>cd</B>, <B>pushd</B>, or
5468 <B>popd</B>, or inherited by the shell at invocation
5469 <DT>*<DD>
5470 the file creation mode mask as set by <B>umask</B> or inherited from
5471 the shell's parent
5472 <DT>*<DD>
5473 current traps set by <B>trap</B>
5474 <DT>*<DD>
5475 shell parameters that are set by variable assignment or with <B>set</B>
5476 or inherited from the shell's parent in the environment
5477 <DT>*<DD>
5478 shell functions defined during execution or inherited from the shell's
5479 parent in the environment
5480 <DT>*<DD>
5481 options enabled at invocation (either by default or with command-line
5482 arguments) or by <B>set</B>
5483 <DT>*<DD>
5484 options enabled by <B>shopt</B>
5485 <DT>*<DD>
5486 shell aliases defined with <B>alias</B>
5487 <DT>*<DD>
5488 various process IDs, including those of background jobs, the value
5489 of <B>$$</B>, and the value of
5490 <FONT SIZE=-1><B>PPID</B>
5491
5492 </FONT>
5493 </DL>
5494 <P>
5495
5496 When a simple command other than a builtin or shell function
5497 is to be executed, it
5498 is invoked in a separate execution environment that consists of
5499 the following. Unless otherwise noted, the values are inherited
5500 from the shell.
5501
5502 <DL COMPACT>
5503 <DT>*<DD>
5504 the shell's open files, plus any modifications and additions specified
5505 by redirections to the command
5506 <DT>*<DD>
5507 the current working directory
5508 <DT>*<DD>
5509 the file creation mode mask
5510 <DT>*<DD>
5511 shell variables and functions marked for export, along with variables
5512 exported for the command, passed in the environment
5513 <DT>*<DD>
5514 traps caught by the shell are reset to the values inherited from the
5515 shell's parent, and traps ignored by the shell are ignored
5516 </DL>
5517 <P>
5518
5519 A command invoked in this separate environment cannot affect the
5520 shell's execution environment.
5521 <P>
5522
5523 Command substitution, commands grouped with parentheses,
5524 and asynchronous commands are invoked in a
5525 subshell environment that is a duplicate of the shell environment,
5526 except that traps caught by the shell are reset to the values
5527 that the shell inherited from its parent at invocation. Builtin
5528 commands that are invoked as part of a pipeline are also executed in a
5529 subshell environment. Changes made to the subshell environment
5530 cannot affect the shell's execution environment.
5531 <P>
5532
5533 Subshells spawned to execute command substitutions inherit the value of
5534 the <B>-e</B> option from the parent shell. When not in <I>posix</I> mode,
5535 <B>bash</B> clears the <B>-e</B> option in such subshells.
5536 <P>
5537
5538 If a command is followed by a <B>&amp;</B> and job control is not active, the
5539 default standard input for the command is the empty file <I>/dev/null</I>.
5540 Otherwise, the invoked command inherits the file descriptors of the calling
5541 shell as modified by redirections.
5542 <A NAME="lbCA">&nbsp;</A>
5543 <H3>ENVIRONMENT</H3>
5544
5545 When a program is invoked it is given an array of strings
5546 called the
5547 <I>environment</I>.
5548
5549 This is a list of
5550 <I>name</I>-<I>value</I> pairs, of the form
5551 <I>name</I>=value.
5552
5553 <P>
5554
5555 The shell provides several ways to manipulate the environment.
5556 On invocation, the shell scans its own environment and
5557 creates a parameter for each name found, automatically marking
5558 it for
5559 <I>export</I>
5560
5561 to child processes. Executed commands inherit the environment.
5562 The
5563 <B>export</B>
5564
5565 and
5566 <B>declare -x</B>
5567
5568 commands allow parameters and functions to be added to and
5569 deleted from the environment. If the value of a parameter
5570 in the environment is modified, the new value becomes part
5571 of the environment, replacing the old. The environment
5572 inherited by any executed command consists of the shell's
5573 initial environment, whose values may be modified in the shell,
5574 less any pairs removed by the
5575 <B>unset</B>
5576
5577 command, plus any additions via the
5578 <B>export</B>
5579
5580 and
5581 <B>declare -x</B>
5582
5583 commands.
5584 <P>
5585
5586 The environment for any
5587 <I>simple command</I>
5588
5589 or function may be augmented temporarily by prefixing it with
5590 parameter assignments, as described above in
5591 <FONT SIZE=-1><B>PARAMETERS</B>.
5592
5593 </FONT>
5594 These assignment statements affect only the environment seen
5595 by that command.
5596 <P>
5597
5598 If the
5599 <B>-k</B>
5600
5601 option is set (see the
5602 <B>set</B>
5603
5604 builtin command below), then
5605 <I>all</I>
5606
5607 parameter assignments are placed in the environment for a command,
5608 not just those that precede the command name.
5609 <P>
5610
5611 When
5612 <B>bash</B>
5613
5614 invokes an external command, the variable
5615 <B>_</B>
5616
5617 is set to the full file name of the command and passed to that
5618 command in its environment.
5619 <A NAME="lbCB">&nbsp;</A>
5620 <H3>EXIT STATUS</H3>
5621
5622 <P>
5623
5624 The exit status of an executed command is the value returned by the
5625 <I>waitpid</I> system call or equivalent function. Exit statuses
5626 fall between 0 and 255, though, as explained below, the shell may
5627 use values above 125 specially. Exit statuses from shell builtins and
5628 compound commands are also limited to this range. Under certain
5629 circumstances, the shell will use special values to indicate specific
5630 failure modes.
5631 <P>
5632
5633 For the shell's purposes, a command which exits with a
5634 zero exit status has succeeded. An exit status of zero
5635 indicates success. A non-zero exit status indicates failure.
5636 When a command terminates on a fatal signal <I>N</I>, <B>bash</B> uses
5637 the value of 128+<I>N</I> as the exit status.
5638 <P>
5639
5640 If a command is not found, the child process created to
5641 execute it returns a status of 127. If a command is found
5642 but is not executable, the return status is 126.
5643 <P>
5644
5645 If a command fails because of an error during expansion or redirection,
5646 the exit status is greater than zero.
5647 <P>
5648
5649 Shell builtin commands return a status of 0 (<I>true</I>) if
5650 successful, and non-zero (<I>false</I>) if an error occurs
5651 while they execute.
5652 All builtins return an exit status of 2 to indicate incorrect usage.
5653 <P>
5654
5655 <B>Bash</B> itself returns the exit status of the last command
5656 executed, unless a syntax error occurs, in which case it exits
5657 with a non-zero value. See also the <B>exit</B> builtin
5658 command below.
5659 <A NAME="lbCC">&nbsp;</A>
5660 <H3>SIGNALS</H3>
5661
5662 When <B>bash</B> is interactive, in the absence of any traps, it ignores
5663 <FONT SIZE=-1><B>SIGTERM</B>
5664
5665 </FONT>
5666 (so that <B>kill 0</B> does not kill an interactive shell),
5667 and
5668 <FONT SIZE=-1><B>SIGINT</B>
5669
5670 </FONT>
5671 is caught and handled (so that the <B>wait</B> builtin is interruptible).
5672 In all cases, <B>bash</B> ignores
5673 <FONT SIZE=-1><B>SIGQUIT</B>.
5674
5675 </FONT>
5676 If job control is in effect,
5677 <B>bash</B>
5678
5679 ignores
5680 <FONT SIZE=-1><B>SIGTTIN</B>,
5681
5682 </FONT>
5683 <FONT SIZE=-1><B>SIGTTOU</B>,
5684
5685 </FONT>
5686 and
5687 <FONT SIZE=-1><B>SIGTSTP</B>.
5688
5689 </FONT>
5690 <P>
5691
5692 Non-builtin commands run by <B>bash</B> have signal handlers
5693 set to the values inherited by the shell from its parent.
5694 When job control is not in effect, asynchronous commands
5695 ignore
5696 <FONT SIZE=-1><B>SIGINT</B>
5697
5698 </FONT>
5699 and
5700 <FONT SIZE=-1><B>SIGQUIT</B>
5701
5702 </FONT>
5703 in addition to these inherited handlers.
5704 Commands run as a result of command substitution ignore the
5705 keyboard-generated job control signals
5706 <FONT SIZE=-1><B>SIGTTIN</B>,
5707
5708 </FONT>
5709 <FONT SIZE=-1><B>SIGTTOU</B>,
5710
5711 </FONT>
5712 and
5713 <FONT SIZE=-1><B>SIGTSTP</B>.
5714
5715 </FONT>
5716 <P>
5717
5718 The shell exits by default upon receipt of a
5719 <FONT SIZE=-1><B>SIGHUP</B>.
5720
5721 </FONT>
5722 Before exiting, an interactive shell resends the
5723 <FONT SIZE=-1><B>SIGHUP</B>
5724
5725 </FONT>
5726 to all jobs, running or stopped.
5727 Stopped jobs are sent
5728 <FONT SIZE=-1><B>SIGCONT</B>
5729
5730 </FONT>
5731 to ensure that they receive the
5732 <FONT SIZE=-1><B>SIGHUP</B>.
5733
5734 </FONT>
5735 To prevent the shell from
5736 sending the signal to a particular job, it should be removed from the
5737 jobs table with the
5738 <B>disown</B>
5739
5740 builtin (see
5741 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
5742
5743 </FONT>
5744 below) or marked
5745 to not receive
5746 <FONT SIZE=-1><B>SIGHUP</B>
5747
5748 </FONT>
5749 using
5750 <B>disown -h</B>.
5751
5752 <P>
5753
5754 If the
5755 <B>huponexit</B>
5756
5757 shell option has been set with
5758 <B>shopt</B>,
5759
5760 <B>bash</B>
5761
5762 sends a
5763 <FONT SIZE=-1><B>SIGHUP</B>
5764
5765 </FONT>
5766 to all jobs when an interactive login shell exits.
5767 <P>
5768
5769 If <B>bash</B> is waiting for a command to complete and receives a signal
5770 for which a trap has been set, the trap will not be executed until
5771 the command completes.
5772 When <B>bash</B> is waiting for an asynchronous command via the <B>wait</B>
5773 builtin, the reception of a signal for which a trap has been set will
5774 cause the <B>wait</B> builtin to return immediately with an exit status
5775 greater than 128, immediately after which the trap is executed.
5776 <A NAME="lbCD">&nbsp;</A>
5777 <H3>JOB CONTROL</H3>
5778
5779 <I>Job control</I>
5780
5781 refers to the ability to selectively stop (<I>suspend</I>)
5782 the execution of processes and continue (<I>resume</I>)
5783 their execution at a later point. A user typically employs
5784 this facility via an interactive interface supplied jointly
5785 by the operating system kernel's terminal driver and
5786 <B>bash</B>.
5787
5788 <P>
5789
5790 The shell associates a
5791 <I>job</I>
5792
5793 with each pipeline. It keeps a table of currently executing
5794 jobs, which may be listed with the
5795 <B>jobs</B>
5796
5797 command. When
5798 <B>bash</B>
5799
5800 starts a job asynchronously (in the
5801 <I>background</I>),
5802
5803 it prints a line that looks like:
5804 <DL COMPACT><DT><DD>
5805 <P>
5806
5807 [1] 25647
5808 </DL>
5809
5810 <P>
5811
5812 indicating that this job is job number 1 and that the process ID
5813 of the last process in the pipeline associated with this job is 25647.
5814 All of the processes in a single pipeline are members of the same job.
5815 <B>Bash</B>
5816
5817 uses the
5818 <I>job</I>
5819
5820 abstraction as the basis for job control.
5821 <P>
5822
5823 To facilitate the implementation of the user interface to job
5824 control, the operating system maintains the notion of a <I>current terminal
5825 process group ID</I>. Members of this process group (processes whose
5826 process group ID is equal to the current terminal process group ID)
5827 receive keyboard-generated signals such as
5828 <FONT SIZE=-1><B>SIGINT</B>.
5829
5830 </FONT>
5831 These processes are said to be in the
5832 <I>foreground</I>.
5833
5834 <I>Background</I>
5835
5836 processes are those whose process group ID differs from the terminal's;
5837 such processes are immune to keyboard-generated signals.
5838 Only foreground processes are allowed to read from or, if the
5839 user so specifies with <TT>stty tostop</TT>, write to the
5840 terminal.
5841 Background processes which attempt to read from (write to when
5842 <TT>stty tostop</TT> is in effect) the
5843 terminal are sent a
5844 <FONT SIZE=-1><B>SIGTTIN (SIGTTOU)</B>
5845
5846 </FONT>
5847 signal by the kernel's terminal driver,
5848 which, unless caught, suspends the process.
5849 <P>
5850
5851 If the operating system on which
5852 <B>bash</B>
5853
5854 is running supports
5855 job control,
5856 <B>bash</B>
5857
5858 contains facilities to use it.
5859 Typing the
5860 <I>suspend</I>
5861
5862 character (typically
5863 <B>^Z</B>,
5864
5865 Control-Z) while a process is running
5866 causes that process to be stopped and returns control to
5867 <B>bash</B>.
5868
5869 Typing the
5870 <I>delayed suspend</I>
5871
5872 character (typically
5873 <B>^Y</B>,
5874
5875 Control-Y) causes the process to be stopped when it
5876 attempts to read input from the terminal, and control to
5877 be returned to
5878 <B>bash</B>.
5879
5880 The user may then manipulate the state of this job, using the
5881 <B>bg</B>
5882
5883 command to continue it in the background, the
5884 <B>fg</B>
5885
5886 command to continue it in the foreground, or
5887 the
5888 <B>kill</B>
5889
5890 command to kill it. A <B>^Z</B> takes effect immediately,
5891 and has the additional side effect of causing pending output
5892 and typeahead to be discarded.
5893 <P>
5894
5895 There are a number of ways to refer to a job in the shell.
5896 The character
5897 <B>%</B>
5898
5899 introduces a job specification (<I>jobspec</I>). Job number
5900 <I>n</I>
5901
5902 may be referred to as
5903 <B>%n</B>.
5904
5905 A job may also be referred to using a prefix of the name used to
5906 start it, or using a substring that appears in its command line.
5907 For example,
5908 <B>%ce</B>
5909
5910 refers to a stopped
5911 <B>ce</B>
5912
5913 job. If a prefix matches more than one job,
5914 <B>bash</B>
5915
5916 reports an error. Using
5917 <B>%?ce</B>,
5918
5919 on the other hand, refers to any job containing the string
5920 <B>ce</B>
5921
5922 in its command line. If the substring matches more than one job,
5923 <B>bash</B>
5924
5925 reports an error. The symbols
5926 <B>%%</B>
5927
5928 and
5929 <B>%+</B>
5930
5931 refer to the shell's notion of the
5932 <I>current job</I>,
5933
5934 which is the last job stopped while it was in
5935 the foreground or started in the background.
5936 The
5937 <I>previous job</I>
5938
5939 may be referenced using
5940 <B>%-</B>.
5941
5942 If there is only a single job, <B>%+</B> and <B>%-</B> can both be used
5943 to refer to that job.
5944 In output pertaining to jobs (e.g., the output of the
5945 <B>jobs</B>
5946
5947 command), the current job is always flagged with a
5948 <B>+</B>,
5949
5950 and the previous job with a
5951 <B>-</B>.
5952
5953 A single % (with no accompanying job specification) also refers to the
5954 current job.
5955 <P>
5956
5957 Simply naming a job can be used to bring it into the
5958 foreground:
5959 <B>%1</B>
5960
5961 is a synonym for
5962 <B>``fg %1''</B>,
5963 bringing job 1 from the background into the foreground.
5964 Similarly,
5965 <B>``%1 &amp;''</B>
5966
5967 resumes job 1 in the background, equivalent to
5968 <B>``bg %1''</B>.
5969 <P>
5970
5971 The shell learns immediately whenever a job changes state.
5972 Normally,
5973 <B>bash</B>
5974
5975 waits until it is about to print a prompt before reporting
5976 changes in a job's status so as to not interrupt
5977 any other output. If the
5978 <B>-b</B>
5979
5980 option to the
5981 <B>set</B>
5982
5983 builtin command
5984 is enabled,
5985 <B>bash</B>
5986
5987 reports such changes immediately.
5988 Any trap on
5989 <FONT SIZE=-1><B>SIGCHLD</B>
5990
5991 </FONT>
5992 is executed for each child that exits.
5993 <P>
5994
5995 If an attempt to exit
5996 <B>bash</B>
5997
5998 is made while jobs are stopped (or, if the <B>checkjobs</B> shell option has
5999 been enabled using the <B>shopt</B> builtin, running), the shell prints a
6000 warning message, and, if the <B>checkjobs</B> option is enabled, lists the
6001 jobs and their statuses.
6002 The
6003 <B>jobs</B>
6004
6005 command may then be used to inspect their status.
6006 If a second attempt to exit is made without an intervening command,
6007 the shell does not print another warning, and any stopped
6008 jobs are terminated.
6009 <A NAME="lbCE">&nbsp;</A>
6010 <H3>PROMPTING</H3>
6011
6012 When executing interactively,
6013 <B>bash</B>
6014
6015 displays the primary prompt
6016 <FONT SIZE=-1><B>PS1</B>
6017
6018 </FONT>
6019 when it is ready to read a command, and the secondary prompt
6020 <FONT SIZE=-1><B>PS2</B>
6021
6022 </FONT>
6023 when it needs more input to complete a command.
6024 <B>Bash</B>
6025
6026 allows these prompt strings to be customized by inserting a number of
6027 backslash-escaped special characters that are decoded as follows:
6028 <DL COMPACT><DT><DD>
6029
6030 <DL COMPACT>
6031 <DT><B>\a</B>
6032
6033 <DD>
6034 an ASCII bell character (07)
6035 <DT><B>\d</B>
6036
6037 <DD>
6038 the date in &quot;Weekday Month Date&quot; format (e.g., &quot;Tue May 26&quot;)
6039 <DT><B>\D{</B><I>format</I>}
6040
6041 <DD>
6042 the <I>format</I> is passed to <I>strftime</I>(3) and the result is inserted
6043 into the prompt string; an empty <I>format</I> results in a locale-specific
6044 time representation. The braces are required
6045 <DT><B>\e</B>
6046
6047 <DD>
6048 an ASCII escape character (033)
6049 <DT><B>\h</B>
6050
6051 <DD>
6052 the hostname up to the first `.'
6053 <DT><B>\H</B>
6054
6055 <DD>
6056 the hostname
6057 <DT><B>\j</B>
6058
6059 <DD>
6060 the number of jobs currently managed by the shell
6061 <DT><B>\l</B>
6062
6063 <DD>
6064 the basename of the shell's terminal device name
6065 <DT><B>\n</B>
6066
6067 <DD>
6068 newline
6069 <DT><B>\r</B>
6070
6071 <DD>
6072 carriage return
6073 <DT><B>\s</B>
6074
6075 <DD>
6076 the name of the shell, the basename of
6077 <B>$0</B>
6078
6079 (the portion following the final slash)
6080 <DT><B>\t</B>
6081
6082 <DD>
6083 the current time in 24-hour HH:MM:SS format
6084 <DT><B>\T</B>
6085
6086 <DD>
6087 the current time in 12-hour HH:MM:SS format
6088 <DT><B>\@</B>
6089
6090 <DD>
6091 the current time in 12-hour am/pm format
6092 <DT><B>\A</B>
6093
6094 <DD>
6095 the current time in 24-hour HH:MM format
6096 <DT><B>\u</B>
6097
6098 <DD>
6099 the username of the current user
6100 <DT><B>\v</B>
6101
6102 <DD>
6103 the version of <B>bash</B> (e.g., 2.00)
6104 <DT><B>\V</B>
6105
6106 <DD>
6107 the release of <B>bash</B>, version + patch level (e.g., 2.00.0)
6108 <DT><B>\w</B>
6109
6110 <DD>
6111 the current working directory, with
6112 <FONT SIZE=-1><B>$HOME</B>
6113
6114 </FONT>
6115 abbreviated with a tilde
6116 (uses the value of the
6117 <FONT SIZE=-1><B>PROMPT_DIRTRIM</B>
6118
6119 </FONT>
6120 variable)
6121 <DT><B>\W</B>
6122
6123 <DD>
6124 the basename of the current working directory, with
6125 <FONT SIZE=-1><B>$HOME</B>
6126
6127 </FONT>
6128 abbreviated with a tilde
6129 <DT><B>\!</B>
6130
6131 <DD>
6132 the history number of this command
6133 <DT><B>\#</B>
6134
6135 <DD>
6136 the command number of this command
6137 <DT><B>\$</B>
6138
6139 <DD>
6140 if the effective UID is 0, a
6141 <B>#</B>,
6142
6143 otherwise a
6144 <B>$</B>
6145
6146 <DT><B>\</B><I>nnn</I>
6147
6148 <DD>
6149 the character corresponding to the octal number <I>nnn</I>
6150 <DT><B>\\</B>
6151
6152 <DD>
6153 a backslash
6154 <DT><B>\[</B>
6155
6156 <DD>
6157 begin a sequence of non-printing characters, which could be used to
6158 embed a terminal control sequence into the prompt
6159 <DT><B>\]</B>
6160
6161 <DD>
6162 end a sequence of non-printing characters
6163
6164 </DL></DL>
6165
6166 <P>
6167
6168 The command number and the history number are usually different:
6169 the history number of a command is its position in the history
6170 list, which may include commands restored from the history file
6171 (see
6172 <FONT SIZE=-1><B>HISTORY</B>
6173
6174 </FONT>
6175 below), while the command number is the position in the sequence
6176 of commands executed during the current shell session.
6177 After the string is decoded, it is expanded via
6178 parameter expansion, command substitution, arithmetic
6179 expansion, and quote removal, subject to the value of the
6180 <B>promptvars</B>
6181
6182 shell option (see the description of the
6183 <B>shopt</B>
6184
6185 command under
6186 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
6187
6188 </FONT>
6189 below).
6190 <A NAME="lbCF">&nbsp;</A>
6191 <H3>READLINE</H3>
6192
6193 This is the library that handles reading input when using an interactive
6194 shell, unless the
6195 <B>--noediting</B>
6196
6197 option is given at shell invocation.
6198 Line editing is also used when using the <B>-e</B> option to the
6199 <B>read</B> builtin.
6200 By default, the line editing commands are similar to those of Emacs.
6201 A vi-style line editing interface is also available.
6202 Line editing can be enabled at any time using the
6203 <B>-o emacs</B>
6204
6205 or
6206 <B>-o vi</B>
6207
6208 options to the
6209 <B>set</B>
6210
6211 builtin (see
6212 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
6213
6214 </FONT>
6215 below).
6216 To turn off line editing after the shell is running, use the
6217 <B>+o emacs</B>
6218
6219 or
6220 <B>+o vi</B>
6221
6222 options to the
6223 <B>set</B>
6224
6225 builtin.
6226 <A NAME="lbCG">&nbsp;</A>
6227 <H4>Readline Notation</H4>
6228
6229 <P>
6230
6231 In this section, the Emacs-style notation is used to denote
6232 keystrokes. Control keys are denoted by C-<I>key</I>, e.g., C-n
6233 means Control-N. Similarly,
6234 <I>meta</I>
6235
6236 keys are denoted by M-<I>key</I>, so M-x means Meta-X. (On keyboards
6237 without a
6238 <I>meta</I>
6239
6240 key, M-<I>x</I> means ESC <I>x</I>, i.e., press the Escape key
6241 then the
6242 <I>x</I>
6243
6244 key. This makes ESC the <I>meta prefix</I>.
6245 The combination M-C-<I>x</I> means ESC-Control-<I>x</I>,
6246 or press the Escape key
6247 then hold the Control key while pressing the
6248 <I>x</I>
6249
6250 key.)
6251 <P>
6252
6253 Readline commands may be given numeric
6254 <I>arguments</I>,
6255
6256 which normally act as a repeat count.
6257 Sometimes, however, it is the sign of the argument that is significant.
6258 Passing a negative argument to a command that acts in the forward
6259 direction (e.g., <B>kill-line</B>) causes that command to act in a
6260 backward direction.
6261 Commands whose behavior with arguments deviates from this are noted
6262 below.
6263 <P>
6264
6265 When a command is described as <I>killing</I> text, the text
6266 deleted is saved for possible future retrieval
6267 (<I>yanking</I>). The killed text is saved in a
6268 <I>kill ring</I>. Consecutive kills cause the text to be
6269 accumulated into one unit, which can be yanked all at once.
6270 Commands which do not kill text separate the chunks of text
6271 on the kill ring.
6272 <A NAME="lbCH">&nbsp;</A>
6273 <H4>Readline Initialization</H4>
6274
6275 <P>
6276
6277 Readline is customized by putting commands in an initialization
6278 file (the <I>inputrc</I> file).
6279 The name of this file is taken from the value of the
6280 <FONT SIZE=-1><B>INPUTRC</B>
6281
6282 </FONT>
6283 variable. If that variable is unset, the default is
6284 <A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>.
6285
6286 When a program which uses the readline library starts up, the
6287 initialization file is read, and the key bindings and variables
6288 are set.
6289 There are only a few basic constructs allowed in the
6290 readline initialization file.
6291 Blank lines are ignored.
6292 Lines beginning with a <B>#</B> are comments.
6293 Lines beginning with a <B>$</B> indicate conditional constructs.
6294 Other lines denote key bindings and variable settings.
6295 <P>
6296
6297 The default key-bindings may be changed with an
6298 <I>inputrc </I>
6299
6300 file.
6301 Other programs that use this library may add their own commands
6302 and bindings.
6303 <P>
6304
6305 For example, placing
6306 <DL COMPACT><DT><DD>
6307 <P>
6308
6309 M-Control-u: universal-argument
6310 </DL>
6311
6312 or
6313 <DL COMPACT><DT><DD>
6314 C-Meta-u: universal-argument
6315 </DL>
6316
6317 into the
6318 <I>inputrc</I>
6319
6320 would make M-C-u execute the readline command
6321 <I>universal-argument</I>.
6322
6323 <P>
6324
6325 The following symbolic character names are recognized:
6326 <I>RUBOUT</I>,
6327
6328 <I>DEL</I>,
6329
6330 <I>ESC</I>,
6331
6332 <I>LFD</I>,
6333
6334 <I>NEWLINE</I>,
6335
6336 <I>RET</I>,
6337
6338 <I>RETURN</I>,
6339
6340 <I>SPC</I>,
6341
6342 <I>SPACE</I>,
6343
6344 and
6345 <I>TAB</I>.
6346
6347 <P>
6348
6349 In addition to command names, readline allows keys to be bound
6350 to a string that is inserted when the key is pressed (a <I>macro</I>).
6351 <A NAME="lbCI">&nbsp;</A>
6352 <H4>Readline Key Bindings</H4>
6353
6354 <P>
6355
6356 The syntax for controlling key bindings in the
6357 <I>inputrc</I>
6358
6359 file is simple. All that is required is the name of the
6360 command or the text of a macro and a key sequence to which
6361 it should be bound. The name may be specified in one of two ways:
6362 as a symbolic key name, possibly with <I>Meta-</I> or <I>Control-</I>
6363 prefixes, or as a key sequence.
6364 <P>
6365
6366 When using the form <B>keyname</B>:<I>function-name</I> or <I>macro</I>,
6367 <I>keyname</I>
6368
6369 is the name of a key spelled out in English. For example:
6370 <P>
6371 <DL COMPACT><DT><DD>
6372 Control-u: universal-argument
6373 <BR>
6374
6375 Meta-Rubout: backward-kill-word
6376 <BR>
6377
6378 Control-o: &quot;&gt; output&quot;
6379 </DL>
6380
6381 <P>
6382
6383 In the above example,
6384 <I>C-u</I>
6385
6386 is bound to the function
6387 <B>universal-argument</B>,
6388
6389 <I>M-DEL</I>
6390
6391 is bound to the function
6392 <B>backward-kill-word</B>,
6393
6394 and
6395 <I>C-o</I>
6396
6397 is bound to run the macro
6398 expressed on the right hand side (that is, to insert the text
6399 <TT>&gt; output</TT>
6400
6401 into the line).
6402 <P>
6403
6404 In the second form, <B>&quot;keyseq&quot;</B>:<I>function-name</I> or <I>macro</I>,
6405 <B>keyseq</B>
6406
6407 differs from
6408 <B>keyname</B>
6409
6410 above in that strings denoting
6411 an entire key sequence may be specified by placing the sequence
6412 within double quotes. Some GNU Emacs style key escapes can be
6413 used, as in the following example, but the symbolic character names
6414 are not recognized.
6415 <P>
6416 <DL COMPACT><DT><DD>
6417 &quot;\C-u&quot;: universal-argument
6418 <BR>
6419
6420 &quot;\C-x\C-r&quot;: re-read-init-file
6421 <BR>
6422
6423 &quot;\e[11~&quot;: &quot;Function Key 1&quot;
6424 </DL>
6425
6426 <P>
6427
6428 In this example,
6429 <I>C-u</I>
6430
6431 is again bound to the function
6432 <B>universal-argument</B>.
6433
6434 <I>C-x C-r</I>
6435
6436 is bound to the function
6437 <B>re-read-init-file</B>,
6438
6439 and
6440 <I>ESC [ 1 1 ~</I>
6441
6442 is bound to insert the text
6443 <TT>Function Key 1</TT>.
6444
6445 <P>
6446
6447 The full set of GNU Emacs style escape sequences is
6448 <DL COMPACT><DT><DD>
6449
6450 <DL COMPACT>
6451 <DT><B>\C-</B>
6452
6453 <DD>
6454 control prefix
6455 <DT><B>\M-</B>
6456
6457 <DD>
6458 meta prefix
6459 <DT><B>\e</B>
6460
6461 <DD>
6462 an escape character
6463 <DT><B>\\</B>
6464
6465 <DD>
6466 backslash
6467 <DT><B>\</B>
6468
6469 <DD>
6470 literal &quot;
6471 <DT><B>\aq</B>
6472
6473 <DD>
6474 literal aq
6475 </DL></DL>
6476
6477
6478 <P>
6479
6480 In addition to the GNU Emacs style escape sequences, a second
6481 set of backslash escapes is available:
6482 <DL COMPACT><DT><DD>
6483
6484 <DL COMPACT>
6485 <DT><B>\a</B>
6486
6487 <DD>
6488 alert (bell)
6489 <DT><B>\b</B>
6490
6491 <DD>
6492 backspace
6493 <DT><B>\d</B>
6494
6495 <DD>
6496 delete
6497 <DT><B>\f</B>
6498
6499 <DD>
6500 form feed
6501 <DT><B>\n</B>
6502
6503 <DD>
6504 newline
6505 <DT><B>\r</B>
6506
6507 <DD>
6508 carriage return
6509 <DT><B>\t</B>
6510
6511 <DD>
6512 horizontal tab
6513 <DT><B>\v</B>
6514
6515 <DD>
6516 vertical tab
6517 <DT><B>\</B><I>nnn</I>
6518
6519 <DD>
6520 the eight-bit character whose value is the octal value <I>nnn</I>
6521 (one to three digits)
6522 <DT><B>\x</B><I>HH</I>
6523
6524 <DD>
6525 the eight-bit character whose value is the hexadecimal value <I>HH</I>
6526 (one or two hex digits)
6527 </DL></DL>
6528
6529
6530 <P>
6531
6532 When entering the text of a macro, single or double quotes must
6533 be used to indicate a macro definition.
6534 Unquoted text is assumed to be a function name.
6535 In the macro body, the backslash escapes described above are expanded.
6536 Backslash will quote any other character in the macro text,
6537 including &quot; and aq.
6538 <P>
6539
6540 <B>Bash</B>
6541
6542 allows the current readline key bindings to be displayed or modified
6543 with the
6544 <B>bind</B>
6545
6546 builtin command. The editing mode may be switched during interactive
6547 use by using the
6548 <B>-o</B>
6549
6550 option to the
6551 <B>set</B>
6552
6553 builtin command (see
6554 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
6555
6556 </FONT>
6557 below).
6558 <A NAME="lbCJ">&nbsp;</A>
6559 <H4>Readline Variables</H4>
6560
6561 <P>
6562
6563 Readline has variables that can be used to further customize its
6564 behavior. A variable may be set in the
6565 <I>inputrc</I>
6566
6567 file with a statement of the form
6568 <DL COMPACT><DT><DD>
6569 <P>
6570
6571 <B>set</B> <I>variable-name</I> <I>value</I>
6572 </DL>
6573
6574 <P>
6575
6576 Except where noted, readline variables can take the values
6577 <B>On</B>
6578
6579 or
6580 <B>Off</B>
6581
6582 (without regard to case).
6583 Unrecognized variable names are ignored.
6584 When a variable value is read, empty or null values, &quot;on&quot; (case-insensitive),
6585 and &quot;1&quot; are equivalent to <B>On</B>. All other values are equivalent to
6586 <B>Off</B>.
6587 The variables and their default values are:
6588 <P>
6589
6590
6591 <DL COMPACT>
6592 <DT><B>bell-style (audible)</B>
6593
6594 <DD>
6595 Controls what happens when readline wants to ring the terminal bell.
6596 If set to <B>none</B>, readline never rings the bell. If set to
6597 <B>visible</B>, readline uses a visible bell if one is available.
6598 If set to <B>audible</B>, readline attempts to ring the terminal's bell.
6599 <DT><B>bind-tty-special-chars (On)</B>
6600
6601 <DD>
6602 If set to <B>On</B>, readline attempts to bind the control characters
6603 treated specially by the kernel's terminal driver to their readline
6604 equivalents.
6605 <DT><B>comment-begin (``#'')</B>
6606
6607 <DD>
6608 The string that is inserted when the readline
6609 <B>insert-comment</B>
6610
6611 command is executed.
6612 This command is bound to
6613 <B>M-#</B>
6614
6615 in emacs mode and to
6616 <B>#</B>
6617
6618 in vi command mode.
6619 <DT><B>completion-ignore-case (Off)</B>
6620
6621 <DD>
6622 If set to <B>On</B>, readline performs filename matching and completion
6623 in a case-insensitive fashion.
6624 <DT><B>completion-prefix-display-length (0)</B>
6625
6626 <DD>
6627 The length in characters of the common prefix of a list of possible
6628 completions that is displayed without modification. When set to a
6629 value greater than zero, common prefixes longer than this value are
6630 replaced with an ellipsis when displaying possible completions.
6631 <DT><B>completion-query-items (100)</B>
6632
6633 <DD>
6634 This determines when the user is queried about viewing
6635 the number of possible completions
6636 generated by the <B>possible-completions</B> command.
6637 It may be set to any integer value greater than or equal to
6638 zero. If the number of possible completions is greater than
6639 or equal to the value of this variable, the user is asked whether
6640 or not he wishes to view them; otherwise they are simply listed
6641 on the terminal.
6642 <DT><B>convert-meta (On)</B>
6643
6644 <DD>
6645 If set to <B>On</B>, readline will convert characters with the
6646 eighth bit set to an ASCII key sequence
6647 by stripping the eighth bit and prefixing an
6648 escape character (in effect, using escape as the <I>meta prefix</I>).
6649 <DT><B>disable-completion (Off)</B>
6650
6651 <DD>
6652 If set to <B>On</B>, readline will inhibit word completion. Completion
6653 characters will be inserted into the line as if they had been
6654 mapped to <B>self-insert</B>.
6655 <DT><B>editing-mode (emacs)</B>
6656
6657 <DD>
6658 Controls whether readline begins with a set of key bindings similar
6659 to <I>Emacs</I> or <I>vi</I>.
6660 <B>editing-mode</B>
6661
6662 can be set to either
6663 <B>emacs</B>
6664
6665 or
6666 <B>vi</B>.
6667
6668 <DT><B>echo-control-characters (On)</B>
6669
6670 <DD>
6671 When set to <B>On</B>, on operating systems that indicate they support it,
6672 readline echoes a character corresponding to a signal generated from the
6673 keyboard.
6674 <DT><B>enable-keypad (Off)</B>
6675
6676 <DD>
6677 When set to <B>On</B>, readline will try to enable the application
6678 keypad when it is called. Some systems need this to enable the
6679 arrow keys.
6680 <DT><B>enable-meta-key (On)</B>
6681
6682 <DD>
6683 When set to <B>On</B>, readline will try to enable any meta modifier
6684 key the terminal claims to support when it is called. On many terminals,
6685 the meta key is used to send eight-bit characters.
6686 <DT><B>expand-tilde (Off)</B>
6687
6688 <DD>
6689 If set to <B>On</B>, tilde expansion is performed when readline
6690 attempts word completion.
6691 <DT><B>history-preserve-point (Off)</B>
6692
6693 <DD>
6694 If set to <B>On</B>, the history code attempts to place point at the
6695 same location on each history line retrieved with <B>previous-history</B>
6696 or <B>next-history</B>.
6697 <DT><B>history-size (0)</B>
6698
6699 <DD>
6700 Set the maximum number of history entries saved in the history list. If
6701 set to zero, the number of entries in the history list is not limited.
6702 <DT><B>horizontal-scroll-mode (Off)</B>
6703
6704 <DD>
6705 When set to <B>On</B>, makes readline use a single line for display,
6706 scrolling the input horizontally on a single screen line when it
6707 becomes longer than the screen width rather than wrapping to a new line.
6708 <DT><B>input-meta (Off)</B>
6709
6710 <DD>
6711 If set to <B>On</B>, readline will enable eight-bit input (that is,
6712 it will not strip the high bit from the characters it reads),
6713 regardless of what the terminal claims it can support. The name
6714 <B>meta-flag</B>
6715
6716 is a synonym for this variable.
6717 <DT><B>isearch-terminators (``C-[C-J'')</B>
6718
6719 <DD>
6720 The string of characters that should terminate an incremental
6721 search without subsequently executing the character as a command.
6722 If this variable has not been given a value, the characters
6723 <I>ESC</I> and <I>C-J</I> will terminate an incremental search.
6724 <DT><B>keymap (emacs)</B>
6725
6726 <DD>
6727 Set the current readline keymap. The set of valid keymap names is
6728 <I>emacs, emacs-standard, emacs-meta, emacs-ctlx, vi,
6729 vi-command</I>, and
6730 <I>vi-insert</I>.
6731
6732 <I>vi</I> is equivalent to <I>vi-command</I>; <I>emacs</I> is
6733 equivalent to <I>emacs-standard</I>. The default value is
6734 <I>emacs</I>;
6735
6736 the value of
6737 <B>editing-mode</B>
6738
6739 also affects the default keymap.
6740 <DT><B>mark-directories (On)</B>
6741
6742 <DD>
6743 If set to <B>On</B>, completed directory names have a slash
6744 appended.
6745 <DT><B>mark-modified-lines (Off)</B>
6746
6747 <DD>
6748 If set to <B>On</B>, history lines that have been modified are displayed
6749 with a preceding asterisk (<B>*</B>).
6750 <DT><B>mark-symlinked-directories (Off)</B>
6751
6752 <DD>
6753 If set to <B>On</B>, completed names which are symbolic links to directories
6754 have a slash appended (subject to the value of
6755 <B>mark-directories</B>).
6756 <DT><B>match-hidden-files (On)</B>
6757
6758 <DD>
6759 This variable, when set to <B>On</B>, causes readline to match files whose
6760 names begin with a `.' (hidden files) when performing filename
6761 completion.
6762 If set to <B>Off</B>, the leading `.' must be
6763 supplied by the user in the filename to be completed.
6764 <DT><B>menu-complete-display-prefix (Off)</B>
6765
6766 <DD>
6767 If set to <B>On</B>, menu completion displays the common prefix of the
6768 list of possible completions (which may be empty) before cycling through
6769 the list.
6770 <DT><B>output-meta (Off)</B>
6771
6772 <DD>
6773 If set to <B>On</B>, readline will display characters with the
6774 eighth bit set directly rather than as a meta-prefixed escape
6775 sequence.
6776 <DT><B>page-completions (On)</B>
6777
6778 <DD>
6779 If set to <B>On</B>, readline uses an internal <I>more</I>-like pager
6780 to display a screenful of possible completions at a time.
6781 <DT><B>print-completions-horizontally (Off)</B>
6782
6783 <DD>
6784 If set to <B>On</B>, readline will display completions with matches
6785 sorted horizontally in alphabetical order, rather than down the screen.
6786 <DT><B>revert-all-at-newline (Off)</B>
6787
6788 <DD>
6789 If set to <B>On</B>, readline will undo all changes to history lines
6790 before returning when <B>accept-line</B> is executed. By default,
6791 history lines may be modified and retain individual undo lists across
6792 calls to <B>readline</B>.
6793 <DT><B>show-all-if-ambiguous (Off)</B>
6794
6795 <DD>
6796 This alters the default behavior of the completion functions. If
6797 set to
6798 <B>On</B>,
6799
6800 words which have more than one possible completion cause the
6801 matches to be listed immediately instead of ringing the bell.
6802 <DT><B>show-all-if-unmodified (Off)</B>
6803
6804 <DD>
6805 This alters the default behavior of the completion functions in
6806 a fashion similar to <B>show-all-if-ambiguous</B>.
6807 If set to
6808 <B>On</B>,
6809
6810 words which have more than one possible completion without any
6811 possible partial completion (the possible completions don't share
6812 a common prefix) cause the matches to be listed immediately instead
6813 of ringing the bell.
6814 <DT><B>skip-completed-text (Off)</B>
6815
6816 <DD>
6817 If set to <B>On</B>, this alters the default completion behavior when
6818 inserting a single match into the line. It's only active when
6819 performing completion in the middle of a word. If enabled, readline
6820 does not insert characters from the completion that match characters
6821 after point in the word being completed, so portions of the word
6822 following the cursor are not duplicated.
6823 <DT><B>visible-stats (Off)</B>
6824
6825 <DD>
6826 If set to <B>On</B>, a character denoting a file's type as reported
6827 by <I>stat</I>(2) is appended to the filename when listing possible
6828 completions.
6829
6830 </DL>
6831 <A NAME="lbCK">&nbsp;</A>
6832 <H4>Readline Conditional Constructs</H4>
6833
6834 <P>
6835
6836 Readline implements a facility similar in spirit to the conditional
6837 compilation features of the C preprocessor which allows key
6838 bindings and variable settings to be performed as the result
6839 of tests. There are four parser directives used.
6840 <DL COMPACT>
6841 <DT><B>$if</B><DD>
6842 The
6843 <B>$if</B>
6844
6845 construct allows bindings to be made based on the
6846 editing mode, the terminal being used, or the application using
6847 readline. The text of the test extends to the end of the line;
6848 no characters are required to isolate it.
6849 <DL COMPACT><DT><DD>
6850 <DL COMPACT>
6851 <DT><B>mode</B><DD>
6852 The <B>mode=</B> form of the <B>$if</B> directive is used to test
6853 whether readline is in emacs or vi mode.
6854 This may be used in conjunction
6855 with the <B>set keymap</B> command, for instance, to set bindings in
6856 the <I>emacs-standard</I> and <I>emacs-ctlx</I> keymaps only if
6857 readline is starting out in emacs mode.
6858 <DT><B>term</B><DD>
6859 The <B>term=</B> form may be used to include terminal-specific
6860 key bindings, perhaps to bind the key sequences output by the
6861 terminal's function keys. The word on the right side of the
6862 <B>=</B>
6863
6864 is tested against the both full name of the terminal and the portion
6865 of the terminal name before the first <B>-</B>. This allows
6866 <I>sun</I>
6867
6868 to match both
6869 <I>sun</I>
6870
6871 and
6872 <I>sun-cmd</I>,
6873
6874 for instance.
6875 <DT><B>application</B><DD>
6876 The <B>application</B> construct is used to include
6877 application-specific settings. Each program using the readline
6878 library sets the <I>application name</I>, and an initialization
6879 file can test for a particular value.
6880 This could be used to bind key sequences to functions useful for
6881 a specific program. For instance, the following command adds a
6882 key sequence that quotes the current or previous word in <B>bash</B>:
6883 <P>
6884 <DL COMPACT><DT><DD>
6885 <PRE>
6886 <B>$if</B> Bash
6887 # Quote the current or previous word
6888 &quot;\C-xq&quot;: &quot;\eb\&quot;\ef\&quot;&quot;
6889 <B>$endif</B>
6890 </PRE>
6891
6892 </DL>
6893
6894 </DL></DL>
6895
6896 <DT><B>$endif</B><DD>
6897 This command, as seen in the previous example, terminates an
6898 <B>$if</B> command.
6899 <DT><B>$else</B><DD>
6900 Commands in this branch of the <B>$if</B> directive are executed if
6901 the test fails.
6902 <DT><B>$include</B><DD>
6903 This directive takes a single filename as an argument and reads commands
6904 and bindings from that file. For example, the following directive
6905 would read <A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>:
6906 <P>
6907 <DL COMPACT><DT><DD>
6908 <PRE>
6909 <B>$include</B> <A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>
6910 </PRE>
6911
6912 </DL>
6913
6914 </DL>
6915 <A NAME="lbCL">&nbsp;</A>
6916 <H4>Searching</H4>
6917
6918 <P>
6919
6920 Readline provides commands for searching through the command history
6921 (see
6922 <FONT SIZE=-1><B>HISTORY</B>
6923
6924 </FONT>
6925 below) for lines containing a specified string.
6926 There are two search modes:
6927 <I>incremental</I>
6928
6929 and
6930 <I>non-incremental</I>.
6931
6932 <P>
6933
6934 Incremental searches begin before the user has finished typing the
6935 search string.
6936 As each character of the search string is typed, readline displays
6937 the next entry from the history matching the string typed so far.
6938 An incremental search requires only as many characters as needed to
6939 find the desired history entry.
6940 The characters present in the value of the <B>isearch-terminators</B>
6941 variable are used to terminate an incremental search.
6942 If that variable has not been assigned a value the Escape and
6943 Control-J characters will terminate an incremental search.
6944 Control-G will abort an incremental search and restore the original
6945 line.
6946 When the search is terminated, the history entry containing the
6947 search string becomes the current line.
6948 <P>
6949
6950 To find other matching entries in the history list, type Control-S or
6951 Control-R as appropriate.
6952 This will search backward or forward in the history for the next
6953 entry matching the search string typed so far.
6954 Any other key sequence bound to a readline command will terminate
6955 the search and execute that command.
6956 For instance, a <I>newline</I> will terminate the search and accept
6957 the line, thereby executing the command from the history list.
6958 <P>
6959
6960 Readline remembers the last incremental search string. If two
6961 Control-Rs are typed without any intervening characters defining a
6962 new search string, any remembered search string is used.
6963 <P>
6964
6965 Non-incremental searches read the entire search string before starting
6966 to search for matching history lines. The search string may be
6967 typed by the user or be part of the contents of the current line.
6968 <A NAME="lbCM">&nbsp;</A>
6969 <H4>Readline Command Names</H4>
6970
6971 <P>
6972
6973 The following is a list of the names of the commands and the default
6974 key sequences to which they are bound.
6975 Command names without an accompanying key sequence are unbound by default.
6976 In the following descriptions, <I>point</I> refers to the current cursor
6977 position, and <I>mark</I> refers to a cursor position saved by the
6978 <B>set-mark</B> command.
6979 The text between the point and mark is referred to as the <I>region</I>.
6980 <A NAME="lbCN">&nbsp;</A>
6981 <H4>Commands for Moving</H4>
6982
6983 <P>
6984
6985
6986 <DL COMPACT>
6987 <DT><B>beginning-of-line (C-a)</B>
6988
6989 <DD>
6990 Move to the start of the current line.
6991 <DT><B>end-of-line (C-e)</B>
6992
6993 <DD>
6994 Move to the end of the line.
6995 <DT><B>forward-char (C-f)</B>
6996
6997 <DD>
6998 Move forward a character.
6999 <DT><B>backward-char (C-b)</B>
7000
7001 <DD>
7002 Move back a character.
7003 <DT><B>forward-word (M-f)</B>
7004
7005 <DD>
7006 Move forward to the end of the next word. Words are composed of
7007 alphanumeric characters (letters and digits).
7008 <DT><B>backward-word (M-b)</B>
7009
7010 <DD>
7011 Move back to the start of the current or previous word.
7012 Words are composed of alphanumeric characters (letters and digits).
7013 <DT><B>shell-forward-word</B>
7014
7015 <DD>
7016 Move forward to the end of the next word.
7017 Words are delimited by non-quoted shell metacharacters.
7018 <DT><B>shell-backward-word</B>
7019
7020 <DD>
7021 Move back to the start of the current or previous word.
7022 Words are delimited by non-quoted shell metacharacters.
7023 <DT><B>clear-screen (C-l)</B>
7024
7025 <DD>
7026 Clear the screen leaving the current line at the top of the screen.
7027 With an argument, refresh the current line without clearing the
7028 screen.
7029 <DT><B>redraw-current-line</B>
7030
7031 <DD>
7032 Refresh the current line.
7033
7034 </DL>
7035 <A NAME="lbCO">&nbsp;</A>
7036 <H4>Commands for Manipulating the History</H4>
7037
7038 <P>
7039
7040
7041 <DL COMPACT>
7042 <DT><B>accept-line (Newline, Return)</B>
7043
7044 <DD>
7045 Accept the line regardless of where the cursor is. If this line is
7046 non-empty, add it to the history list according to the state of the
7047 <FONT SIZE=-1><B>HISTCONTROL</B>
7048
7049 </FONT>
7050 variable. If the line is a modified history
7051 line, then restore the history line to its original state.
7052 <DT><B>previous-history (C-p)</B>
7053
7054 <DD>
7055 Fetch the previous command from the history list, moving back in
7056 the list.
7057 <DT><B>next-history (C-n)</B>
7058
7059 <DD>
7060 Fetch the next command from the history list, moving forward in the
7061 list.
7062 <DT><B>beginning-of-history (M-&lt;)</B>
7063
7064 <DD>
7065 Move to the first line in the history.
7066 <DT><B>end-of-history (M-&gt;)</B>
7067
7068 <DD>
7069 Move to the end of the input history, i.e., the line currently being
7070 entered.
7071 <DT><B>reverse-search-history (C-r)</B>
7072
7073 <DD>
7074 Search backward starting at the current line and moving `up' through
7075 the history as necessary. This is an incremental search.
7076 <DT><B>forward-search-history (C-s)</B>
7077
7078 <DD>
7079 Search forward starting at the current line and moving `down' through
7080 the history as necessary. This is an incremental search.
7081 <DT><B>non-incremental-reverse-search-history (M-p)</B>
7082
7083 <DD>
7084 Search backward through the history starting at the current line
7085 using a non-incremental search for a string supplied by the user.
7086 <DT><B>non-incremental-forward-search-history (M-n)</B>
7087
7088 <DD>
7089 Search forward through the history using a non-incremental search for
7090 a string supplied by the user.
7091 <DT><B>history-search-forward</B>
7092
7093 <DD>
7094 Search forward through the history for the string of characters
7095 between the start of the current line and the point.
7096 This is a non-incremental search.
7097 <DT><B>history-search-backward</B>
7098
7099 <DD>
7100 Search backward through the history for the string of characters
7101 between the start of the current line and the point.
7102 This is a non-incremental search.
7103 <DT><B>yank-nth-arg (M-C-y)</B>
7104
7105 <DD>
7106 Insert the first argument to the previous command (usually
7107 the second word on the previous line) at point.
7108 With an argument
7109 <I>n</I>,
7110
7111 insert the <I>n</I>th word from the previous command (the words
7112 in the previous command begin with word 0). A negative argument
7113 inserts the <I>n</I>th word from the end of the previous command.
7114 Once the argument <I>n</I> is computed, the argument is extracted
7115 as if the &quot;!<I>n</I>&quot; history expansion had been specified.
7116 <DT><B>yank-last-arg (M-., M-_)</B>
7117
7118 <DD>
7119 Insert the last argument to the previous command (the last word of
7120 the previous history entry). With an argument,
7121 behave exactly like <B>yank-nth-arg</B>.
7122 Successive calls to <B>yank-last-arg</B> move back through the history
7123 list, inserting the last argument of each line in turn.
7124 The history expansion facilities are used to extract the last argument,
7125 as if the &quot;!$&quot; history expansion had been specified.
7126 <DT><B>shell-expand-line (M-C-e)</B>
7127
7128 <DD>
7129 Expand the line as the shell does. This
7130 performs alias and history expansion as well as all of the shell
7131 word expansions. See
7132 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
7133
7134 </FONT>
7135 below for a description of history expansion.
7136 <DT><B>history-expand-line (M-^)</B>
7137
7138 <DD>
7139 Perform history expansion on the current line.
7140 See
7141 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
7142
7143 </FONT>
7144 below for a description of history expansion.
7145 <DT><B>magic-space</B>
7146
7147 <DD>
7148 Perform history expansion on the current line and insert a space.
7149 See
7150 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
7151
7152 </FONT>
7153 below for a description of history expansion.
7154 <DT><B>alias-expand-line</B>
7155
7156 <DD>
7157 Perform alias expansion on the current line.
7158 See
7159 <FONT SIZE=-1><B>ALIASES</B>
7160
7161 </FONT>
7162 above for a description of alias expansion.
7163 <DT><B>history-and-alias-expand-line</B>
7164
7165 <DD>
7166 Perform history and alias expansion on the current line.
7167 <DT><B>insert-last-argument (M-., M-_)</B>
7168
7169 <DD>
7170 A synonym for <B>yank-last-arg</B>.
7171 <DT><B>operate-and-get-next (C-o)</B>
7172
7173 <DD>
7174 Accept the current line for execution and fetch the next line
7175 relative to the current line from the history for editing. Any
7176 argument is ignored.
7177 <DT><B>edit-and-execute-command (C-xC-e)</B>
7178
7179 <DD>
7180 Invoke an editor on the current command line, and execute the result as shell
7181 commands.
7182 <B>Bash</B> attempts to invoke
7183 <FONT SIZE=-1><B>$VISUAL</B>,
7184
7185 </FONT>
7186 <FONT SIZE=-1><B>$EDITOR</B>,
7187
7188 </FONT>
7189 and <I>emacs</I> as the editor, in that order.
7190
7191 </DL>
7192 <A NAME="lbCP">&nbsp;</A>
7193 <H4>Commands for Changing Text</H4>
7194
7195 <P>
7196
7197
7198 <DL COMPACT>
7199 <DT><B>delete-char (C-d)</B>
7200
7201 <DD>
7202 Delete the character at point. If point is at the
7203 beginning of the line, there are no characters in the line, and
7204 the last character typed was not bound to <B>delete-char</B>,
7205 then return
7206 <FONT SIZE=-1><B>EOF</B>.
7207
7208 </FONT>
7209 <DT><B>backward-delete-char (Rubout)</B>
7210
7211 <DD>
7212 Delete the character behind the cursor. When given a numeric argument,
7213 save the deleted text on the kill ring.
7214 <DT><B>forward-backward-delete-char</B>
7215
7216 <DD>
7217 Delete the character under the cursor, unless the cursor is at the
7218 end of the line, in which case the character behind the cursor is
7219 deleted.
7220 <DT><B>quoted-insert (C-q, C-v)</B>
7221
7222 <DD>
7223 Add the next character typed to the line verbatim. This is
7224 how to insert characters like <B>C-q</B>, for example.
7225 <DT><B>tab-insert (C-v TAB)</B>
7226
7227 <DD>
7228 Insert a tab character.
7229 <DT><B>self-insert (a,&nbsp;b,&nbsp;A,&nbsp;1,&nbsp;!,&nbsp;...)</B>
7230
7231 <DD>
7232 Insert the character typed.
7233 <DT><B>transpose-chars (C-t)</B>
7234
7235 <DD>
7236 Drag the character before point forward over the character at point,
7237 moving point forward as well.
7238 If point is at the end of the line, then this transposes
7239 the two characters before point.
7240 Negative arguments have no effect.
7241 <DT><B>transpose-words (M-t)</B>
7242
7243 <DD>
7244 Drag the word before point past the word after point,
7245 moving point over that word as well.
7246 If point is at the end of the line, this transposes
7247 the last two words on the line.
7248 <DT><B>upcase-word (M-u)</B>
7249
7250 <DD>
7251 Uppercase the current (or following) word. With a negative argument,
7252 uppercase the previous word, but do not move point.
7253 <DT><B>downcase-word (M-l)</B>
7254
7255 <DD>
7256 Lowercase the current (or following) word. With a negative argument,
7257 lowercase the previous word, but do not move point.
7258 <DT><B>capitalize-word (M-c)</B>
7259
7260 <DD>
7261 Capitalize the current (or following) word. With a negative argument,
7262 capitalize the previous word, but do not move point.
7263 <DT><B>overwrite-mode</B>
7264
7265 <DD>
7266 Toggle overwrite mode. With an explicit positive numeric argument,
7267 switches to overwrite mode. With an explicit non-positive numeric
7268 argument, switches to insert mode. This command affects only
7269 <B>emacs</B> mode; <B>vi</B> mode does overwrite differently.
7270 Each call to <I>readline()</I> starts in insert mode.
7271 In overwrite mode, characters bound to <B>self-insert</B> replace
7272 the text at point rather than pushing the text to the right.
7273 Characters bound to <B>backward-delete-char</B> replace the character
7274 before point with a space. By default, this command is unbound.
7275
7276 </DL>
7277 <A NAME="lbCQ">&nbsp;</A>
7278 <H4>Killing and Yanking</H4>
7279
7280 <P>
7281
7282
7283 <DL COMPACT>
7284 <DT><B>kill-line (C-k)</B>
7285
7286 <DD>
7287 Kill the text from point to the end of the line.
7288 <DT><B>backward-kill-line (C-x Rubout)</B>
7289
7290 <DD>
7291 Kill backward to the beginning of the line.
7292 <DT><B>unix-line-discard (C-u)</B>
7293
7294 <DD>
7295 Kill backward from point to the beginning of the line.
7296 The killed text is saved on the kill-ring.
7297
7298 <DT><B>kill-whole-line</B>
7299
7300 <DD>
7301 Kill all characters on the current line, no matter where point is.
7302 <DT><B>kill-word (M-d)</B>
7303
7304 <DD>
7305 Kill from point to the end of the current word, or if between
7306 words, to the end of the next word.
7307 Word boundaries are the same as those used by <B>forward-word</B>.
7308 <DT><B>backward-kill-word (M-Rubout)</B>
7309
7310 <DD>
7311 Kill the word behind point.
7312 Word boundaries are the same as those used by <B>backward-word</B>.
7313 <DT><B>shell-kill-word (M-d)</B>
7314
7315 <DD>
7316 Kill from point to the end of the current word, or if between
7317 words, to the end of the next word.
7318 Word boundaries are the same as those used by <B>shell-forward-word</B>.
7319 <DT><B>shell-backward-kill-word (M-Rubout)</B>
7320
7321 <DD>
7322 Kill the word behind point.
7323 Word boundaries are the same as those used by <B>shell-backward-word</B>.
7324 <DT><B>unix-word-rubout (C-w)</B>
7325
7326 <DD>
7327 Kill the word behind point, using white space as a word boundary.
7328 The killed text is saved on the kill-ring.
7329 <DT><B>unix-filename-rubout</B>
7330
7331 <DD>
7332 Kill the word behind point, using white space and the slash character
7333 as the word boundaries.
7334 The killed text is saved on the kill-ring.
7335 <DT><B>delete-horizontal-space (M-\)</B>
7336
7337 <DD>
7338 Delete all spaces and tabs around point.
7339 <DT><B>kill-region</B>
7340
7341 <DD>
7342 Kill the text in the current region.
7343 <DT><B>copy-region-as-kill</B>
7344
7345 <DD>
7346 Copy the text in the region to the kill buffer.
7347 <DT><B>copy-backward-word</B>
7348
7349 <DD>
7350 Copy the word before point to the kill buffer.
7351 The word boundaries are the same as <B>backward-word</B>.
7352 <DT><B>copy-forward-word</B>
7353
7354 <DD>
7355 Copy the word following point to the kill buffer.
7356 The word boundaries are the same as <B>forward-word</B>.
7357 <DT><B>yank (C-y)</B>
7358
7359 <DD>
7360 Yank the top of the kill ring into the buffer at point.
7361 <DT><B>yank-pop (M-y)</B>
7362
7363 <DD>
7364 Rotate the kill ring, and yank the new top. Only works following
7365 <B>yank</B>
7366
7367 or
7368 <B>yank-pop</B>.
7369
7370
7371 </DL>
7372 <A NAME="lbCR">&nbsp;</A>
7373 <H4>Numeric Arguments</H4>
7374
7375 <P>
7376
7377
7378 <DL COMPACT>
7379 <DT><B>digit-argument (M-0, M-1, ..., M--)</B>
7380
7381 <DD>
7382 Add this digit to the argument already accumulating, or start a new
7383 argument. M-- starts a negative argument.
7384 <DT><B>universal-argument</B>
7385
7386 <DD>
7387 This is another way to specify an argument.
7388 If this command is followed by one or more digits, optionally with a
7389 leading minus sign, those digits define the argument.
7390 If the command is followed by digits, executing
7391 <B>universal-argument</B>
7392
7393 again ends the numeric argument, but is otherwise ignored.
7394 As a special case, if this command is immediately followed by a
7395 character that is neither a digit or minus sign, the argument count
7396 for the next command is multiplied by four.
7397 The argument count is initially one, so executing this function the
7398 first time makes the argument count four, a second time makes the
7399 argument count sixteen, and so on.
7400
7401 </DL>
7402 <A NAME="lbCS">&nbsp;</A>
7403 <H4>Completing</H4>
7404
7405 <P>
7406
7407
7408 <DL COMPACT>
7409 <DT><B>complete (TAB)</B>
7410
7411 <DD>
7412 Attempt to perform completion on the text before point.
7413 <B>Bash</B>
7414
7415 attempts completion treating the text as a variable (if the
7416 text begins with <B>$</B>), username (if the text begins with
7417 <B>~</B>), hostname (if the text begins with <B>@</B>), or
7418 command (including aliases and functions) in turn. If none
7419 of these produces a match, filename completion is attempted.
7420 <DT><B>possible-completions (M-?)</B>
7421
7422 <DD>
7423 List the possible completions of the text before point.
7424 <DT><B>insert-completions (M-*)</B>
7425
7426 <DD>
7427 Insert all completions of the text before point
7428 that would have been generated by
7429 <B>possible-completions</B>.
7430 <DT><B>menu-complete</B>
7431
7432 <DD>
7433 Similar to <B>complete</B>, but replaces the word to be completed
7434 with a single match from the list of possible completions.
7435 Repeated execution of <B>menu-complete</B> steps through the list
7436 of possible completions, inserting each match in turn.
7437 At the end of the list of completions, the bell is rung
7438 (subject to the setting of <B>bell-style</B>)
7439 and the original text is restored.
7440 An argument of <I>n</I> moves <I>n</I> positions forward in the list
7441 of matches; a negative argument may be used to move backward
7442 through the list.
7443 This command is intended to be bound to <B>TAB</B>, but is unbound
7444 by default.
7445 <DT><B>menu-complete-backward</B>
7446
7447 <DD>
7448 Identical to <B>menu-complete</B>, but moves backward through the list
7449 of possible completions, as if <B>menu-complete</B> had been given a
7450 negative argument. This command is unbound by default.
7451 <DT><B>delete-char-or-list</B>
7452
7453 <DD>
7454 Deletes the character under the cursor if not at the beginning or
7455 end of the line (like <B>delete-char</B>).
7456 If at the end of the line, behaves identically to
7457 <B>possible-completions</B>.
7458 This command is unbound by default.
7459 <DT><B>complete-filename (M-/)</B>
7460
7461 <DD>
7462 Attempt filename completion on the text before point.
7463 <DT><B>possible-filename-completions (C-x /)</B>
7464
7465 <DD>
7466 List the possible completions of the text before point,
7467 treating it as a filename.
7468 <DT><B>complete-username (M-~)</B>
7469
7470 <DD>
7471 Attempt completion on the text before point, treating
7472 it as a username.
7473 <DT><B>possible-username-completions (C-x ~)</B>
7474
7475 <DD>
7476 List the possible completions of the text before point,
7477 treating it as a username.
7478 <DT><B>complete-variable (M-$)</B>
7479
7480 <DD>
7481 Attempt completion on the text before point, treating
7482 it as a shell variable.
7483 <DT><B>possible-variable-completions (C-x $)</B>
7484
7485 <DD>
7486 List the possible completions of the text before point,
7487 treating it as a shell variable.
7488 <DT><B>complete-hostname (M-@)</B>
7489
7490 <DD>
7491 Attempt completion on the text before point, treating
7492 it as a hostname.
7493 <DT><B>possible-hostname-completions (C-x @)</B>
7494
7495 <DD>
7496 List the possible completions of the text before point,
7497 treating it as a hostname.
7498 <DT><B>complete-command (M-!)</B>
7499
7500 <DD>
7501 Attempt completion on the text before point, treating
7502 it as a command name. Command completion attempts to
7503 match the text against aliases, reserved words, shell
7504 functions, shell builtins, and finally executable filenames,
7505 in that order.
7506 <DT><B>possible-command-completions (C-x !)</B>
7507
7508 <DD>
7509 List the possible completions of the text before point,
7510 treating it as a command name.
7511 <DT><B>dynamic-complete-history (M-TAB)</B>
7512
7513 <DD>
7514 Attempt completion on the text before point, comparing
7515 the text against lines from the history list for possible
7516 completion matches.
7517 <DT><B>dabbrev-expand</B>
7518
7519 <DD>
7520 Attempt menu completion on the text before point, comparing
7521 the text against lines from the history list for possible
7522 completion matches.
7523 <DT><B>complete-into-braces (M-{)</B>
7524
7525 <DD>
7526 Perform filename completion and insert the list of possible completions
7527 enclosed within braces so the list is available to the shell (see
7528 <B>Brace Expansion</B>
7529
7530 above).
7531
7532 </DL>
7533 <A NAME="lbCT">&nbsp;</A>
7534 <H4>Keyboard Macros</H4>
7535
7536 <P>
7537
7538
7539 <DL COMPACT>
7540 <DT><B>start-kbd-macro (C-x ()</B>
7541
7542 <DD>
7543 Begin saving the characters typed into the current keyboard macro.
7544 <DT><B>end-kbd-macro (C-x ))</B>
7545
7546 <DD>
7547 Stop saving the characters typed into the current keyboard macro
7548 and store the definition.
7549 <DT><B>call-last-kbd-macro (C-x e)</B>
7550
7551 <DD>
7552 Re-execute the last keyboard macro defined, by making the characters
7553 in the macro appear as if typed at the keyboard.
7554
7555 </DL>
7556 <A NAME="lbCU">&nbsp;</A>
7557 <H4>Miscellaneous</H4>
7558
7559 <P>
7560
7561
7562 <DL COMPACT>
7563 <DT><B>re-read-init-file (C-x C-r)</B>
7564
7565 <DD>
7566 Read in the contents of the <I>inputrc</I> file, and incorporate
7567 any bindings or variable assignments found there.
7568 <DT><B>abort (C-g)</B>
7569
7570 <DD>
7571 Abort the current editing command and
7572 ring the terminal's bell (subject to the setting of
7573 <B>bell-style</B>).
7574
7575 <DT><B>do-uppercase-version (M-a, M-b, M-</B><I>x</I>, ...)
7576
7577 <DD>
7578 If the metafied character <I>x</I> is lowercase, run the command
7579 that is bound to the corresponding uppercase character.
7580 <DT><B>prefix-meta (ESC)</B>
7581
7582 <DD>
7583 Metafy the next character typed.
7584 <FONT SIZE=-1><B>ESC</B>
7585
7586 </FONT>
7587 <B>f</B>
7588
7589 is equivalent to
7590 <B>Meta-f</B>.
7591
7592 <DT><B>undo (C-_, C-x C-u)</B>
7593
7594 <DD>
7595 Incremental undo, separately remembered for each line.
7596 <DT><B>revert-line (M-r)</B>
7597
7598 <DD>
7599 Undo all changes made to this line. This is like executing the
7600 <B>undo</B>
7601
7602 command enough times to return the line to its initial state.
7603 <DT><B>tilde-expand (M-&amp;)</B>
7604
7605 <DD>
7606 Perform tilde expansion on the current word.
7607 <DT><B>set-mark (C-@, M-&lt;space&gt;)</B>
7608
7609 <DD>
7610 Set the mark to the point. If a
7611 numeric argument is supplied, the mark is set to that position.
7612 <DT><B>exchange-point-and-mark (C-x C-x)</B>
7613
7614 <DD>
7615 Swap the point with the mark. The current cursor position is set to
7616 the saved position, and the old cursor position is saved as the mark.
7617 <DT><B>character-search (C-])</B>
7618
7619 <DD>
7620 A character is read and point is moved to the next occurrence of that
7621 character. A negative count searches for previous occurrences.
7622 <DT><B>character-search-backward (M-C-])</B>
7623
7624 <DD>
7625 A character is read and point is moved to the previous occurrence of that
7626 character. A negative count searches for subsequent occurrences.
7627 <DT><B>skip-csi-sequence</B>
7628
7629 <DD>
7630 Read enough characters to consume a multi-key sequence such as those
7631 defined for keys like Home and End. Such sequences begin with a
7632 Control Sequence Indicator (CSI), usually ESC-[. If this sequence is
7633 bound to &quot;\[&quot;, keys producing such sequences will have no effect
7634 unless explicitly bound to a readline command, instead of inserting
7635 stray characters into the editing buffer. This is unbound by default,
7636 but usually bound to ESC-[.
7637 <DT><B>insert-comment (M-#)</B>
7638
7639 <DD>
7640 Without a numeric argument, the value of the readline
7641 <B>comment-begin</B>
7642
7643 variable is inserted at the beginning of the current line.
7644 If a numeric argument is supplied, this command acts as a toggle: if
7645 the characters at the beginning of the line do not match the value
7646 of <B>comment-begin</B>, the value is inserted, otherwise
7647 the characters in <B>comment-begin</B> are deleted from the beginning of
7648 the line.
7649 In either case, the line is accepted as if a newline had been typed.
7650 The default value of
7651 <B>comment-begin</B> causes this command to make the current line
7652 a shell comment.
7653 If a numeric argument causes the comment character to be removed, the line
7654 will be executed by the shell.
7655 <DT><B>glob-complete-word (M-g)</B>
7656
7657 <DD>
7658 The word before point is treated as a pattern for pathname expansion,
7659 with an asterisk implicitly appended. This pattern is used to
7660 generate a list of matching file names for possible completions.
7661 <DT><B>glob-expand-word (C-x *)</B>
7662
7663 <DD>
7664 The word before point is treated as a pattern for pathname expansion,
7665 and the list of matching file names is inserted, replacing the word.
7666 If a numeric argument is supplied, an asterisk is appended before
7667 pathname expansion.
7668 <DT><B>glob-list-expansions (C-x g)</B>
7669
7670 <DD>
7671 The list of expansions that would have been generated by
7672 <B>glob-expand-word</B>
7673
7674 is displayed, and the line is redrawn.
7675 If a numeric argument is supplied, an asterisk is appended before
7676 pathname expansion.
7677 <DT><B>dump-functions</B>
7678
7679 <DD>
7680 Print all of the functions and their key bindings to the
7681 readline output stream. If a numeric argument is supplied,
7682 the output is formatted in such a way that it can be made part
7683 of an <I>inputrc</I> file.
7684 <DT><B>dump-variables</B>
7685
7686 <DD>
7687 Print all of the settable readline variables and their values to the
7688 readline output stream. If a numeric argument is supplied,
7689 the output is formatted in such a way that it can be made part
7690 of an <I>inputrc</I> file.
7691 <DT><B>dump-macros</B>
7692
7693 <DD>
7694 Print all of the readline key sequences bound to macros and the
7695 strings they output. If a numeric argument is supplied,
7696 the output is formatted in such a way that it can be made part
7697 of an <I>inputrc</I> file.
7698 <DT><B>display-shell-version (C-x C-v)</B>
7699
7700 <DD>
7701 Display version information about the current instance of
7702 <B>bash</B>.
7703
7704
7705 </DL>
7706 <A NAME="lbCV">&nbsp;</A>
7707 <H4>Programmable Completion</H4>
7708
7709 <P>
7710
7711 When word completion is attempted for an argument to a command for
7712 which a completion specification (a <I>compspec</I>) has been defined
7713 using the <B>complete</B> builtin (see
7714 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
7715
7716 </FONT>
7717 below), the programmable completion facilities are invoked.
7718 <P>
7719
7720 First, the command name is identified.
7721 If the command word is the empty string (completion attempted at the
7722 beginning of an empty line), any compspec defined with
7723 the <B>-E</B> option to <B>complete</B> is used.
7724 If a compspec has been defined for that command, the
7725 compspec is used to generate the list of possible completions for the word.
7726 If the command word is a full pathname, a compspec for the full
7727 pathname is searched for first.
7728 If no compspec is found for the full pathname, an attempt is made to
7729 find a compspec for the portion following the final slash.
7730 If those searches do not result in a compspec, any compspec defined with
7731 the <B>-D</B> option to <B>complete</B> is used as the default.
7732 <P>
7733
7734 Once a compspec has been found, it is used to generate the list of
7735 matching words.
7736 If a compspec is not found, the default <B>bash</B> completion as
7737 described above under <B>Completing</B> is performed.
7738 <P>
7739
7740 First, the actions specified by the compspec are used.
7741 Only matches which are prefixed by the word being completed are
7742 returned.
7743 When the
7744 <B>-f</B>
7745
7746 or
7747 <B>-d</B>
7748
7749 option is used for filename or directory name completion, the shell
7750 variable
7751 <FONT SIZE=-1><B>FIGNORE</B>
7752
7753 </FONT>
7754 is used to filter the matches.
7755 <P>
7756
7757 Any completions specified by a pathname expansion pattern to the
7758 <B>-G</B> option are generated next.
7759 The words generated by the pattern need not match the word
7760 being completed.
7761 The
7762 <FONT SIZE=-1><B>GLOBIGNORE</B>
7763
7764 </FONT>
7765 shell variable is not used to filter the matches, but the
7766 <FONT SIZE=-1><B>FIGNORE</B>
7767
7768 </FONT>
7769 variable is used.
7770 <P>
7771
7772 Next, the string specified as the argument to the <B>-W</B> option
7773 is considered.
7774 The string is first split using the characters in the
7775 <FONT SIZE=-1><B>IFS</B>
7776
7777 </FONT>
7778 special variable as delimiters.
7779 Shell quoting is honored.
7780 Each word is then expanded using
7781 brace expansion, tilde expansion, parameter and variable expansion,
7782 command substitution, and arithmetic expansion,
7783 as described above under
7784 <FONT SIZE=-1><B>EXPANSION</B>.
7785
7786 </FONT>
7787 The results are split using the rules described above under
7788 <B>Word Splitting</B>.
7789 The results of the expansion are prefix-matched against the word being
7790 completed, and the matching words become the possible completions.
7791 <P>
7792
7793 After these matches have been generated, any shell function or command
7794 specified with the <B>-F</B> and <B>-C</B> options is invoked.
7795 When the command or function is invoked, the
7796 <FONT SIZE=-1><B>COMP_LINE</B>,
7797
7798 </FONT>
7799 <FONT SIZE=-1><B>COMP_POINT</B>,
7800
7801 </FONT>
7802 <FONT SIZE=-1><B>COMP_KEY</B>,
7803
7804 </FONT>
7805 and
7806 <FONT SIZE=-1><B>COMP_TYPE</B>
7807
7808 </FONT>
7809 variables are assigned values as described above under
7810 <B>Shell Variables</B>.
7811 If a shell function is being invoked, the
7812 <FONT SIZE=-1><B>COMP_WORDS</B>
7813
7814 </FONT>
7815 and
7816 <FONT SIZE=-1><B>COMP_CWORD</B>
7817
7818 </FONT>
7819 variables are also set.
7820 When the function or command is invoked, the first argument is the
7821 name of the command whose arguments are being completed, the
7822 second argument is the word being completed, and the third argument
7823 is the word preceding the word being completed on the current command line.
7824 No filtering of the generated completions against the word being completed
7825 is performed; the function or command has complete freedom in generating
7826 the matches.
7827 <P>
7828
7829 Any function specified with <B>-F</B> is invoked first.
7830 The function may use any of the shell facilities, including the
7831 <B>compgen</B> builtin described below, to generate the matches.
7832 It must put the possible completions in the
7833 <FONT SIZE=-1><B>COMPREPLY</B>
7834
7835 </FONT>
7836 array variable.
7837 <P>
7838
7839 Next, any command specified with the <B>-C</B> option is invoked
7840 in an environment equivalent to command substitution.
7841 It should print a list of completions, one per line, to the
7842 standard output.
7843 Backslash may be used to escape a newline, if necessary.
7844 <P>
7845
7846 After all of the possible completions are generated, any filter
7847 specified with the <B>-X</B> option is applied to the list.
7848 The filter is a pattern as used for pathname expansion; a <B>&amp;</B>
7849 in the pattern is replaced with the text of the word being completed.
7850 A literal <B>&amp;</B> may be escaped with a backslash; the backslash
7851 is removed before attempting a match.
7852 Any completion that matches the pattern will be removed from the list.
7853 A leading <B>!</B> negates the pattern; in this case any completion
7854 not matching the pattern will be removed.
7855 <P>
7856
7857 Finally, any prefix and suffix specified with the <B>-P</B> and <B>-S</B>
7858 options are added to each member of the completion list, and the result is
7859 returned to the readline completion code as the list of possible
7860 completions.
7861 <P>
7862
7863 If the previously-applied actions do not generate any matches, and the
7864 <B>-o dirnames</B> option was supplied to <B>complete</B> when the
7865 compspec was defined, directory name completion is attempted.
7866 <P>
7867
7868 If the <B>-o plusdirs</B> option was supplied to <B>complete</B> when the
7869 compspec was defined, directory name completion is attempted and any
7870 matches are added to the results of the other actions.
7871 <P>
7872
7873 By default, if a compspec is found, whatever it generates is returned
7874 to the completion code as the full set of possible completions.
7875 The default <B>bash</B> completions are not attempted, and the readline
7876 default of filename completion is disabled.
7877 If the <B>-o bashdefault</B> option was supplied to <B>complete</B> when
7878 the compspec was defined, the <B>bash</B> default completions are attempted
7879 if the compspec generates no matches.
7880 If the <B>-o default</B> option was supplied to <B>complete</B> when the
7881 compspec was defined, readline's default completion will be performed
7882 if the compspec (and, if attempted, the default <B>bash</B> completions)
7883 generate no matches.
7884 <P>
7885
7886 When a compspec indicates that directory name completion is desired,
7887 the programmable completion functions force readline to append a slash
7888 to completed names which are symbolic links to directories, subject to
7889 the value of the <B>mark-directories</B> readline variable, regardless
7890 of the setting of the <B>mark-symlinked-directories</B> readline variable.
7891 <P>
7892
7893 There is some support for dynamically modifying completions. This is
7894 most useful when used in combination with a default completion specified
7895 with <B>complete -D</B>.
7896 It's possible for shell functions executed as completion
7897 handlers to indicate that completion should be retried by returning an
7898 exit status of 124. If a shell function returns 124, and changes
7899 the compspec associated with the command on which completion is being
7900 attempted (supplied as the first argument when the function is executed),
7901 programmable completion restarts from the beginning, with an
7902 attempt to find a new compspec for that command. This allows a set of
7903 completions to be built dynamically as completion is attempted, rather than
7904 being loaded all at once.
7905 <P>
7906
7907 For instance, assuming that there is a library of compspecs, each kept in a
7908 file corresponding to the name of the command, the following default
7909 completion function would load completions dynamically:
7910 <P>
7911
7912 <TT>_completion_loader()
7913 <BR>
7914
7915 {
7916 <BR>
7917
7918 <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>
7919 <BR>
7920
7921 }
7922 <BR>
7923
7924 complete -D -F _completion_loader
7925 <BR>
7926
7927 </TT>
7928 <A NAME="lbCW">&nbsp;</A>
7929 <H3>HISTORY</H3>
7930
7931 When the
7932 <B>-o history</B>
7933
7934 option to the
7935 <B>set</B>
7936
7937 builtin is enabled, the shell provides access to the
7938 <I>command history</I>,
7939 the list of commands previously typed.
7940 The value of the
7941 <FONT SIZE=-1><B>HISTSIZE</B>
7942
7943 </FONT>
7944 variable is used as the
7945 number of commands to save in a history list.
7946 The text of the last
7947 <FONT SIZE=-1><B>HISTSIZE</B>
7948
7949 </FONT>
7950 commands (default 500) is saved. The shell
7951 stores each command in the history list prior to parameter and
7952 variable expansion (see
7953 <FONT SIZE=-1><B>EXPANSION</B>
7954
7955 </FONT>
7956 above) but after history expansion is performed, subject to the
7957 values of the shell variables
7958 <FONT SIZE=-1><B>HISTIGNORE</B>
7959
7960 </FONT>
7961 and
7962 <FONT SIZE=-1><B>HISTCONTROL</B>.
7963
7964 </FONT>
7965 <P>
7966
7967 On startup, the history is initialized from the file named by
7968 the variable
7969 <FONT SIZE=-1><B>HISTFILE</B>
7970
7971 </FONT>
7972 (default <A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>).
7973 The file named by the value of
7974 <FONT SIZE=-1><B>HISTFILE</B>
7975
7976 </FONT>
7977 is truncated, if necessary, to contain no more than
7978 the number of lines specified by the value of
7979 <FONT SIZE=-1><B>HISTFILESIZE</B>.
7980
7981 </FONT>
7982 When the history file is read,
7983 lines beginning with the history comment character followed immediately
7984 by a digit are interpreted as timestamps for the preceding history line.
7985 These timestamps are optionally displayed depending on the value of the
7986 <FONT SIZE=-1><B>HISTTIMEFORMAT</B>
7987
7988 </FONT>
7989 variable.
7990 When an interactive shell exits, the last
7991 <FONT SIZE=-1><B>$HISTSIZE</B>
7992
7993 </FONT>
7994 lines are copied from the history list to
7995 <FONT SIZE=-1><B>$HISTFILE</B>.
7996
7997 </FONT>
7998 If the
7999 <B>histappend</B>
8000
8001 shell option is enabled
8002 (see the description of
8003 <B>shopt</B>
8004
8005 under
8006 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
8007
8008 </FONT>
8009 below), the lines are appended to the history file,
8010 otherwise the history file is overwritten.
8011 If
8012 <FONT SIZE=-1><B>HISTFILE</B>
8013
8014 </FONT>
8015 is unset, or if the history file is unwritable, the history is
8016 not saved.
8017 If the
8018 <FONT SIZE=-1><B>HISTTIMEFORMAT</B>
8019
8020 </FONT>
8021 variable is set, time stamps are written to the history file, marked
8022 with the history comment character, so
8023 they may be preserved across shell sessions.
8024 This uses the history comment character to distinguish timestamps from
8025 other history lines.
8026 After saving the history, the history file is truncated
8027 to contain no more than
8028 <FONT SIZE=-1><B>HISTFILESIZE</B>
8029
8030 </FONT>
8031 lines. If
8032 <FONT SIZE=-1><B>HISTFILESIZE</B>
8033
8034 </FONT>
8035 is not set, no truncation is performed.
8036 <P>
8037
8038 The builtin command
8039 <B>fc</B>
8040
8041 (see
8042 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
8043
8044 </FONT>
8045 below) may be used to list or edit and re-execute a portion of
8046 the history list.
8047 The
8048 <B>history</B>
8049
8050 builtin may be used to display or modify the history list and
8051 manipulate the history file.
8052 When using command-line editing, search commands
8053 are available in each editing mode that provide access to the
8054 history list.
8055 <P>
8056
8057 The shell allows control over which commands are saved on the history
8058 list. The
8059 <FONT SIZE=-1><B>HISTCONTROL</B>
8060
8061 </FONT>
8062 and
8063 <FONT SIZE=-1><B>HISTIGNORE</B>
8064
8065 </FONT>
8066 variables may be set to cause the shell to save only a subset of the
8067 commands entered.
8068 The
8069 <B>cmdhist</B>
8070
8071 shell option, if enabled, causes the shell to attempt to save each
8072 line of a multi-line command in the same history entry, adding
8073 semicolons where necessary to preserve syntactic correctness.
8074 The
8075 <B>lithist</B>
8076
8077 shell option causes the shell to save the command with embedded newlines
8078 instead of semicolons. See the description of the
8079 <B>shopt</B>
8080
8081 builtin below under
8082 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
8083
8084 </FONT>
8085 for information on setting and unsetting shell options.
8086 <A NAME="lbCX">&nbsp;</A>
8087 <H3>HISTORY EXPANSION</H3>
8088
8089 <P>
8090
8091 The shell supports a history expansion feature that
8092 is similar to the history expansion in
8093 <B>csh.</B>
8094
8095 This section describes what syntax features are available. This
8096 feature is enabled by default for interactive shells, and can be
8097 disabled using the
8098 <B>+H</B>
8099
8100 option to the
8101 <B>set</B>
8102
8103 builtin command (see
8104 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
8105
8106 </FONT>
8107 below). Non-interactive shells do not perform history expansion
8108 by default.
8109 <P>
8110
8111 History expansions introduce words from the history list into
8112 the input stream, making it easy to repeat commands, insert the
8113 arguments to a previous command into the current input line, or
8114 fix errors in previous commands quickly.
8115 <P>
8116
8117 History expansion is performed immediately after a complete line
8118 is read, before the shell breaks it into words.
8119 It takes place in two parts.
8120 The first is to determine which line from the history list
8121 to use during substitution.
8122 The second is to select portions of that line for inclusion into
8123 the current one.
8124 The line selected from the history is the <I>event</I>,
8125 and the portions of that line that are acted upon are <I>words</I>.
8126 Various <I>modifiers</I> are available to manipulate the selected words.
8127 The line is broken into words in the same fashion as when reading input,
8128 so that several <I>metacharacter</I>-separated words surrounded by
8129 quotes are considered one word.
8130 History expansions are introduced by the appearance of the
8131 history expansion character, which is <B>!</B> by default.
8132 Only backslash (<B>\</B>) and single quotes can quote
8133 the history expansion character.
8134 <P>
8135
8136 Several characters inhibit history expansion if found immediately
8137 following the history expansion character, even if it is unquoted:
8138 space, tab, newline, carriage return, and <B>=</B>.
8139 If the <B>extglob</B> shell option is enabled, <B>(</B> will also
8140 inhibit expansion.
8141 <P>
8142
8143 Several shell options settable with the
8144 <B>shopt</B>
8145
8146 builtin may be used to tailor the behavior of history expansion.
8147 If the
8148 <B>histverify</B>
8149
8150 shell option is enabled (see the description of the
8151 <B>shopt</B>
8152
8153 builtin below), and
8154 <B>readline</B>
8155
8156 is being used, history substitutions are not immediately passed to
8157 the shell parser.
8158 Instead, the expanded line is reloaded into the
8159 <B>readline</B>
8160
8161 editing buffer for further modification.
8162 If
8163 <B>readline</B>
8164
8165 is being used, and the
8166 <B>histreedit</B>
8167
8168 shell option is enabled, a failed history substitution will be reloaded
8169 into the
8170 <B>readline</B>
8171
8172 editing buffer for correction.
8173 The
8174 <B>-p</B>
8175
8176 option to the
8177 <B>history</B>
8178
8179 builtin command may be used to see what a history expansion will
8180 do before using it.
8181 The
8182 <B>-s</B>
8183
8184 option to the
8185 <B>history</B>
8186
8187 builtin may be used to add commands to the end of the history list
8188 without actually executing them, so that they are available for
8189 subsequent recall.
8190 <P>
8191
8192 The shell allows control of the various characters used by the
8193 history expansion mechanism (see the description of
8194 <B>histchars</B>
8195
8196 above under
8197 <B>Shell Variables</B>).
8198
8199 The shell uses
8200 the history comment character to mark history timestamps when
8201 writing the history file.
8202 <A NAME="lbCY">&nbsp;</A>
8203 <H4>Event Designators</H4>
8204
8205 <P>
8206
8207 An event designator is a reference to a command line entry in the
8208 history list.
8209 Unless the reference is absolute, events are relative to the current
8210 position in the history list.
8211 <P>
8212
8213
8214 <DL COMPACT>
8215 <DT><B>!</B>
8216
8217 <DD>
8218 Start a history substitution, except when followed by a
8219 <B>blank</B>,
8220
8221 newline, carriage return, =
8222 or ( (when the <B>extglob</B> shell option is enabled using
8223 the <B>shopt</B> builtin).
8224 <DT><B>!</B><I>n</I>
8225
8226 <DD>
8227 Refer to command line
8228 <I>n</I>.
8229
8230 <DT><B>!-</B><I>n</I>
8231
8232 <DD>
8233 Refer to the current command minus
8234 <I>n</I>.
8235
8236 <DT><B>!!</B>
8237
8238 <DD>
8239 Refer to the previous command. This is a synonym for `!-1'.
8240 <DT><B>!</B><I>string</I>
8241
8242 <DD>
8243 Refer to the most recent command preceding the current position in the
8244 history list starting with
8245 <I>string</I>.
8246
8247 <DT><B>!?</B><I>string</I><B>[?]</B>
8248
8249 <DD>
8250 Refer to the most recent command preceding the current postition in the
8251 history list containing
8252 <I>string</I>.
8253
8254 The trailing <B>?</B> may be omitted if
8255 <I>string</I>
8256
8257 is followed immediately by a newline.
8258 <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>
8259
8260 <DD>
8261 Quick substitution. Repeat the previous command, replacing
8262 <I>string1</I>
8263
8264 with
8265 <I>string2</I>.
8266
8267 Equivalent to
8268 ``!!:s/<I>string1</I>/<I>string2</I>/''
8269 (see <B>Modifiers</B> below).
8270 <DT><B>!#</B>
8271
8272 <DD>
8273 The entire command line typed so far.
8274
8275 </DL>
8276 <A NAME="lbCZ">&nbsp;</A>
8277 <H4>Word Designators</H4>
8278
8279 <P>
8280
8281 Word designators are used to select desired words from the event.
8282 A
8283 <B>:</B>
8284
8285 separates the event specification from the word designator.
8286 It may be omitted if the word designator begins with a
8287 <B>^</B>,
8288
8289 <B>$</B>,
8290
8291 <B>*</B>,
8292
8293 <B>-</B>,
8294
8295 or
8296 <B>%</B>.
8297
8298 Words are numbered from the beginning of the line,
8299 with the first word being denoted by 0 (zero).
8300 Words are inserted into the current line separated by single spaces.
8301 <P>
8302
8303
8304 <DL COMPACT>
8305 <DT><B>0 (zero)</B>
8306
8307 <DD>
8308 The zeroth word. For the shell, this is the command
8309 word.
8310 <DT><I>n</I>
8311
8312 <DD>
8313 The <I>n</I>th word.
8314 <DT><B>^</B>
8315
8316 <DD>
8317 The first argument. That is, word 1.
8318 <DT><B>$</B>
8319
8320 <DD>
8321 The last argument.
8322 <DT><B>%</B>
8323
8324 <DD>
8325 The word matched by the most recent `?<I>string</I>?' search.
8326 <DT><I>x</I><B>-</B>y
8327
8328 <DD>
8329 A range of words; `-<I>y</I>' abbreviates `0-<I>y</I>'.
8330 <DT><B>*</B>
8331
8332 <DD>
8333 All of the words but the zeroth. This is a synonym
8334 for `<I>1-$</I>'. It is not an error to use
8335 <B>*</B>
8336
8337 if there is just one
8338 word in the event; the empty string is returned in that case.
8339 <DT><B>x*</B>
8340
8341 <DD>
8342 Abbreviates <I>x-$</I>.
8343 <DT><B>x-</B>
8344
8345 <DD>
8346 Abbreviates <I>x-$</I> like <B>x*</B>, but omits the last word.
8347
8348 </DL>
8349 <P>
8350
8351 If a word designator is supplied without an event specification, the
8352 previous command is used as the event.
8353 <A NAME="lbDA">&nbsp;</A>
8354 <H4>Modifiers</H4>
8355
8356 <P>
8357
8358 After the optional word designator, there may appear a sequence of
8359 one or more of the following modifiers, each preceded by a `:'.
8360 <P>
8361
8362
8363 <P>
8364
8365 <DL COMPACT>
8366 <DT><B>h</B>
8367
8368 <DD>
8369 Remove a trailing file name component, leaving only the head.
8370 <DT><B>t</B>
8371
8372 <DD>
8373 Remove all leading file name components, leaving the tail.
8374 <DT><B>r</B>
8375
8376 <DD>
8377 Remove a trailing suffix of the form <I>.xxx</I>, leaving the
8378 basename.
8379 <DT><B>e</B>
8380
8381 <DD>
8382 Remove all but the trailing suffix.
8383 <DT><B>p</B>
8384
8385 <DD>
8386 Print the new command but do not execute it.
8387 <DT><B>q</B>
8388
8389 <DD>
8390 Quote the substituted words, escaping further substitutions.
8391 <DT><B>x</B>
8392
8393 <DD>
8394 Quote the substituted words as with
8395 <B>q</B>,
8396
8397 but break into words at
8398 <B>blanks</B>
8399
8400 and newlines.
8401 <DT><B>s/</B><I>old</I>/<I>new</I>/
8402
8403 <DD>
8404 Substitute
8405 <I>new</I>
8406
8407 for the first occurrence of
8408 <I>old</I>
8409
8410 in the event line. Any delimiter can be used in place of /. The
8411 final delimiter is optional if it is the last character of the
8412 event line. The delimiter may be quoted in
8413 <I>old</I>
8414
8415 and
8416 <I>new</I>
8417
8418 with a single backslash. If &amp; appears in
8419 <I>new</I>,
8420
8421 it is replaced by
8422 <I>old</I>.
8423
8424 A single backslash will quote the &amp;. If
8425 <I>old</I>
8426
8427 is null, it is set to the last
8428 <I>old</I>
8429
8430 substituted, or, if no previous history substitutions took place,
8431 the last
8432 <I>string</I>
8433
8434 in a
8435 <B>!?</B><I>string</I><B>[?]</B>
8436
8437 search.
8438 <DT><B>&amp;</B>
8439
8440 <DD>
8441 Repeat the previous substitution.
8442 <DT><B>g</B>
8443
8444 <DD>
8445 Cause changes to be applied over the entire event line. This is
8446 used in conjunction with `<B>:s</B>' (e.g., `<B>:gs/</B><I>old</I>/<I>new</I>/')
8447 or `<B>:&amp;</B>'. If used with
8448 `<B>:s</B>', any delimiter can be used
8449 in place of /, and the final delimiter is optional
8450 if it is the last character of the event line.
8451 An <B>a</B> may be used as a synonym for <B>g</B>.
8452 <DT><B>G</B>
8453
8454 <DD>
8455 Apply the following `<B>s</B>' modifier once to each word in the event line.
8456
8457 </DL>
8458 <A NAME="lbDB">&nbsp;</A>
8459 <H3>SHELL BUILTIN COMMANDS</H3>
8460
8461
8462
8463 <P>
8464
8465 Unless otherwise noted, each builtin command documented in this
8466 section as accepting options preceded by
8467 <B>-</B>
8468
8469 accepts
8470 <B>--</B>
8471
8472 to signify the end of the options.
8473 The <B>:</B>, <B>true</B>, <B>false</B>, and <B>test</B> builtins
8474 do not accept options and do not treat <B>--</B> specially.
8475 The <B>exit</B>, <B>logout</B>, <B>break</B>, <B>continue</B>, <B>let</B>,
8476 and <B>shift</B> builtins accept and process arguments beginning with
8477 <B>-</B> without requiring <B>--</B>.
8478 Other builtins that accept arguments but are not specified as accepting
8479 options interpret arguments beginning with <B>-</B> as invalid options and
8480 require <B>--</B> to prevent this interpretation.
8481 <P>
8482
8483 <DL COMPACT>
8484 <DT><B>:</B> [<I>arguments</I>]<DD>
8485
8486 No effect; the command does nothing beyond expanding
8487 <I>arguments</I>
8488
8489 and performing any specified
8490 redirections. A zero exit code is returned.
8491 <DT><B> . </B> <I>filename</I> [<I>arguments</I>]<DD>
8492
8493 <DT><B>source</B> <I>filename</I> [<I>arguments</I>]<DD>
8494
8495 Read and execute commands from
8496 <I>filename</I>
8497
8498 in the current
8499 shell environment and return the exit status of the last command
8500 executed from
8501 <I>filename</I>.
8502
8503 If
8504 <I>filename</I>
8505
8506 does not contain a slash, file names in
8507 <FONT SIZE=-1><B>PATH</B>
8508
8509 </FONT>
8510 are used to find the directory containing
8511 <I>filename</I>.
8512
8513 The file searched for in
8514 <FONT SIZE=-1><B>PATH</B>
8515
8516 </FONT>
8517 need not be executable.
8518 When <B>bash</B> is not in <I>posix mode</I>, the current directory is
8519 searched if no file is found in
8520 <FONT SIZE=-1><B>PATH</B>.
8521
8522 </FONT>
8523 If the
8524 <B>sourcepath</B>
8525
8526 option to the
8527 <B>shopt</B>
8528
8529 builtin command is turned off, the
8530 <FONT SIZE=-1><B>PATH</B>
8531
8532 </FONT>
8533 is not searched.
8534 If any <I>arguments</I> are supplied, they become the positional
8535 parameters when <I>filename</I> is executed. Otherwise the positional
8536 parameters are unchanged.
8537 The return status is the status of the last command exited within
8538 the script (0 if no commands are executed), and false if
8539 <I>filename</I>
8540
8541 is not found or cannot be read.
8542 <DT><B>alias</B> [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
8543 <B>Alias</B> with no arguments or with the
8544 <B>-p</B>
8545
8546 option prints the list of aliases in the form
8547 <B>alias</B> <I>name</I>=<I>value</I> on standard output.
8548 When arguments are supplied, an alias is defined for
8549 each <I>name</I> whose <I>value</I> is given.
8550 A trailing space in <I>value</I> causes the next word to be
8551 checked for alias substitution when the alias is expanded.
8552 For each <I>name</I> in the argument list for which no <I>value</I>
8553 is supplied, the name and value of the alias is printed.
8554 <B>Alias</B> returns true unless a <I>name</I> is given for which
8555 no alias has been defined.
8556 <DT><B>bg</B> [<I>jobspec</I> ...]<DD>
8557 Resume each suspended job <I>jobspec</I> in the background, as if it
8558 had been started with
8559 <B>&amp;</B>.
8560
8561 If
8562 <I>jobspec</I>
8563
8564 is not present, the shell's notion of the <I>current job</I> is used.
8565 <B>bg</B>
8566
8567 <I>jobspec</I>
8568
8569 returns 0 unless run when job control is disabled or, when run with
8570 job control enabled, any specified <I>jobspec</I> was not found
8571 or was started without job control.
8572 <DT><B>bind</B> [<B>-m</B> <I>keymap</I>] [<B>-lpsvPSV</B>]<DD>
8573
8574 <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>
8575 <DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <B>-f</B> <I>filename</I><DD>
8576 <DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <B>-x</B> <I>keyseq</I>:<I>shell-command</I><DD>
8577 <DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <I>keyseq</I>:<I>function-name</I><DD>
8578 <DT><B>bind</B> <I>readline-command</I><DD>
8579
8580 Display current
8581 <B>readline</B>
8582
8583 key and function bindings, bind a key sequence to a
8584 <B>readline</B>
8585
8586 function or macro, or set a
8587 <B>readline</B>
8588
8589 variable.
8590 Each non-option argument is a command as it would appear in
8591 <I>.inputrc</I>,
8592
8593 but each binding or command must be passed as a separate argument;
8594 e.g., '&quot;\C-x\C-r&quot;: re-read-init-file'.
8595 Options, if supplied, have the following meanings:
8596 <DL COMPACT><DT><DD>
8597
8598 <DL COMPACT>
8599 <DT><B>-m </B><I>keymap</I>
8600
8601 <DD>
8602 Use
8603 <I>keymap</I>
8604
8605 as the keymap to be affected by the subsequent bindings.
8606 Acceptable
8607 <I>keymap</I>
8608
8609 names are
8610 <I>emacs, emacs-standard, emacs-meta, emacs-ctlx, vi,
8611 vi-move, vi-command</I>, and
8612 <I>vi-insert</I>.
8613
8614 <I>vi</I> is equivalent to <I>vi-command</I>; <I>emacs</I> is
8615 equivalent to <I>emacs-standard</I>.
8616 <DT><B>-l</B>
8617
8618 <DD>
8619 List the names of all <B>readline</B> functions.
8620 <DT><B>-p</B>
8621
8622 <DD>
8623 Display <B>readline</B> function names and bindings in such a way
8624 that they can be re-read.
8625 <DT><B>-P</B>
8626
8627 <DD>
8628 List current <B>readline</B> function names and bindings.
8629 <DT><B>-s</B>
8630
8631 <DD>
8632 Display <B>readline</B> key sequences bound to macros and the strings
8633 they output in such a way that they can be re-read.
8634 <DT><B>-S</B>
8635
8636 <DD>
8637 Display <B>readline</B> key sequences bound to macros and the strings
8638 they output.
8639 <DT><B>-v</B>
8640
8641 <DD>
8642 Display <B>readline</B> variable names and values in such a way that they
8643 can be re-read.
8644 <DT><B>-V</B>
8645
8646 <DD>
8647 List current <B>readline</B> variable names and values.
8648 <DT><B>-f </B><I>filename</I>
8649
8650 <DD>
8651 Read key bindings from <I>filename</I>.
8652 <DT><B>-q </B><I>function</I>
8653
8654 <DD>
8655 Query about which keys invoke the named <I>function</I>.
8656 <DT><B>-u </B><I>function</I>
8657
8658 <DD>
8659 Unbind all keys bound to the named <I>function</I>.
8660 <DT><B>-r </B><I>keyseq</I>
8661
8662 <DD>
8663 Remove any current binding for <I>keyseq</I>.
8664 <DT><B>-x </B><I>keyseq</I>:<I>shell-command</I>
8665
8666 <DD>
8667 Cause <I>shell-command</I> to be executed whenever <I>keyseq</I> is
8668 entered.
8669 When <I>shell-command</I> is executed, the shell sets the
8670 <FONT SIZE=-1><B>READLINE_LINE</B>
8671
8672 </FONT>
8673 variable to the contents of the <B>readline</B> line buffer and the
8674 <FONT SIZE=-1><B>READLINE_POINT</B>
8675
8676 </FONT>
8677 variable to the current location of the insertion point.
8678 If the executed command changes the value of
8679 <FONT SIZE=-1><B>READLINE_LINE</B>
8680
8681 </FONT>
8682 or
8683 <FONT SIZE=-1><B>READLINE_POINT</B>,
8684
8685 </FONT>
8686 those new values will be reflected in the editing state.
8687
8688 </DL>
8689 <P>
8690
8691 The return value is 0 unless an unrecognized option is given or an
8692 error occurred.
8693 </DL>
8694
8695 <DT><B>break</B> [<I>n</I>]<DD>
8696 Exit from within a
8697 <B>for</B>,
8698
8699 <B>while</B>,
8700
8701 <B>until</B>,
8702
8703 or
8704 <B>select</B>
8705
8706 loop. If <I>n</I> is specified, break <I>n</I> levels.
8707 <I>n</I>
8708
8709 must be >= 1. If
8710 <I>n</I>
8711
8712 is greater than the number of enclosing loops, all enclosing loops
8713 are exited.
8714 The return value is 0 unless <I>n</I> is not greater than or equal to 1.
8715 <DT><B>builtin</B> <I>shell-builtin</I> [<I>arguments</I>]<DD>
8716 Execute the specified shell builtin, passing it
8717 <I>arguments</I>,
8718
8719 and return its exit status.
8720 This is useful when defining a
8721 function whose name is the same as a shell builtin,
8722 retaining the functionality of the builtin within the function.
8723 The <B>cd</B> builtin is commonly redefined this way.
8724 The return status is false if
8725 <I>shell-builtin</I>
8726
8727 is not a shell builtin command.
8728 <DT><B>caller</B> [<I>expr</I>]<DD>
8729 Returns the context of any active subroutine call (a shell function or
8730 a script executed with the <B>.</B> or <B>source</B> builtins).
8731 Without <I>expr</I>, <B>caller</B> displays the line number and source
8732 filename of the current subroutine call.
8733 If a non-negative integer is supplied as <I>expr</I>, <B>caller</B>
8734 displays the line number, subroutine name, and source file corresponding
8735 to that position in the current execution call stack. This extra
8736 information may be used, for example, to print a stack trace. The
8737 current frame is frame 0.
8738 The return value is 0 unless the shell is not executing a subroutine
8739 call or <I>expr</I> does not correspond to a valid position in the
8740 call stack.
8741 <DT><B>cd</B> [<B>-L</B>|[<B>-P</B> [<B>-e</B>]]] [<I>dir</I>]<DD>
8742 Change the current directory to <I>dir</I>. The variable
8743 <FONT SIZE=-1><B>HOME</B>
8744
8745 </FONT>
8746 is the
8747 default
8748 <I>dir</I>.
8749
8750 The variable
8751 <FONT SIZE=-1><B>CDPATH</B>
8752
8753 </FONT>
8754 defines the search path for the directory containing
8755 <I>dir</I>.
8756
8757 Alternative directory names in
8758 <FONT SIZE=-1><B>CDPATH</B>
8759
8760 </FONT>
8761 are separated by a colon (:). A null directory name in
8762 <FONT SIZE=-1><B>CDPATH</B>
8763
8764 </FONT>
8765 is the same as the current directory, i.e., ``<B>.</B>''. If
8766 <I>dir</I>
8767
8768 begins with a slash (/),
8769 then
8770 <FONT SIZE=-1><B>CDPATH</B>
8771
8772 </FONT>
8773 is not used. The
8774 <B>-P</B>
8775
8776 option says to use the physical directory structure instead of
8777 following symbolic links (see also the
8778 <B>-P</B>
8779
8780 option to the
8781 <B>set</B>
8782
8783 builtin command); the
8784 <B>-L</B>
8785
8786 option forces symbolic links to be followed.
8787 If the
8788 <B>-e</B>
8789
8790 option is supplied with
8791 <B>-P</B>,
8792
8793 and the current working directory cannot be successfully determined
8794 after a successful directory change, <B>cd</B> will return an unsuccessful
8795 status.
8796 An argument of
8797 <B>-</B>
8798
8799 is equivalent to
8800 <FONT SIZE=-1><B>$OLDPWD</B>.
8801
8802 </FONT>
8803 If a non-empty directory name from
8804 <FONT SIZE=-1><B>CDPATH</B>
8805
8806 </FONT>
8807 is used, or if
8808 <B>-</B> is the first argument, and the directory change is
8809 successful, the absolute pathname of the new working directory is
8810 written to the standard output.
8811 The return value is true if the directory was successfully changed;
8812 false otherwise.
8813 <DT><B>command</B> [<B>-pVv</B>] <I>command</I> [<I>arg</I> ...]<DD>
8814 Run
8815 <I>command</I>
8816
8817 with
8818 <I>args</I>
8819
8820 suppressing the normal shell function lookup. Only builtin
8821 commands or commands found in the
8822 <FONT SIZE=-1><B>PATH</B>
8823
8824 </FONT>
8825 are executed. If the
8826 <B>-p</B>
8827
8828 option is given, the search for
8829 <I>command</I>
8830
8831 is performed using a default value for
8832 <FONT SIZE=-1><B>PATH</B>
8833
8834 </FONT>
8835 that is guaranteed to find all of the standard utilities.
8836 If either the
8837 <B>-V</B>
8838
8839 or
8840 <B>-v</B>
8841
8842 option is supplied, a description of
8843 <I>command</I>
8844
8845 is printed. The
8846 <B>-v</B>
8847
8848 option causes a single word indicating the command or file name
8849 used to invoke
8850 <I>command</I>
8851
8852 to be displayed; the
8853 <B>-V</B>
8854
8855 option produces a more verbose description.
8856 If the
8857 <B>-V</B>
8858
8859 or
8860 <B>-v</B>
8861
8862 option is supplied, the exit status is 0 if
8863 <I>command</I>
8864
8865 was found, and 1 if not. If neither option is supplied and
8866 an error occurred or
8867 <I>command</I>
8868
8869 cannot be found, the exit status is 127. Otherwise, the exit status of the
8870 <B>command</B>
8871
8872 builtin is the exit status of
8873 <I>command</I>.
8874
8875 <DT><B>compgen</B> [<I>option</I>] [<I>word</I>]<DD>
8876 Generate possible completion matches for <I>word</I> according to
8877 the <I>option</I>s, which may be any option accepted by the
8878 <B>complete</B>
8879
8880 builtin with the exception of <B>-p</B> and <B>-r</B>, and write
8881 the matches to the standard output.
8882 When using the <B>-F</B> or <B>-C</B> options, the various shell variables
8883 set by the programmable completion facilities, while available, will not
8884 have useful values.
8885 <P>
8886 The matches will be generated in the same way as if the programmable
8887 completion code had generated them directly from a completion specification
8888 with the same flags.
8889 If <I>word</I> is specified, only those completions matching <I>word</I>
8890 will be displayed.
8891 <P>
8892 The return value is true unless an invalid option is supplied, or no
8893 matches were generated.
8894 <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>
8895 <BR>
8896
8897 [<B>-X</B> <I>filterpat</I>] [<B>-P</B> <I>prefix</I>] [<B>-S</B> <I>suffix</I>] <I>name</I> [<I>name ...</I>]
8898
8899 <DT><B>complete</B> <B>-pr</B> [<B>-DE</B>] [<I>name</I> ...]<DD>
8900
8901 Specify how arguments to each <I>name</I> should be completed.
8902 If the <B>-p</B> option is supplied, or if no options are supplied,
8903 existing completion specifications are printed in a way that allows
8904 them to be reused as input.
8905 The <B>-r</B> option removes a completion specification for
8906 each <I>name</I>, or, if no <I>name</I>s are supplied, all
8907 completion specifications.
8908 The <B>-D</B> option indicates that the remaining options and actions should
8909 apply to the ``default'' command completion; that is, completion attempted
8910 on a command for which no completion has previously been defined.
8911 The <B>-E</B> option indicates that the remaining options and actions should
8912 apply to ``empty'' command completion; that is, completion attempted on a
8913 blank line.
8914 <P>
8915 The process of applying these completion specifications when word completion
8916 is attempted is described above under <B>Programmable Completion</B>.
8917 <P>
8918 Other options, if specified, have the following meanings.
8919 The arguments to the <B>-G</B>, <B>-W</B>, and <B>-X</B> options
8920 (and, if necessary, the <B>-P</B> and <B>-S</B> options)
8921 should be quoted to protect them from expansion before the
8922 <B>complete</B>
8923
8924 builtin is invoked.
8925 <DL COMPACT><DT><DD>
8926
8927 <DL COMPACT>
8928 <DT><B>-o</B> <I>comp-option</I><DD>
8929 The <I>comp-option</I> controls several aspects of the compspec's behavior
8930 beyond the simple generation of completions.
8931 <I>comp-option</I> may be one of:
8932 <DL COMPACT><DT><DD>
8933 <DL COMPACT>
8934 <DT><B>bashdefault</B>
8935
8936 <DD>
8937 Perform the rest of the default <B>bash</B> completions if the compspec
8938 generates no matches.
8939 <DT><B>default</B>
8940
8941 <DD>
8942 Use readline's default filename completion if the compspec generates
8943 no matches.
8944 <DT><B>dirnames</B>
8945
8946 <DD>
8947 Perform directory name completion if the compspec generates no matches.
8948 <DT><B>filenames</B>
8949
8950 <DD>
8951 Tell readline that the compspec generates filenames, so it can perform any
8952 filename-specific processing (like adding a slash to directory names,
8953 quoting special characters, or suppressing trailing spaces).
8954 Intended to be used with shell functions.
8955 <DT><B>nospace</B>
8956
8957 <DD>
8958 Tell readline not to append a space (the default) to words completed at
8959 the end of the line.
8960 <DT><B>plusdirs</B>
8961
8962 <DD>
8963 After any matches defined by the compspec are generated,
8964 directory name completion is attempted and any
8965 matches are added to the results of the other actions.
8966 </DL></DL>
8967
8968 <DT><B>-A</B> <I>action</I><DD>
8969 The <I>action</I> may be one of the following to generate a list of possible
8970 completions:
8971 <DL COMPACT><DT><DD>
8972 <DL COMPACT>
8973 <DT><B>alias</B>
8974
8975 <DD>
8976 Alias names. May also be specified as <B>-a</B>.
8977 <DT><B>arrayvar</B>
8978
8979 <DD>
8980 Array variable names.
8981 <DT><B>binding</B>
8982
8983 <DD>
8984 <B>Readline</B> key binding names.
8985 <DT><B>builtin</B>
8986
8987 <DD>
8988 Names of shell builtin commands. May also be specified as <B>-b</B>.
8989 <DT><B>command</B>
8990
8991 <DD>
8992 Command names. May also be specified as <B>-c</B>.
8993 <DT><B>directory</B>
8994
8995 <DD>
8996 Directory names. May also be specified as <B>-d</B>.
8997 <DT><B>disabled</B>
8998
8999 <DD>
9000 Names of disabled shell builtins.
9001 <DT><B>enabled</B>
9002
9003 <DD>
9004 Names of enabled shell builtins.
9005 <DT><B>export</B>
9006
9007 <DD>
9008 Names of exported shell variables. May also be specified as <B>-e</B>.
9009 <DT><B>file</B>
9010
9011 <DD>
9012 File names. May also be specified as <B>-f</B>.
9013 <DT><B>function</B>
9014
9015 <DD>
9016 Names of shell functions.
9017 <DT><B>group</B>
9018
9019 <DD>
9020 Group names. May also be specified as <B>-g</B>.
9021 <DT><B>helptopic</B>
9022
9023 <DD>
9024 Help topics as accepted by the <B>help</B> builtin.
9025 <DT><B>hostname</B>
9026
9027 <DD>
9028 Hostnames, as taken from the file specified by the
9029 <FONT SIZE=-1><B>HOSTFILE</B>
9030
9031 </FONT>
9032 shell variable.
9033 <DT><B>job</B>
9034
9035 <DD>
9036 Job names, if job control is active. May also be specified as <B>-j</B>.
9037 <DT><B>keyword</B>
9038
9039 <DD>
9040 Shell reserved words. May also be specified as <B>-k</B>.
9041 <DT><B>running</B>
9042
9043 <DD>
9044 Names of running jobs, if job control is active.
9045 <DT><B>service</B>
9046
9047 <DD>
9048 Service names. May also be specified as <B>-s</B>.
9049 <DT><B>setopt</B>
9050
9051 <DD>
9052 Valid arguments for the <B>-o</B> option to the <B>set</B> builtin.
9053 <DT><B>shopt</B>
9054
9055 <DD>
9056 Shell option names as accepted by the <B>shopt</B> builtin.
9057 <DT><B>signal</B>
9058
9059 <DD>
9060 Signal names.
9061 <DT><B>stopped</B>
9062
9063 <DD>
9064 Names of stopped jobs, if job control is active.
9065 <DT><B>user</B>
9066
9067 <DD>
9068 User names. May also be specified as <B>-u</B>.
9069 <DT><B>variable</B>
9070
9071 <DD>
9072 Names of all shell variables. May also be specified as <B>-v</B>.
9073 </DL></DL>
9074
9075 <DT><B>-C</B> <I>command</I><DD>
9076 <I>command</I> is executed in a subshell environment, and its output is
9077 used as the possible completions.
9078 <DT><B>-F</B> <I>function</I><DD>
9079 The shell function <I>function</I> is executed in the current shell
9080 environment.
9081 When it finishes, the possible completions are retrieved from the value
9082 of the
9083 <FONT SIZE=-1><B>COMPREPLY</B>
9084
9085 </FONT>
9086 array variable.
9087 <DT><B>-G</B> <I>globpat</I><DD>
9088 The pathname expansion pattern <I>globpat</I> is expanded to generate
9089 the possible completions.
9090 <DT><B>-P</B> <I>prefix</I><DD>
9091 <I>prefix</I> is added at the beginning of each possible completion
9092 after all other options have been applied.
9093 <DT><B>-S</B> <I>suffix</I><DD>
9094 <I>suffix</I> is appended to each possible completion
9095 after all other options have been applied.
9096 <DT><B>-W</B> <I>wordlist</I><DD>
9097 The <I>wordlist</I> is split using the characters in the
9098 <FONT SIZE=-1><B>IFS</B>
9099
9100 </FONT>
9101 special variable as delimiters, and each resultant word is expanded.
9102 The possible completions are the members of the resultant list which
9103 match the word being completed.
9104 <DT><B>-X</B> <I>filterpat</I><DD>
9105 <I>filterpat</I> is a pattern as used for pathname expansion.
9106 It is applied to the list of possible completions generated by the
9107 preceding options and arguments, and each completion matching
9108 <I>filterpat</I> is removed from the list.
9109 A leading <B>!</B> in <I>filterpat</I> negates the pattern; in this
9110 case, any completion not matching <I>filterpat</I> is removed.
9111
9112 </DL>
9113 <P>
9114
9115 The return value is true unless an invalid option is supplied, an option
9116 other than <B>-p</B> or <B>-r</B> is supplied without a <I>name</I>
9117 argument, an attempt is made to remove a completion specification for
9118 a <I>name</I> for which no specification exists, or
9119 an error occurs adding a completion specification.
9120 </DL>
9121
9122 <DT><B>compopt</B> [<B>-o</B> <I>option</I>] [<B>-DE</B>] [<B>+o</B> <I>option</I>] [<I>name</I>]<DD>
9123 Modify completion options for each <I>name</I> according to the
9124 <I>option</I>s, or for the
9125 currently-executing completion if no <I>name</I>s are supplied.
9126 If no <I>option</I>s are given, display the completion options for each
9127 <I>name</I> or the current completion.
9128 The possible values of <I>option</I> are those valid for the <B>complete</B>
9129 builtin described above.
9130 The <B>-D</B> option indicates that the remaining options should
9131 apply to the ``default'' command completion; that is, completion attempted
9132 on a command for which no completion has previously been defined.
9133 The <B>-E</B> option indicates that the remaining options should
9134 apply to ``empty'' command completion; that is, completion attempted on a
9135 blank line.
9136 <P>
9137 The return value is true unless an invalid option is supplied, an attempt
9138 is made to modify the options for a <I>name</I> for which no completion
9139 specification exists, or an output error occurs.
9140 <DT><B>continue</B> [<I>n</I>]<DD>
9141 Resume the next iteration of the enclosing
9142 <B>for</B>,
9143
9144 <B>while</B>,
9145
9146 <B>until</B>,
9147
9148 or
9149 <B>select</B>
9150
9151 loop.
9152 If
9153 <I>n</I>
9154
9155 is specified, resume at the <I>n</I>th enclosing loop.
9156 <I>n</I>
9157
9158 must be >= 1. If
9159 <I>n</I>
9160
9161 is greater than the number of enclosing loops, the last enclosing loop
9162 (the ``top-level'' loop) is resumed.
9163 The return value is 0 unless <I>n</I> is not greater than or equal to 1.
9164 <DT><B>declare</B> [<B>-aAfFgilrtux</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
9165
9166 <DT><B>typeset</B> [<B>-aAfFgilrtux</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
9167
9168 Declare variables and/or give them attributes.
9169 If no <I>name</I>s are given then display the values of variables.
9170 The
9171 <B>-p</B>
9172
9173 option will display the attributes and values of each
9174 <I>name</I>.
9175
9176 When
9177 <B>-p</B>
9178
9179 is used with <I>name</I> arguments, additional options are ignored.
9180 When
9181 <B>-p</B>
9182
9183 is supplied without <I>name</I> arguments, it will display the attributes
9184 and values of all variables having the attributes specified by the
9185 additional options.
9186 If no other options are supplied with <B>-p</B>, <B>declare</B> will display
9187 the attributes and values of all shell variables. The <B>-f</B> option
9188 will restrict the display to shell functions.
9189 The
9190 <B>-F</B>
9191
9192 option inhibits the display of function definitions; only the
9193 function name and attributes are printed.
9194 If the <B>extdebug</B> shell option is enabled using <B>shopt</B>,
9195 the source file name and line number where the function is defined
9196 are displayed as well. The
9197 <B>-F</B>
9198
9199 option implies
9200 <B>-f</B>.
9201
9202 The
9203 <B>-g</B>
9204
9205 option forces variables to be created or modified at the global scope,
9206 even when <B>declare</B> is executed in a shell function.
9207 It is ignored in all other cases.
9208 The following options can
9209 be used to restrict output to variables with the specified attribute or
9210 to give variables attributes:
9211 <DL COMPACT><DT><DD>
9212
9213 <DL COMPACT>
9214 <DT><B>-a</B>
9215
9216 <DD>
9217 Each <I>name</I> is an indexed array variable (see
9218 <B>Arrays</B>
9219
9220 above).
9221 <DT><B>-A</B>
9222
9223 <DD>
9224 Each <I>name</I> is an associative array variable (see
9225 <B>Arrays</B>
9226
9227 above).
9228 <DT><B>-f</B>
9229
9230 <DD>
9231 Use function names only.
9232 <DT><B>-i</B>
9233
9234 <DD>
9235 The variable is treated as an integer; arithmetic evaluation (see
9236 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
9237
9238 </FONT>
9239 above) is performed when the variable is assigned a value.
9240 <DT><B>-l</B>
9241
9242 <DD>
9243 When the variable is assigned a value, all upper-case characters are
9244 converted to lower-case.
9245 The upper-case attribute is disabled.
9246 <DT><B>-r</B>
9247
9248 <DD>
9249 Make <I>name</I>s readonly. These names cannot then be assigned values
9250 by subsequent assignment statements or unset.
9251 <DT><B>-t</B>
9252
9253 <DD>
9254 Give each <I>name</I> the <I>trace</I> attribute.
9255 Traced functions inherit the <B>DEBUG</B> and <B>RETURN</B> traps from
9256 the calling shell.
9257 The trace attribute has no special meaning for variables.
9258 <DT><B>-u</B>
9259
9260 <DD>
9261 When the variable is assigned a value, all lower-case characters are
9262 converted to upper-case.
9263 The lower-case attribute is disabled.
9264 <DT><B>-x</B>
9265
9266 <DD>
9267 Mark <I>name</I>s for export to subsequent commands via the environment.
9268
9269 </DL>
9270 <P>
9271
9272 Using `+' instead of `-'
9273 turns off the attribute instead,
9274 with the exceptions that <B>+a</B>
9275 may not be used to destroy an array variable and <B>+r</B> will not
9276 remove the readonly attribute.
9277 When used in a function, makes each
9278 <I>name</I> local, as with the
9279 <B>local</B>
9280
9281 command,
9282 unless the <B>-gP option is supplied,
9283 If a variable name is followed by =</B><I>value</I>, the value of
9284 the variable is set to <I>value</I>.
9285 The return value is 0 unless an invalid option is encountered,
9286 an attempt is made to define a function using
9287
9288 <TT>-f foo=bar</TT>,
9289 an attempt is made to assign a value to a readonly variable,
9290 an attempt is made to assign a value to an array variable without
9291 using the compound assignment syntax (see
9292 <B>Arrays</B>
9293
9294 above), one of the <I>names</I> is not a valid shell variable name,
9295 an attempt is made to turn off readonly status for a readonly variable,
9296 an attempt is made to turn off array status for an array variable,
9297 or an attempt is made to display a non-existent function with <B>-f</B>.
9298 </DL>
9299
9300 <DT><B>dirs [+</B><I>n</I>] [-<I>n</I>] [<B>-clpv</B>]
9301
9302 <DD>
9303 Without options, displays the list of currently remembered directories.
9304 The default display is on a single line with directory names separated
9305 by spaces.
9306 Directories are added to the list with the
9307 <B>pushd</B>
9308
9309 command; the
9310 <B>popd</B>
9311
9312 command removes entries from the list.
9313 <DL COMPACT><DT><DD>
9314
9315 <DL COMPACT>
9316 <DT><B>+</B><I>n</I><DD>
9317 Displays the <I>n</I>th entry counting from the left of the list
9318 shown by
9319 <B>dirs</B>
9320
9321 when invoked without options, starting with zero.
9322 <DT><B>-</B><I>n</I><DD>
9323 Displays the <I>n</I>th entry counting from the right of the list
9324 shown by
9325 <B>dirs</B>
9326
9327 when invoked without options, starting with zero.
9328 <DT><B>-c</B>
9329
9330 <DD>
9331 Clears the directory stack by deleting all of the entries.
9332 <DT><B>-l</B>
9333
9334 <DD>
9335 Produces a longer listing; the default listing format uses a
9336 tilde to denote the home directory.
9337 <DT><B>-p</B>
9338
9339 <DD>
9340 Print the directory stack with one entry per line.
9341 <DT><B>-v</B>
9342
9343 <DD>
9344 Print the directory stack with one entry per line,
9345 prefixing each entry with its index in the stack.
9346
9347 </DL>
9348 <P>
9349
9350 The return value is 0 unless an
9351 invalid option is supplied or <I>n</I> indexes beyond the end
9352 of the directory stack.
9353 </DL>
9354
9355 <DT><B>disown</B> [<B>-ar</B>] [<B>-h</B>] [<I>jobspec</I> ...]<DD>
9356 Without options, each
9357 <I>jobspec</I>
9358
9359 is removed from the table of active jobs.
9360 If
9361 <I>jobspec</I>
9362
9363 is not present, and neither <B>-a</B> nor <B>-r</B> is supplied,
9364 the shell's notion of the <I>current job</I> is used.
9365 If the <B>-h</B> option is given, each
9366 <I>jobspec</I>
9367
9368 is not removed from the table, but is marked so that
9369 <FONT SIZE=-1><B>SIGHUP</B>
9370
9371 </FONT>
9372 is not sent to the job if the shell receives a
9373 <FONT SIZE=-1><B>SIGHUP</B>.
9374
9375 </FONT>
9376 If no
9377 <I>jobspec</I>
9378
9379 is present, and neither the
9380 <B>-a</B>
9381
9382 nor the
9383 <B>-r</B>
9384
9385 option is supplied, the <I>current job</I> is used.
9386 If no
9387 <I>jobspec</I>
9388
9389 is supplied, the
9390 <B>-a</B>
9391
9392 option means to remove or mark all jobs; the
9393 <B>-r</B>
9394
9395 option without a
9396 <I>jobspec</I>
9397
9398 argument restricts operation to running jobs.
9399 The return value is 0 unless a
9400 <I>jobspec</I>
9401
9402 does not specify a valid job.
9403 <DT><B>echo</B> [<B>-neE</B>] [<I>arg</I> ...]<DD>
9404 Output the <I>arg</I>s, separated by spaces, followed by a newline.
9405 The return status is always 0.
9406 If <B>-n</B> is specified, the trailing newline is
9407 suppressed. If the <B>-e</B> option is given, interpretation of
9408 the following backslash-escaped characters is enabled. The
9409 <B>-E</B>
9410
9411 option disables the interpretation of these escape characters,
9412 even on systems where they are interpreted by default.
9413 The <B>xpg_echo</B> shell option may be used to
9414 dynamically determine whether or not <B>echo</B> expands these
9415 escape characters by default.
9416 <B>echo</B>
9417
9418 does not interpret <B>--</B> to mean the end of options.
9419 <B>echo</B>
9420
9421 interprets the following escape sequences:
9422 <DL COMPACT><DT><DD>
9423
9424 <DL COMPACT>
9425 <DT><B>\a</B>
9426
9427 <DD>
9428 alert (bell)
9429 <DT><B>\b</B>
9430
9431 <DD>
9432 backspace
9433 <DT><B>\c</B>
9434
9435 <DD>
9436 suppress further output
9437 <DT><B>\e</B>
9438
9439 <DD>
9440 <DT><B>\E</B>
9441
9442 <DD>
9443 an escape character
9444 <DT><B>\f</B>
9445
9446 <DD>
9447 form feed
9448 <DT><B>\n</B>
9449
9450 <DD>
9451 new line
9452 <DT><B>\r</B>
9453
9454 <DD>
9455 carriage return
9456 <DT><B>\t</B>
9457
9458 <DD>
9459 horizontal tab
9460 <DT><B>\v</B>
9461
9462 <DD>
9463 vertical tab
9464 <DT><B>\\</B>
9465
9466 <DD>
9467 backslash
9468 <DT><B>\0</B><I>nnn</I>
9469
9470 <DD>
9471 the eight-bit character whose value is the octal value <I>nnn</I>
9472 (zero to three octal digits)
9473 <DT><B>\x</B><I>HH</I>
9474
9475 <DD>
9476 the eight-bit character whose value is the hexadecimal value <I>HH</I>
9477 (one or two hex digits)
9478 <DT><B>\u</B><I>HHHH</I>
9479
9480 <DD>
9481 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
9482 <I>HHHH</I> (one to four hex digits)
9483 <DT><B>\U</B><I>HHHHHHHH</I>
9484
9485 <DD>
9486 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
9487 <I>HHHHHHHH</I> (one to eight hex digits)
9488
9489 </DL></DL>
9490
9491 <DT><B>enable</B> [<B>-a</B>] [<B>-dnps</B>] [<B>-f</B> <I>filename</I>] [<I>name</I> ...]<DD>
9492 Enable and disable builtin shell commands.
9493 Disabling a builtin allows a disk command which has the same name
9494 as a shell builtin to be executed without specifying a full pathname,
9495 even though the shell normally searches for builtins before disk commands.
9496 If <B>-n</B> is used, each <I>name</I>
9497 is disabled; otherwise,
9498 <I>names</I> are enabled. For example, to use the
9499 <B>test</B>
9500
9501 binary found via the
9502 <FONT SIZE=-1><B>PATH</B>
9503
9504 </FONT>
9505 instead of the shell builtin version, run
9506 <TT>enable -n test</TT>.
9507
9508 The
9509 <B>-f</B>
9510
9511 option means to load the new builtin command
9512 <I>name</I>
9513
9514 from shared object
9515 <I>filename</I>,
9516
9517 on systems that support dynamic loading. The
9518 <B>-d</B>
9519
9520 option will delete a builtin previously loaded with
9521 <B>-f</B>.
9522
9523 If no <I>name</I> arguments are given, or if the
9524 <B>-p</B>
9525
9526 option is supplied, a list of shell builtins is printed.
9527 With no other option arguments, the list consists of all enabled
9528 shell builtins.
9529 If <B>-n</B> is supplied, only disabled builtins are printed.
9530 If <B>-a</B> is supplied, the list printed includes all builtins, with an
9531 indication of whether or not each is enabled.
9532 If <B>-s</B> is supplied, the output is restricted to the POSIX
9533 <I>special</I> builtins.
9534 The return value is 0 unless a
9535 <I>name</I>
9536
9537 is not a shell builtin or there is an error loading a new builtin
9538 from a shared object.
9539 <DT><B>eval</B> [<I>arg</I> ...]<DD>
9540 The <I>arg</I>s are read and concatenated together into a single
9541 command. This command is then read and executed by the shell, and
9542 its exit status is returned as the value of
9543 <B>eval</B>.
9544
9545 If there are no
9546 <I>args</I>,
9547
9548 or only null arguments,
9549 <B>eval</B>
9550
9551 returns 0.
9552 <DT><B>exec</B> [<B>-cl</B>] [<B>-a</B> <I>name</I>] [<I>command</I> [<I>arguments</I>]]<DD>
9553 If
9554 <I>command</I>
9555
9556 is specified, it replaces the shell.
9557 No new process is created. The
9558 <I>arguments</I>
9559
9560 become the arguments to <I>command</I>.
9561 If the
9562 <B>-l</B>
9563
9564 option is supplied,
9565 the shell places a dash at the beginning of the zeroth argument passed to
9566 <I>command</I>.
9567
9568 This is what
9569 <I>login</I>(1)
9570
9571 does. The
9572 <B>-c</B>
9573
9574 option causes
9575 <I>command</I>
9576
9577 to be executed with an empty environment. If
9578 <B>-a</B>
9579
9580 is supplied, the shell passes
9581 <I>name</I>
9582
9583 as the zeroth argument to the executed command. If
9584 <I>command</I>
9585
9586 cannot be executed for some reason, a non-interactive shell exits,
9587 unless the shell option
9588 <B>execfail</B>
9589
9590 is enabled, in which case it returns failure.
9591 An interactive shell returns failure if the file cannot be executed.
9592 If
9593 <I>command</I>
9594
9595 is not specified, any redirections take effect in the current shell,
9596 and the return status is 0. If there is a redirection error, the
9597 return status is 1.
9598 <DT><B>exit</B> [<I>n</I>]<DD>
9599 Cause the shell to exit
9600 with a status of <I>n</I>. If
9601 <I>n</I>
9602
9603 is omitted, the exit status
9604 is that of the last command executed.
9605 A trap on
9606 <FONT SIZE=-1><B>EXIT</B>
9607
9608 </FONT>
9609 is executed before the shell terminates.
9610 <DT><B>export</B> [<B>-fn</B>] [<I>name</I>[=<I>word</I>]] ...<DD>
9611
9612 <DT><B>export -p</B>
9613
9614 <DD>
9615
9616 The supplied
9617 <I>names</I>
9618
9619 are marked for automatic export to the environment of
9620 subsequently executed commands. If the
9621 <B>-f</B>
9622
9623 option is given,
9624 the
9625 <I>names</I>
9626
9627 refer to functions.
9628 If no
9629 <I>names</I>
9630
9631 are given, or if the
9632 <B>-p</B>
9633
9634 option is supplied, a list
9635 of all names that are exported in this shell is printed.
9636 The
9637 <B>-n</B>
9638
9639 option causes the export property to be removed from each
9640 <I>name</I>.
9641 If a variable name is followed by =<I>word</I>, the value of
9642 the variable is set to <I>word</I>.
9643 <B>export</B>
9644
9645 returns an exit status of 0 unless an invalid option is
9646 encountered,
9647 one of the <I>names</I> is not a valid shell variable name, or
9648 <B>-f</B>
9649
9650 is supplied with a
9651 <I>name</I>
9652
9653 that is not a function.
9654 <DT><B>fc</B> [<B>-e</B> <I>ename</I>] [<B>-lnr</B>] [<I>first</I>] [<I>last</I>]<DD>
9655
9656 <DT><B>fc</B> <B>-s</B> [<I>pat</I>=<I>rep</I>] [<I>cmd</I>]<DD>
9657
9658 Fix Command. In the first form, a range of commands from
9659 <I>first</I>
9660
9661 to
9662 <I>last</I>
9663
9664 is selected from the history list.
9665 <I>First</I>
9666
9667 and
9668 <I>last</I>
9669
9670 may be specified as a string (to locate the last command beginning
9671 with that string) or as a number (an index into the history list,
9672 where a negative number is used as an offset from the current
9673 command number). If
9674 <I>last</I>
9675
9676 is not specified it is set to
9677 the current command for listing (so that
9678
9679 <TT>fc -l -10</TT>
9680 prints the last 10 commands) and to
9681 <I>first</I>
9682
9683 otherwise.
9684 If
9685 <I>first</I>
9686
9687 is not specified it is set to the previous
9688 command for editing and -16 for listing.
9689 <P>
9690 The
9691 <B>-n</B>
9692
9693 option suppresses
9694 the command numbers when listing. The
9695 <B>-r</B>
9696
9697 option reverses the order of
9698 the commands. If the
9699 <B>-l</B>
9700
9701 option is given,
9702 the commands are listed on
9703 standard output. Otherwise, the editor given by
9704 <I>ename</I>
9705
9706 is invoked
9707 on a file containing those commands. If
9708 <I>ename</I>
9709
9710 is not given, the
9711 value of the
9712 <FONT SIZE=-1><B>FCEDIT</B>
9713
9714 </FONT>
9715 variable is used, and
9716 the value of
9717 <FONT SIZE=-1><B>EDITOR</B>
9718
9719 </FONT>
9720 if
9721 <FONT SIZE=-1><B>FCEDIT</B>
9722
9723 </FONT>
9724 is not set. If neither variable is set,
9725
9726 <I>vi</I>
9727
9728 is used. When editing is complete, the edited commands are
9729 echoed and executed.
9730 <P>
9731 In the second form, <I>command</I> is re-executed after each instance
9732 of <I>pat</I> is replaced by <I>rep</I>.
9733 A useful alias to use with this is
9734
9735 <TT>r='fc -s'</TT>,
9736 so that typing
9737
9738 <TT>r cc</TT>
9739 runs the last command beginning with
9740
9741 <TT>cc</TT>
9742 and typing
9743
9744 <TT>r</TT>
9745 re-executes the last command.
9746 <P>
9747 If the first form is used, the return value is 0 unless an invalid
9748 option is encountered or
9749 <I>first</I>
9750
9751 or
9752 <I>last</I>
9753
9754 specify history lines out of range.
9755 If the
9756 <B>-e</B>
9757
9758 option is supplied, the return value is the value of the last
9759 command executed or failure if an error occurs with the temporary
9760 file of commands. If the second form is used, the return status
9761 is that of the command re-executed, unless
9762 <I>cmd</I>
9763
9764 does not specify a valid history line, in which case
9765 <B>fc</B>
9766
9767 returns failure.
9768 <DT><B>fg</B> [<I>jobspec</I>]<DD>
9769 Resume
9770 <I>jobspec</I>
9771
9772 in the foreground, and make it the current job.
9773 If
9774 <I>jobspec</I>
9775
9776 is not present, the shell's notion of the <I>current job</I> is used.
9777 The return value is that of the command placed into the foreground,
9778 or failure if run when job control is disabled or, when run with
9779 job control enabled, if
9780 <I>jobspec</I>
9781
9782 does not specify a valid job or
9783 <I>jobspec</I>
9784
9785 specifies a job that was started without job control.
9786 <DT><B>getopts</B> <I>optstring</I> <I>name</I> [<I>args</I>]<DD>
9787 <B>getopts</B>
9788
9789 is used by shell procedures to parse positional parameters.
9790 <I>optstring</I>
9791
9792 contains the option characters to be recognized; if a character
9793 is followed by a colon, the option is expected to have an
9794 argument, which should be separated from it by white space.
9795 The colon and question mark characters may not be used as
9796 option characters.
9797 Each time it is invoked,
9798 <B>getopts</B>
9799
9800 places the next option in the shell variable
9801 <I>name</I>,
9802
9803 initializing
9804 <I>name</I>
9805
9806 if it does not exist,
9807 and the index of the next argument to be processed into the
9808 variable
9809 <FONT SIZE=-1><B>OPTIND</B>.
9810
9811 </FONT>
9812 <FONT SIZE=-1><B>OPTIND</B>
9813
9814 </FONT>
9815 is initialized to 1 each time the shell or a shell script
9816 is invoked. When an option requires an argument,
9817 <B>getopts</B>
9818
9819 places that argument into the variable
9820 <FONT SIZE=-1><B>OPTARG</B>.
9821
9822 </FONT>
9823 The shell does not reset
9824 <FONT SIZE=-1><B>OPTIND</B>
9825
9826 </FONT>
9827 automatically; it must be manually reset between multiple
9828 calls to
9829 <B>getopts</B>
9830
9831 within the same shell invocation if a new set of parameters
9832 is to be used.
9833 <P>
9834 When the end of options is encountered, <B>getopts</B> exits with a
9835 return value greater than zero.
9836 <FONT SIZE=-1><B>OPTIND</B>
9837
9838 </FONT>
9839 is set to the index of the first non-option argument,
9840 and <I>name</I> is set to ?.
9841 <P>
9842 <B>getopts</B>
9843
9844 normally parses the positional parameters, but if more arguments are
9845 given in
9846 <I>args</I>,
9847
9848 <B>getopts</B>
9849
9850 parses those instead.
9851 <P>
9852 <B>getopts</B>
9853
9854 can report errors in two ways. If the first character of
9855 <I>optstring</I>
9856
9857 is a colon,
9858 <I>silent</I>
9859
9860 error reporting is used. In normal operation diagnostic messages
9861 are printed when invalid options or missing option arguments are
9862 encountered.
9863 If the variable
9864 <FONT SIZE=-1><B>OPTERR</B>
9865
9866 </FONT>
9867 is set to 0, no error messages will be displayed, even if the first
9868 character of
9869 <I>optstring</I>
9870
9871 is not a colon.
9872 <P>
9873 If an invalid option is seen,
9874 <B>getopts</B>
9875
9876 places ? into
9877 <I>name</I>
9878
9879 and, if not silent,
9880 prints an error message and unsets
9881 <FONT SIZE=-1><B>OPTARG</B>.
9882
9883 </FONT>
9884 If
9885 <B>getopts</B>
9886
9887 is silent,
9888 the option character found is placed in
9889 <FONT SIZE=-1><B>OPTARG</B>
9890
9891 </FONT>
9892 and no diagnostic message is printed.
9893 <P>
9894 If a required argument is not found, and
9895 <B>getopts</B>
9896
9897 is not silent,
9898 a question mark (<B>?</B>) is placed in
9899 <I>name</I>,
9900
9901 <FONT SIZE=-1><B>OPTARG</B>
9902
9903 </FONT>
9904 is unset, and a diagnostic message is printed.
9905 If
9906 <B>getopts</B>
9907
9908 is silent, then a colon (<B>:</B>) is placed in
9909 <I>name</I>
9910
9911 and
9912 <FONT SIZE=-1><B>OPTARG</B>
9913
9914 </FONT>
9915 is set to the option character found.
9916 <P>
9917 <B>getopts</B>
9918
9919 returns true if an option, specified or unspecified, is found.
9920 It returns false if the end of options is encountered or an
9921 error occurs.
9922 <DT><B>hash</B> [<B>-lr</B>] [<B>-p</B> <I>filename</I>] [<B>-dt</B>] [<I>name</I>]<DD>
9923 Each time <B>hash</B> is invoked,
9924 the full pathname of the command
9925 <I>name</I>
9926
9927 is determined by searching
9928 the directories in
9929 <B>$PATH</B>
9930
9931 and remembered. Any previously-remembered pathname is discarded.
9932 If the
9933 <B>-p</B>
9934
9935 option is supplied, no path search is performed, and
9936 <I>filename</I>
9937
9938 is used as the full file name of the command.
9939 The
9940 <B>-r</B>
9941
9942 option causes the shell to forget all
9943 remembered locations.
9944 The
9945 <B>-d</B>
9946
9947 option causes the shell to forget the remembered location of each <I>name</I>.
9948 If the
9949 <B>-t</B>
9950
9951 option is supplied, the full pathname to which each <I>name</I> corresponds
9952 is printed. If multiple <I>name</I> arguments are supplied with <B>-t</B>,
9953 the <I>name</I> is printed before the hashed full pathname.
9954 The
9955 <B>-l</B>
9956
9957 option causes output to be displayed in a format that may be reused as input.
9958 If no arguments are given, or if only <B>-l</B> is supplied,
9959 information about remembered commands is printed.
9960 The return status is true unless a
9961 <I>name</I>
9962
9963 is not found or an invalid option is supplied.
9964 <DT><B>help</B> [<B>-dms</B>] [<I>pattern</I>]<DD>
9965 Display helpful information about builtin commands. If
9966 <I>pattern</I>
9967
9968 is specified,
9969 <B>help</B>
9970
9971 gives detailed help on all commands matching
9972 <I>pattern</I>;
9973
9974 otherwise help for all the builtins and shell control structures
9975 is printed.
9976 <DL COMPACT><DT><DD>
9977
9978 <DL COMPACT>
9979 <DT><B>-d</B>
9980
9981 <DD>
9982 Display a short description of each <I>pattern</I>
9983 <DT><B>-m</B>
9984
9985 <DD>
9986 Display the description of each <I>pattern</I> in a manpage-like format
9987 <DT><B>-s</B>
9988
9989 <DD>
9990 Display only a short usage synopsis for each <I>pattern</I>
9991
9992 </DL></DL>
9993
9994 The return status is 0 unless no command matches
9995 <I>pattern</I>.
9996
9997 <DT><B>history [</B><I>n</I>]<DD>
9998
9999 <DT><B>history</B> <B>-c</B><DD>
10000 <DT><B>history -d</B> <I>offset</I><DD>
10001 <DT><B>history</B> <B>-anrw</B> [<I>filename</I>]<DD>
10002 <DT><B>history</B> <B>-p</B> <I>arg</I> [<I>arg ...</I>]<DD>
10003 <DT><B>history</B> <B>-s</B> <I>arg</I> [<I>arg ...</I>]<DD>
10004
10005 With no options, display the command
10006 history list with line numbers. Lines listed
10007 with a
10008 <B>*</B>
10009
10010 have been modified. An argument of
10011 <I>n</I>
10012
10013 lists only the last
10014 <I>n</I>
10015
10016 lines.
10017 If the shell variable
10018 <FONT SIZE=-1><B>HISTTIMEFORMAT</B>
10019
10020 </FONT>
10021 is set and not null,
10022 it is used as a format string for <I>strftime</I>(3) to display
10023 the time stamp associated with each displayed history entry.
10024 No intervening blank is printed between the formatted time stamp
10025 and the history line.
10026 If <I>filename</I> is supplied, it is used as the
10027 name of the history file; if not, the value of
10028 <FONT SIZE=-1><B>HISTFILE</B>
10029
10030 </FONT>
10031 is used. Options, if supplied, have the following meanings:
10032 <DL COMPACT><DT><DD>
10033
10034 <DL COMPACT>
10035 <DT><B>-c</B>
10036
10037 <DD>
10038 Clear the history list by deleting all the entries.
10039 <DT><B>-d</B> <I>offset</I><DD>
10040 Delete the history entry at position <I>offset</I>.
10041 <DT><B>-a</B>
10042
10043 <DD>
10044 Append the ``new'' history lines (history lines entered since the
10045 beginning of the current <B>bash</B> session) to the history file.
10046 <DT><B>-n</B>
10047
10048 <DD>
10049 Read the history lines not already read from the history
10050 file into the current history list. These are lines
10051 appended to the history file since the beginning of the
10052 current <B>bash</B> session.
10053 <DT><B>-r</B>
10054
10055 <DD>
10056 Read the contents of the history file
10057 and use them as the current history.
10058 <DT><B>-w</B>
10059
10060 <DD>
10061 Write the current history to the history file, overwriting the
10062 history file's contents.
10063 <DT><B>-p</B>
10064
10065 <DD>
10066 Perform history substitution on the following <I>args</I> and display
10067 the result on the standard output.
10068 Does not store the results in the history list.
10069 Each <I>arg</I> must be quoted to disable normal history expansion.
10070 <DT><B>-s</B>
10071
10072 <DD>
10073 Store the
10074 <I>args</I>
10075
10076 in the history list as a single entry. The last command in the
10077 history list is removed before the
10078 <I>args</I>
10079
10080 are added.
10081
10082 </DL>
10083 <P>
10084
10085 If the
10086 <FONT SIZE=-1><B>HISTTIMEFORMAT</B>
10087
10088 </FONT>
10089 variable is set, the time stamp information
10090 associated with each history entry is written to the history file,
10091 marked with the history comment character.
10092 When the history file is read, lines beginning with the history
10093 comment character followed immediately by a digit are interpreted
10094 as timestamps for the previous history line.
10095 The return value is 0 unless an invalid option is encountered, an
10096 error occurs while reading or writing the history file, an invalid
10097 <I>offset</I> is supplied as an argument to <B>-d</B>, or the
10098 history expansion supplied as an argument to <B>-p</B> fails.
10099 </DL>
10100
10101 <DT><B>jobs</B> [<B>-lnprs</B>] [ <I>jobspec</I> ... ]<DD>
10102
10103 <DT><B>jobs</B> <B>-x</B> <I>command</I> [ <I>args</I> ... ]<DD>
10104
10105 The first form lists the active jobs. The options have the following
10106 meanings:
10107 <DL COMPACT><DT><DD>
10108
10109 <DL COMPACT>
10110 <DT><B>-l</B>
10111
10112 <DD>
10113 List process IDs
10114 in addition to the normal information.
10115 <DT><B>-n</B>
10116
10117 <DD>
10118 Display information only about jobs that have changed status since
10119 the user was last notified of their status.
10120 <DT><B>-p</B>
10121
10122 <DD>
10123 List only the process ID of the job's process group
10124 leader.
10125 <DT><B>-r</B>
10126
10127 <DD>
10128 Restrict output to running jobs.
10129 <DT><B>-s</B>
10130
10131 <DD>
10132 Restrict output to stopped jobs.
10133
10134 </DL>
10135 <P>
10136
10137 If
10138 <I>jobspec</I>
10139
10140 is given, output is restricted to information about that job.
10141 The return status is 0 unless an invalid option is encountered
10142 or an invalid
10143 <I>jobspec</I>
10144
10145 is supplied.
10146 <P>
10147
10148 If the
10149 <B>-x</B>
10150
10151 option is supplied,
10152 <B>jobs</B>
10153
10154 replaces any
10155 <I>jobspec</I>
10156
10157 found in
10158 <I>command</I>
10159
10160 or
10161 <I>args</I>
10162
10163 with the corresponding process group ID, and executes
10164 <I>command</I>
10165
10166 passing it
10167 <I>args</I>,
10168
10169 returning its exit status.
10170 </DL>
10171
10172 <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>
10173
10174 <DT><B>kill</B> <B>-l</B> [<I>sigspec</I> | <I>exit_status</I>]<DD>
10175
10176 Send the signal named by
10177 <I>sigspec</I>
10178
10179 or
10180 <I>signum</I>
10181
10182 to the processes named by
10183 <I>pid</I>
10184
10185 or
10186 <I>jobspec</I>.
10187
10188 <I>sigspec</I>
10189
10190 is either a case-insensitive signal name such as
10191 <FONT SIZE=-1><B>SIGKILL</B>
10192
10193 </FONT>
10194 (with or without the
10195 <FONT SIZE=-1><B>SIG</B>
10196
10197 </FONT>
10198 prefix) or a signal number;
10199 <I>signum</I>
10200
10201 is a signal number.
10202 If
10203 <I>sigspec</I>
10204
10205 is not present, then
10206 <FONT SIZE=-1><B>SIGTERM</B>
10207
10208 </FONT>
10209 is assumed.
10210 An argument of
10211 <B>-l</B>
10212
10213 lists the signal names.
10214 If any arguments are supplied when
10215 <B>-l</B>
10216
10217 is given, the names of the signals corresponding to the arguments are
10218 listed, and the return status is 0.
10219 The <I>exit_status</I> argument to
10220 <B>-l</B>
10221
10222 is a number specifying either a signal number or the exit status of
10223 a process terminated by a signal.
10224 <B>kill</B>
10225
10226 returns true if at least one signal was successfully sent, or false
10227 if an error occurs or an invalid option is encountered.
10228 <DT><B>let</B> <I>arg</I> [<I>arg</I> ...]<DD>
10229 Each
10230 <I>arg</I>
10231
10232 is an arithmetic expression to be evaluated (see
10233 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
10234
10235 </FONT>
10236 above).
10237 If the last
10238 <I>arg</I>
10239
10240 evaluates to 0,
10241 <B>let</B>
10242
10243 returns 1; 0 is returned otherwise.
10244 <DT><B>local</B> [<I>option</I>] [<I>name</I>[=<I>value</I>] ...]<DD>
10245 For each argument, a local variable named
10246 <I>name </I>
10247
10248 is created, and assigned
10249 <I>value</I>.
10250
10251 The <I>option</I> can be any of the options accepted by <B>declare</B>.
10252 When
10253 <B>local</B>
10254
10255 is used within a function, it causes the variable
10256 <I>name</I>
10257
10258 to have a visible scope restricted to that function and its children.
10259 With no operands,
10260 <B>local</B>
10261
10262 writes a list of local variables to the standard output. It is
10263 an error to use
10264 <B>local</B>
10265
10266 when not within a function. The return status is 0 unless
10267 <B>local</B>
10268
10269 is used outside a function, an invalid
10270 <I>name</I>
10271
10272 is supplied, or
10273 <I>name</I> is a readonly variable.
10274 <DT><B>logout</B>
10275
10276 <DD>
10277 Exit a login shell.
10278 <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>
10279
10280 <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>
10281
10282 Read lines from the standard input into the indexed array variable
10283 <I>array</I>,
10284
10285 or from file descriptor
10286 <I>fd</I>
10287
10288 if the
10289 <B>-u</B>
10290
10291 option is supplied.
10292 The variable
10293 <FONT SIZE=-1><B>MAPFILE</B>
10294
10295 </FONT>
10296 is the default <I>array</I>.
10297 Options, if supplied, have the following meanings:
10298 <DL COMPACT><DT><DD>
10299
10300 <DL COMPACT>
10301 <DT><B>-n</B>
10302
10303 <DD>
10304 Copy at most
10305 <I>count</I>
10306
10307 lines. If <I>count</I> is 0, all lines are copied.
10308 <DT><B>-O</B>
10309
10310 <DD>
10311 Begin assigning to
10312 <I>array</I>
10313
10314 at index
10315 <I>origin</I>.
10316
10317 The default index is 0.
10318 <DT><B>-s</B>
10319
10320 <DD>
10321 Discard the first <I>count</I> lines read.
10322 <DT><B>-t</B>
10323
10324 <DD>
10325 Remove a trailing newline from each line read.
10326 <DT><B>-u</B>
10327
10328 <DD>
10329 Read lines from file descriptor <I>fd</I> instead of the standard input.
10330 <DT><B>-C</B>
10331
10332 <DD>
10333 Evaluate
10334 <I>callback</I>
10335
10336 each time <I>quantum</I> lines are read. The <B>-c</B> option specifies
10337 <I>quantum</I>.
10338
10339 <DT><B>-c</B>
10340
10341 <DD>
10342 Specify the number of lines read between each call to
10343 <I>callback</I>.
10344
10345
10346 </DL>
10347 <P>
10348
10349 If
10350 <B>-C</B>
10351
10352 is specified without
10353 <B>-c</B>,
10354
10355 the default quantum is 5000.
10356 When <I>callback</I> is evaluated, it is supplied the index of the next
10357 array element to be assigned and the line to be assigned to that element
10358 as additional arguments.
10359 <I>callback</I> is evaluated after the line is read but before the
10360 array element is assigned.
10361 <P>
10362
10363 If not supplied with an explicit origin, <B>mapfile</B> will clear <I>array</I>
10364 before assigning to it.
10365 <P>
10366
10367 <B>mapfile</B> returns successfully unless an invalid option or option
10368 argument is supplied, <I>array</I> is invalid or unassignable, or if
10369 <I>array</I> is not an indexed array.
10370 </DL>
10371
10372 <DT><B>popd</B> [-<B>n</B>] [+<I>n</I>] [-<I>n</I>]<DD>
10373 Removes entries from the directory stack. With no arguments,
10374 removes the top directory from the stack, and performs a
10375 <B>cd</B>
10376
10377 to the new top directory.
10378 Arguments, if supplied, have the following meanings:
10379 <DL COMPACT><DT><DD>
10380
10381 <DL COMPACT>
10382 <DT><B>-n</B>
10383
10384 <DD>
10385 Suppresses the normal change of directory when removing directories
10386 from the stack, so that only the stack is manipulated.
10387 <DT><B>+</B><I>n</I><DD>
10388 Removes the <I>n</I>th entry counting from the left of the list
10389 shown by
10390 <B>dirs</B>,
10391
10392 starting with zero. For example:
10393
10394 <TT>popd +0</TT>
10395 removes the first directory,
10396
10397 <TT>popd +1</TT>
10398 the second.
10399 <DT><B>-</B><I>n</I><DD>
10400 Removes the <I>n</I>th entry counting from the right of the list
10401 shown by
10402 <B>dirs</B>,
10403
10404 starting with zero. For example:
10405
10406 <TT>popd -0</TT>
10407 removes the last directory,
10408
10409 <TT>popd -1</TT>
10410 the next to last.
10411
10412 </DL>
10413 <P>
10414
10415 If the
10416 <B>popd</B>
10417
10418 command is successful, a
10419 <B>dirs</B>
10420
10421 is performed as well, and the return status is 0.
10422 <B>popd</B>
10423
10424 returns false if an invalid option is encountered, the directory stack
10425 is empty, a non-existent directory stack entry is specified, or the
10426 directory change fails.
10427 </DL>
10428
10429 <DT><B>printf</B> [<B>-v</B> <I>var</I>] <I>format</I> [<I>arguments</I>]<DD>
10430 Write the formatted <I>arguments</I> to the standard output under the
10431 control of the <I>format</I>.
10432 The <B>-v</B> option causes the output to be assigned to the variable
10433 <I>var</I> rather than being printed to the standard output.
10434 <P>
10435 The <I>format</I> is a character string which contains three types of objects:
10436 plain characters, which are simply copied to standard output, character
10437 escape sequences, which are converted and copied to the standard output, and
10438 format specifications, each of which causes printing of the next successive
10439 <I>argument</I>.
10440 In addition to the standard <I>printf</I>(1) format specifications,
10441 <B>printf</B> interprets the following extensions:
10442 <DL COMPACT><DT><DD>
10443
10444 <DL COMPACT>
10445 <DT><B>%b</B>
10446
10447 <DD>
10448 causes
10449 <B>printf</B> to expand backslash escape sequences in the corresponding
10450 <I>argument</I> (except that <B>\c</B> terminates output, backslashes in
10451 <B>\aq</B>, <B>\&quot;</B>, and <B>\?</B> are not removed, and octal escapes
10452 beginning with <B>\0</B> may contain up to four digits).
10453 <DT><B>%q</B>
10454
10455 <DD>
10456 causes <B>printf</B> to output the corresponding
10457 <I>argument</I> in a format that can be reused as shell input.
10458 <DT><B>%(</B><I>datefmt</I>)T
10459
10460 <DD>
10461 causes <B>printf</B> to output the date-time string resulting from using
10462 <I>datefmt</I> as a format string for <I>strftime</I>(3). The corresponding
10463 <I>argument</I> is an integer representing the number of seconds since the
10464 epoch. Two special argument values may be used: -1 represents the current
10465 time, and -2 represents the time the shell was invoked.
10466
10467 </DL>
10468 <P>
10469
10470 Arguments to non-string format specifiers are treated as C constants,
10471 except that a leading plus or minus sign is allowed, and if the leading
10472 character is a single or double quote, the value is the ASCII value of
10473 the following character.
10474 <P>
10475
10476 The <I>format</I> is reused as necessary to consume all of the <I>arguments</I>.
10477 If the <I>format</I> requires more <I>arguments</I> than are supplied, the
10478 extra format specifications behave as if a zero value or null string, as
10479 appropriate, had been supplied.
10480 The return value is zero on success, non-zero on failure.
10481 </DL>
10482
10483 <DT><B>pushd</B> [<B>-n</B>] [+<I>n</I>] [-<I>n</I>]<DD>
10484
10485 <DT><B>pushd</B> [<B>-n</B>] [<I>dir</I>]<DD>
10486
10487 Adds a directory to the top of the directory stack, or rotates
10488 the stack, making the new top of the stack the current working
10489 directory. With no arguments, exchanges the top two directories
10490 and returns 0, unless the directory stack is empty.
10491 Arguments, if supplied, have the following meanings:
10492 <DL COMPACT><DT><DD>
10493
10494 <DL COMPACT>
10495 <DT><B>-n</B>
10496
10497 <DD>
10498 Suppresses the normal change of directory when adding directories
10499 to the stack, so that only the stack is manipulated.
10500 <DT><B>+</B><I>n</I><DD>
10501 Rotates the stack so that the <I>n</I>th directory
10502 (counting from the left of the list shown by
10503 <B>dirs</B>,
10504
10505 starting with zero)
10506 is at the top.
10507 <DT><B>-</B><I>n</I><DD>
10508 Rotates the stack so that the <I>n</I>th directory
10509 (counting from the right of the list shown by
10510 <B>dirs</B>,
10511
10512 starting with zero) is at the top.
10513 <DT><I>dir</I>
10514
10515 <DD>
10516 Adds
10517 <I>dir</I>
10518
10519 to the directory stack at the top, making it the
10520 new current working directory.
10521
10522 </DL>
10523 <P>
10524
10525 If the
10526 <B>pushd</B>
10527
10528 command is successful, a
10529 <B>dirs</B>
10530
10531 is performed as well.
10532 If the first form is used,
10533 <B>pushd</B>
10534
10535 returns 0 unless the cd to
10536 <I>dir</I>
10537
10538 fails. With the second form,
10539 <B>pushd</B>
10540
10541 returns 0 unless the directory stack is empty,
10542 a non-existent directory stack element is specified,
10543 or the directory change to the specified new current directory
10544 fails.
10545 </DL>
10546
10547 <DT><B>pwd</B> [<B>-LP</B>]<DD>
10548 Print the absolute pathname of the current working directory.
10549 The pathname printed contains no symbolic links if the
10550 <B>-P</B>
10551
10552 option is supplied or the
10553 <B>-o physical</B>
10554
10555 option to the
10556 <B>set</B>
10557
10558 builtin command is enabled.
10559 If the
10560 <B>-L</B>
10561
10562 option is used, the pathname printed may contain symbolic links.
10563 The return status is 0 unless an error occurs while
10564 reading the name of the current directory or an
10565 invalid option is supplied.
10566 <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>
10567 One line is read from the standard input, or from the file descriptor
10568 <I>fd</I> supplied as an argument to the <B>-u</B> option, and the first word
10569 is assigned to the first
10570 <I>name</I>,
10571
10572 the second word to the second
10573 <I>name</I>,
10574
10575 and so on, with leftover words and their intervening separators assigned
10576 to the last
10577 <I>name</I>.
10578
10579 If there are fewer words read from the input stream than names,
10580 the remaining names are assigned empty values.
10581 The characters in
10582 <FONT SIZE=-1><B>IFS</B>
10583
10584 </FONT>
10585 are used to split the line into words.
10586 The backslash character (<B>\</B>) may be used to remove any special
10587 meaning for the next character read and for line continuation.
10588 Options, if supplied, have the following meanings:
10589 <DL COMPACT><DT><DD>
10590
10591 <DL COMPACT>
10592 <DT><B>-a </B><I>aname</I>
10593
10594 <DD>
10595 The words are assigned to sequential indices
10596 of the array variable
10597 <I>aname</I>,
10598
10599 starting at 0.
10600 <I>aname</I>
10601
10602 is unset before any new values are assigned.
10603 Other <I>name</I> arguments are ignored.
10604 <DT><B>-d </B><I>delim</I>
10605
10606 <DD>
10607 The first character of <I>delim</I> is used to terminate the input line,
10608 rather than newline.
10609 <DT><B>-e</B>
10610
10611 <DD>
10612 If the standard input
10613 is coming from a terminal,
10614 <B>readline</B>
10615
10616 (see
10617 <FONT SIZE=-1><B>READLINE</B>
10618
10619 </FONT>
10620 above) is used to obtain the line.
10621 Readline uses the current (or default, if line editing was not previously
10622 active) editing settings.
10623 <DT><B>-i </B><I>text</I>
10624
10625 <DD>
10626 If
10627 <B>readline</B>
10628
10629 is being used to read the line, <I>text</I> is placed into the editing
10630 buffer before editing begins.
10631 <DT><B>-n </B><I>nchars</I>
10632
10633 <DD>
10634 <B>read</B> returns after reading <I>nchars</I> characters rather than
10635 waiting for a complete line of input, but honor a delimiter if fewer
10636 than <I>nchars</I> characters are read before the delimiter.
10637 <DT><B>-N </B><I>nchars</I>
10638
10639 <DD>
10640 <B>read</B> returns after reading exactly <I>nchars</I> characters rather
10641 than waiting for a complete line of input, unless EOF is encountered or
10642 <B>read</B> times out.
10643 Delimiter characters encountered in the input are
10644 not treated specially and do not cause <B>read</B> to return until
10645 <I>nchars</I> characters are read.
10646 <DT><B>-p </B><I>prompt</I>
10647
10648 <DD>
10649 Display <I>prompt</I> on standard error, without a
10650 trailing newline, before attempting to read any input. The prompt
10651 is displayed only if input is coming from a terminal.
10652 <DT><B>-r</B>
10653
10654 <DD>
10655 Backslash does not act as an escape character.
10656 The backslash is considered to be part of the line.
10657 In particular, a backslash-newline pair may not be used as a line
10658 continuation.
10659 <DT><B>-s</B>
10660
10661 <DD>
10662 Silent mode. If input is coming from a terminal, characters are
10663 not echoed.
10664 <DT><B>-t </B><I>timeout</I>
10665
10666 <DD>
10667 Cause <B>read</B> to time out and return failure if a complete line of
10668 input is not read within <I>timeout</I> seconds.
10669 <I>timeout</I> may be a decimal number with a fractional portion following
10670 the decimal point.
10671 This option is only effective if <B>read</B> is reading input from a
10672 terminal, pipe, or other special file; it has no effect when reading
10673 from regular files.
10674 If <I>timeout</I> is 0, <B>read</B> returns success if input is available on
10675 the specified file descriptor, failure otherwise.
10676 The exit status is greater than 128 if the timeout is exceeded.
10677 <DT><B>-u </B><I>fd</I>
10678
10679 <DD>
10680 Read input from file descriptor <I>fd</I>.
10681
10682 </DL>
10683 <P>
10684
10685 If no
10686 <I>names</I>
10687
10688 are supplied, the line read is assigned to the variable
10689 <FONT SIZE=-1><B>REPLY</B>.
10690
10691 </FONT>
10692 The return code is zero, unless end-of-file is encountered, <B>read</B>
10693 times out (in which case the return code is greater than 128), or an
10694 invalid file descriptor is supplied as the argument to <B>-u</B>.
10695 </DL>
10696
10697 <DT><B>readonly</B> [<B>-aApf</B>] [<I>name</I>[=<I>word</I>] ...]<DD>
10698
10699 The given
10700 <I>names</I> are marked readonly; the values of these
10701 <I>names</I>
10702
10703 may not be changed by subsequent assignment.
10704 If the
10705 <B>-f</B>
10706
10707 option is supplied, the functions corresponding to the
10708 <I>names</I> are so
10709 marked.
10710 The
10711 <B>-a</B>
10712
10713 option restricts the variables to indexed arrays; the
10714 <B>-A</B>
10715
10716 option restricts the variables to associative arrays.
10717 If no
10718 <I>name</I>
10719
10720 arguments are given, or if the
10721 <B>-p</B>
10722
10723 option is supplied, a list of all readonly names is printed.
10724 The
10725 <B>-p</B>
10726
10727 option causes output to be displayed in a format that
10728 may be reused as input.
10729 If a variable name is followed by =<I>word</I>, the value of
10730 the variable is set to <I>word</I>.
10731 The return status is 0 unless an invalid option is encountered,
10732 one of the
10733 <I>names</I>
10734
10735 is not a valid shell variable name, or
10736 <B>-f</B>
10737
10738 is supplied with a
10739 <I>name</I>
10740
10741 that is not a function.
10742 <DT><B>return</B> [<I>n</I>]<DD>
10743 Causes a function to exit with the return value specified by
10744 <I>n</I>.
10745
10746 If
10747 <I>n</I>
10748
10749 is omitted, the return status is that of the last command
10750 executed in the function body. If used outside a function,
10751 but during execution of a script by the
10752 <B>.</B>
10753
10754 (<B>source</B>) command, it causes the shell to stop executing
10755 that script and return either
10756 <I>n</I>
10757
10758 or the exit status of the last command executed within the
10759 script as the exit status of the script. If used outside a
10760 function and not during execution of a script by <B>.</B>,
10761 the return status is false.
10762 Any command associated with the <B>RETURN</B> trap is executed
10763 before execution resumes after the function or script.
10764 <DT><B>set</B> [<B>--abefhkmnptuvxBCEHPT</B>] [<B>-o</B> <I>option-name</I>] [<I>arg</I> ...]<DD>
10765
10766 <DT><B>set</B> [<B>+abefhkmnptuvxBCEHPT</B>] [<B>+o</B> <I>option-name</I>] [<I>arg</I> ...]<DD>
10767
10768 Without options, the name and value of each shell variable are displayed
10769 in a format that can be reused as input
10770 for setting or resetting the currently-set variables.
10771 Read-only variables cannot be reset.
10772 In <I>posix mode</I>, only shell variables are listed.
10773 The output is sorted according to the current locale.
10774 When options are specified, they set or unset shell attributes.
10775 Any arguments remaining after option processing are treated
10776 as values for the positional parameters and are assigned, in order, to
10777 <B>$1</B>,
10778
10779 <B>$2</B>,
10780
10781 <B>...</B>
10782
10783 <B>$</B><I>n</I>.
10784
10785 Options, if specified, have the following meanings:
10786 <DL COMPACT><DT><DD>
10787
10788 <DL COMPACT>
10789 <DT><B>-a</B>
10790
10791 <DD>
10792 Automatically mark variables and functions which are modified or
10793 created for export to the environment of subsequent commands.
10794 <DT><B>-b</B>
10795
10796 <DD>
10797 Report the status of terminated background jobs
10798 immediately, rather than before the next primary prompt. This is
10799 effective only when job control is enabled.
10800 <DT><B>-e</B>
10801
10802 <DD>
10803 Exit immediately if a <I>pipeline</I> (which may consist of a single
10804 <I>simple command</I>), a <I>subshell</I> command enclosed in parentheses,
10805 or one of the commands executed as part of a command list enclosed
10806 by braces (see
10807 <FONT SIZE=-1><B>SHELL GRAMMAR</B>
10808
10809 </FONT>
10810 above) exits with a non-zero status.
10811 The shell does not exit if the
10812 command that fails is part of the command list immediately following a
10813 <B>while</B>
10814
10815 or
10816 <B>until</B>
10817
10818 keyword,
10819 part of the test following the
10820 <B>if</B>
10821
10822 or
10823 <B>elif</B>
10824
10825 reserved words, part of any command executed in a
10826 <B>&amp;&amp;</B>
10827
10828 or
10829 <B>||</B>
10830
10831 list except the command following the final <B>&amp;&amp;</B> or <B>||</B>,
10832 any command in a pipeline but the last,
10833 or if the command's return value is
10834 being inverted with
10835 <B>!</B>.
10836
10837 A trap on <B>ERR</B>, if set, is executed before the shell exits.
10838 This option applies to the shell environment and each subshell environment
10839 separately (see
10840 <FONT SIZE=-1><B>COMMAND EXECUTION ENVIRONMENT</B>
10841
10842 </FONT>
10843 above), and may cause
10844 subshells to exit before executing all the commands in the subshell.
10845 <DT><B>-f</B>
10846
10847 <DD>
10848 Disable pathname expansion.
10849 <DT><B>-h</B>
10850
10851 <DD>
10852 Remember the location of commands as they are looked up for execution.
10853 This is enabled by default.
10854 <DT><B>-k</B>
10855
10856 <DD>
10857 All arguments in the form of assignment statements
10858 are placed in the environment for a command, not just
10859 those that precede the command name.
10860 <DT><B>-m</B>
10861
10862 <DD>
10863 Monitor mode. Job control is enabled. This option is on
10864 by default for interactive shells on systems that support
10865 it (see
10866 <FONT SIZE=-1><B>JOB CONTROL</B>
10867
10868 </FONT>
10869 above). Background processes run in a separate process
10870 group and a line containing their exit status is printed
10871 upon their completion.
10872 <DT><B>-n</B>
10873
10874 <DD>
10875 Read commands but do not execute them. This may be used to
10876 check a shell script for syntax errors. This is ignored by
10877 interactive shells.
10878 <DT><B>-o </B><I>option-name</I>
10879
10880 <DD>
10881 The <I>option-name</I> can be one of the following:
10882 <DL COMPACT><DT><DD>
10883 <DL COMPACT>
10884 <DT><B>allexport</B>
10885
10886 <DD>
10887 Same as
10888 <B>-a</B>.
10889
10890 <DT><B>braceexpand</B>
10891
10892 <DD>
10893 Same as
10894 <B>-B</B>.
10895
10896 <DT><B>emacs</B>
10897
10898 <DD>
10899 Use an emacs-style command line editing interface. This is enabled
10900 by default when the shell is interactive, unless the shell is started
10901 with the
10902 <B>--noediting</B>
10903
10904 option.
10905 This also affects the editing interface used for <B>read -e</B>.
10906 <DT><B>errexit</B>
10907
10908 <DD>
10909 Same as
10910 <B>-e</B>.
10911
10912 <DT><B>errtrace</B>
10913
10914 <DD>
10915 Same as
10916 <B>-E</B>.
10917
10918 <DT><B>functrace</B>
10919
10920 <DD>
10921 Same as
10922 <B>-T</B>.
10923
10924 <DT><B>hashall</B>
10925
10926 <DD>
10927 Same as
10928 <B>-h</B>.
10929
10930 <DT><B>histexpand</B>
10931
10932 <DD>
10933 Same as
10934 <B>-H</B>.
10935
10936 <DT><B>history</B>
10937
10938 <DD>
10939 Enable command history, as described above under
10940 <FONT SIZE=-1><B>HISTORY</B>.
10941
10942 </FONT>
10943 This option is on by default in interactive shells.
10944 <DT><B>ignoreeof</B>
10945
10946 <DD>
10947 The effect is as if the shell command
10948 <TT>IGNOREEOF=10</TT>
10949
10950 had been executed
10951 (see
10952 <B>Shell Variables</B>
10953
10954 above).
10955 <DT><B>keyword</B>
10956
10957 <DD>
10958 Same as
10959 <B>-k</B>.
10960
10961 <DT><B>monitor</B>
10962
10963 <DD>
10964 Same as
10965 <B>-m</B>.
10966
10967 <DT><B>noclobber</B>
10968
10969 <DD>
10970 Same as
10971 <B>-C</B>.
10972
10973 <DT><B>noexec</B>
10974
10975 <DD>
10976 Same as
10977 <B>-n</B>.
10978
10979 <DT><B>noglob</B>
10980
10981 <DD>
10982 Same as
10983 <B>-f</B>.
10984
10985 <DT><B>nolog</B>
10986
10987 <DD>
10988 Currently ignored.
10989 <DT><B>notify</B>
10990
10991 <DD>
10992 Same as
10993 <B>-b</B>.
10994
10995 <DT><B>nounset</B>
10996
10997 <DD>
10998 Same as
10999 <B>-u</B>.
11000
11001 <DT><B>onecmd</B>
11002
11003 <DD>
11004 Same as
11005 <B>-t</B>.
11006
11007 <DT><B>physical</B>
11008
11009 <DD>
11010 Same as
11011 <B>-P</B>.
11012
11013 <DT><B>pipefail</B>
11014
11015 <DD>
11016 If set, the return value of a pipeline is the value of the last
11017 (rightmost) command to exit with a non-zero status, or zero if all
11018 commands in the pipeline exit successfully.
11019 This option is disabled by default.
11020 <DT><B>posix</B>
11021
11022 <DD>
11023 Change the behavior of
11024 <B>bash</B>
11025
11026 where the default operation differs
11027 from the POSIX standard to match the standard (<I>posix mode</I>).
11028 <DT><B>privileged</B>
11029
11030 <DD>
11031 Same as
11032 <B>-p</B>.
11033
11034 <DT><B>verbose</B>
11035
11036 <DD>
11037 Same as
11038 <B>-v</B>.
11039
11040 <DT><B>vi</B>
11041
11042 <DD>
11043 Use a vi-style command line editing interface.
11044 This also affects the editing interface used for <B>read -e</B>.
11045 <DT><B>xtrace</B>
11046
11047 <DD>
11048 Same as
11049 <B>-x</B>.
11050
11051 <P>
11052 </DL>
11053 <P>
11054
11055 If
11056 <B>-o</B>
11057
11058 is supplied with no <I>option-name</I>, the values of the current options are
11059 printed.
11060 If
11061 <B>+o</B>
11062
11063 is supplied with no <I>option-name</I>, a series of
11064 <B>set</B>
11065
11066 commands to recreate the current option settings is displayed on
11067 the standard output.
11068 </DL>
11069
11070 <DT><B>-p</B>
11071
11072 <DD>
11073 Turn on
11074 <I>privileged</I>
11075
11076 mode. In this mode, the
11077 <FONT SIZE=-1><B>$ENV</B>
11078
11079 </FONT>
11080 and
11081 <FONT SIZE=-1><B>$BASH_ENV</B>
11082
11083 </FONT>
11084 files are not processed, shell functions are not inherited from the
11085 environment, and the
11086 <FONT SIZE=-1><B>SHELLOPTS</B>,
11087
11088 </FONT>
11089 <FONT SIZE=-1><B>BASHOPTS</B>,
11090
11091 </FONT>
11092 <FONT SIZE=-1><B>CDPATH</B>,
11093
11094 </FONT>
11095 and
11096 <FONT SIZE=-1><B>GLOBIGNORE</B>
11097
11098 </FONT>
11099 variables, if they appear in the environment, are ignored.
11100 If the shell is started with the effective user (group) id not equal to the
11101 real user (group) id, and the <B>-p</B> option is not supplied, these actions
11102 are taken and the effective user id is set to the real user id.
11103 If the <B>-p</B> option is supplied at startup, the effective user id is
11104 not reset.
11105 Turning this option off causes the effective user
11106 and group ids to be set to the real user and group ids.
11107 <DT><B>-t</B>
11108
11109 <DD>
11110 Exit after reading and executing one command.
11111 <DT><B>-u</B>
11112
11113 <DD>
11114 Treat unset variables and parameters other than the special
11115 parameters &quot;@&quot; and &quot;*&quot; as an error when performing
11116 parameter expansion. If expansion is attempted on an
11117 unset variable or parameter, the shell prints an error message, and,
11118 if not interactive, exits with a non-zero status.
11119 <DT><B>-v</B>
11120
11121 <DD>
11122 Print shell input lines as they are read.
11123 <DT><B>-x</B>
11124
11125 <DD>
11126 After expanding each <I>simple command</I>,
11127 <B>for</B> command, <B>case</B> command, <B>select</B> command, or
11128 arithmetic <B>for</B> command, display the expanded value of
11129 <FONT SIZE=-1><B>PS4</B>,
11130
11131 </FONT>
11132 followed by the command and its expanded arguments
11133 or associated word list.
11134 <DT><B>-B</B>
11135
11136 <DD>
11137 The shell performs brace expansion (see
11138 <B>Brace Expansion</B>
11139
11140 above). This is on by default.
11141 <DT><B>-C</B>
11142
11143 <DD>
11144 If set,
11145 <B>bash</B>
11146
11147 does not overwrite an existing file with the
11148 <B>&gt;</B>,
11149
11150 <B>&gt;&amp;</B>,
11151
11152 and
11153 <B>&lt;&gt;</B>
11154
11155 redirection operators. This may be overridden when
11156 creating output files by using the redirection operator
11157 <B>&gt;|</B>
11158
11159 instead of
11160 <B>&gt;</B>.
11161
11162 <DT><B>-E</B>
11163
11164 <DD>
11165 If set, any trap on <B>ERR</B> is inherited by shell functions, command
11166 substitutions, and commands executed in a subshell environment.
11167 The <B>ERR</B> trap is normally not inherited in such cases.
11168 <DT><B>-H</B>
11169
11170 <DD>
11171 Enable
11172 <B>!</B>
11173
11174 style history substitution. This option is on by
11175 default when the shell is interactive.
11176 <DT><B>-P</B>
11177
11178 <DD>
11179 If set, the shell does not follow symbolic links when executing
11180 commands such as
11181 <B>cd</B>
11182
11183 that change the current working directory. It uses the
11184 physical directory structure instead. By default,
11185 <B>bash</B>
11186
11187 follows the logical chain of directories when performing commands
11188 which change the current directory.
11189 <DT><B>-T</B>
11190
11191 <DD>
11192 If set, any traps on <B>DEBUG</B> and <B>RETURN</B> are inherited by shell
11193 functions, command substitutions, and commands executed in a
11194 subshell environment.
11195 The <B>DEBUG</B> and <B>RETURN</B> traps are normally not inherited
11196 in such cases.
11197 <DT><B>--</B>
11198
11199 <DD>
11200 If no arguments follow this option, then the positional parameters are
11201 unset. Otherwise, the positional parameters are set to the
11202 <I>arg</I>s, even if some of them begin with a
11203 <B>-</B>.
11204
11205 <DT><B>-</B>
11206
11207 <DD>
11208 Signal the end of options, cause all remaining <I>arg</I>s to be
11209 assigned to the positional parameters. The
11210 <B>-x</B>
11211
11212 and
11213 <B>-v</B>
11214
11215 options are turned off.
11216 If there are no <I>arg</I>s,
11217 the positional parameters remain unchanged.
11218
11219 </DL>
11220 <P>
11221
11222 The options are off by default unless otherwise noted.
11223 Using + rather than - causes these options to be turned off.
11224 The options can also be specified as arguments to an invocation of
11225 the shell.
11226 The current set of options may be found in
11227 <B>$-</B>.
11228
11229 The return status is always true unless an invalid option is encountered.
11230 </DL>
11231
11232 <DT><B>shift</B> [<I>n</I>]<DD>
11233 The positional parameters from <I>n</I>+1 ... are renamed to
11234 <B>$1</B>
11235
11236 <B>....</B>
11237
11238 Parameters represented by the numbers <B>$#</B>
11239 down to <B>$#</B>-<I>n</I>+1 are unset.
11240 <I>n</I>
11241
11242 must be a non-negative number less than or equal to <B>$#</B>.
11243 If
11244 <I>n</I>
11245
11246 is 0, no parameters are changed.
11247 If
11248 <I>n </I>
11249
11250 is not given, it is assumed to be 1.
11251 If
11252 <I>n</I>
11253
11254 is greater than <B>$#</B>, the positional parameters are not changed.
11255 The return status is greater than zero if
11256 <I>n</I>
11257
11258 is greater than
11259 <B>$#</B>
11260
11261 or less than zero; otherwise 0.
11262 <DT><B>shopt</B> [<B>-pqsu</B>] [<B>-o</B>] [<I>optname</I> ...]<DD>
11263 Toggle the values of variables controlling optional shell behavior.
11264 With no options, or with the
11265 <B>-p</B>
11266
11267 option, a list of all settable options is displayed, with
11268 an indication of whether or not each is set.
11269 The <B>-p</B> option causes output to be displayed in a form that
11270 may be reused as input.
11271 Other options have the following meanings:
11272 <DL COMPACT><DT><DD>
11273
11274 <DL COMPACT>
11275 <DT><B>-s</B>
11276
11277 <DD>
11278 Enable (set) each <I>optname</I>.
11279 <DT><B>-u</B>
11280
11281 <DD>
11282 Disable (unset) each <I>optname</I>.
11283 <DT><B>-q</B>
11284
11285 <DD>
11286 Suppresses normal output (quiet mode); the return status indicates
11287 whether the <I>optname</I> is set or unset.
11288 If multiple <I>optname</I> arguments are given with
11289 <B>-q</B>,
11290
11291 the return status is zero if all <I>optnames</I> are enabled; non-zero
11292 otherwise.
11293 <DT><B>-o</B>
11294
11295 <DD>
11296 Restricts the values of <I>optname</I> to be those defined for the
11297 <B>-o</B>
11298
11299 option to the
11300 <B>set</B>
11301
11302 builtin.
11303
11304 </DL>
11305 <P>
11306
11307 If either
11308 <B>-s</B>
11309
11310 or
11311 <B>-u</B>
11312
11313 is used with no <I>optname</I> arguments, the display is limited to
11314 those options which are set or unset, respectively.
11315 Unless otherwise noted, the <B>shopt</B> options are disabled (unset)
11316 by default.
11317 <P>
11318
11319 The return status when listing options is zero if all <I>optnames</I>
11320 are enabled, non-zero otherwise. When setting or unsetting options,
11321 the return status is zero unless an <I>optname</I> is not a valid shell
11322 option.
11323 <P>
11324
11325 The list of <B>shopt</B> options is:
11326 <P>
11327
11328
11329
11330 <DL COMPACT>
11331 <DT><B>autocd</B>
11332
11333 <DD>
11334 If set, a command name that is the name of a directory is executed as if
11335 it were the argument to the <B>cd</B> command.
11336 This option is only used by interactive shells.
11337 <DT><B>cdable_vars</B>
11338
11339 <DD>
11340 If set, an argument to the
11341 <B>cd</B>
11342
11343 builtin command that
11344 is not a directory is assumed to be the name of a variable whose
11345 value is the directory to change to.
11346 <DT><B>cdspell</B>
11347
11348 <DD>
11349 If set, minor errors in the spelling of a directory component in a
11350 <B>cd</B>
11351
11352 command will be corrected.
11353 The errors checked for are transposed characters,
11354 a missing character, and one character too many.
11355 If a correction is found, the corrected file name is printed,
11356 and the command proceeds.
11357 This option is only used by interactive shells.
11358 <DT><B>checkhash</B>
11359
11360 <DD>
11361 If set, <B>bash</B> checks that a command found in the hash
11362 table exists before trying to execute it. If a hashed command no
11363 longer exists, a normal path search is performed.
11364 <DT><B>checkjobs</B>
11365
11366 <DD>
11367 If set, <B>bash</B> lists the status of any stopped and running jobs before
11368 exiting an interactive shell. If any jobs are running, this causes
11369 the exit to be deferred until a second exit is attempted without an
11370 intervening command (see
11371 <FONT SIZE=-1><B>JOB CONTROL</B>
11372
11373 </FONT>
11374 above). The shell always
11375 postpones exiting if any jobs are stopped.
11376 <DT><B>checkwinsize</B>
11377
11378 <DD>
11379 If set, <B>bash</B> checks the window size after each command
11380 and, if necessary, updates the values of
11381 <FONT SIZE=-1><B>LINES</B>
11382
11383 </FONT>
11384 and
11385 <FONT SIZE=-1><B>COLUMNS</B>.
11386
11387 </FONT>
11388 <DT><B>cmdhist</B>
11389
11390 <DD>
11391 If set,
11392 <B>bash</B>
11393
11394 attempts to save all lines of a multiple-line
11395 command in the same history entry. This allows
11396 easy re-editing of multi-line commands.
11397 <DT><B>compat31</B>
11398
11399 <DD>
11400 If set,
11401 <B>bash</B>
11402
11403 changes its behavior to that of version 3.1 with respect to quoted
11404 arguments to the conditional command's <B>=~</B> operator.
11405 <DT><B>compat32</B>
11406
11407 <DD>
11408 If set,
11409 <B>bash</B>
11410
11411 changes its behavior to that of version 3.2 with respect to locale-specific
11412 string comparison when using the conditional command's <B>&lt;</B> and <B>&gt;</B>
11413 operators.
11414 <DT><B>compat40</B>
11415
11416 <DD>
11417 If set,
11418 <B>bash</B>
11419
11420 changes its behavior to that of version 4.0 with respect to locale-specific
11421 string comparison when using the conditional command's <B>&lt;</B> and <B>&gt;</B>
11422 operators and the effect of interrupting a command list.
11423 <DT><B>compat41</B>
11424
11425 <DD>
11426 @item compat41
11427 If set,
11428 <B>bash</B>,
11429
11430 when in posix mode, treats a single quote in a double-quoted
11431 parameter expansion as a special character. The single quotes must match
11432 (an even number) and the characters between the single quotes are considered
11433 quoted. This is the behavior of posix mode through version 4.1.
11434 The default bash behavior remains as in previous versions.
11435 <DT><B>dirspell</B>
11436
11437 <DD>
11438 If set,
11439 <B>bash</B>
11440
11441 attempts spelling correction on directory names during word completion
11442 if the directory name initially supplied does not exist.
11443 <DT><B>dotglob</B>
11444
11445 <DD>
11446 If set,
11447 <B>bash</B>
11448
11449 includes filenames beginning with a `.' in the results of pathname
11450 expansion.
11451 <DT><B>execfail</B>
11452
11453 <DD>
11454 If set, a non-interactive shell will not exit if
11455 it cannot execute the file specified as an argument to the
11456 <B>exec</B>
11457
11458 builtin command. An interactive shell does not exit if
11459 <B>exec</B>
11460
11461 fails.
11462 <DT><B>expand_aliases</B>
11463
11464 <DD>
11465 If set, aliases are expanded as described above under
11466 <FONT SIZE=-1><B>ALIASES</B>.
11467
11468 </FONT>
11469 This option is enabled by default for interactive shells.
11470 <DT><B>extdebug</B>
11471
11472 <DD>
11473 If set, behavior intended for use by debuggers is enabled:
11474 <DL COMPACT><DT><DD>
11475 <DL COMPACT>
11476 <DT><B>1.</B>
11477
11478 <DD>
11479 The <B>-F</B> option to the <B>declare</B> builtin displays the source
11480 file name and line number corresponding to each function name supplied
11481 as an argument.
11482 <DT><B>2.</B>
11483
11484 <DD>
11485 If the command run by the <B>DEBUG</B> trap returns a non-zero value, the
11486 next command is skipped and not executed.
11487 <DT><B>3.</B>
11488
11489 <DD>
11490 If the command run by the <B>DEBUG</B> trap returns a value of 2, and the
11491 shell is executing in a subroutine (a shell function or a shell script
11492 executed by the <B>.</B> or <B>source</B> builtins), a call to
11493 <B>return</B> is simulated.
11494 <DT><B>4.</B>
11495
11496 <DD>
11497 <FONT SIZE=-1><B>BASH_ARGC</B>
11498
11499 </FONT>
11500 and
11501 <FONT SIZE=-1><B>BASH_ARGV</B>
11502
11503 </FONT>
11504 are updated as described in their descriptions above.
11505 <DT><B>5.</B>
11506
11507 <DD>
11508 Function tracing is enabled: command substitution, shell functions, and
11509 subshells invoked with <B>(</B> <I>command</I> <B>)</B> inherit the
11510 <B>DEBUG</B> and <B>RETURN</B> traps.
11511 <DT><B>6.</B>
11512
11513 <DD>
11514 Error tracing is enabled: command substitution, shell functions, and
11515 subshells invoked with <B>(</B> <I>command</I> <B>)</B> inherit the
11516 <B>ERR</B> trap.
11517 </DL></DL>
11518
11519 <DT><B>extglob</B>
11520
11521 <DD>
11522 If set, the extended pattern matching features described above under
11523 <B>Pathname Expansion</B> are enabled.
11524 <DT><B>extquote</B>
11525
11526 <DD>
11527 If set, <B>$</B>aq<I>string</I>aq and <B>$</B>&quot;<I>string</I>&quot; quoting is
11528 performed within <B>${</B><I>parameter</I><B>}</B> expansions
11529 enclosed in double quotes. This option is enabled by default.
11530 <DT><B>failglob</B>
11531
11532 <DD>
11533 If set, patterns which fail to match filenames during pathname expansion
11534 result in an expansion error.
11535 <DT><B>force_fignore</B>
11536
11537 <DD>
11538 If set, the suffixes specified by the
11539 <FONT SIZE=-1><B>FIGNORE</B>
11540
11541 </FONT>
11542 shell variable
11543 cause words to be ignored when performing word completion even if
11544 the ignored words are the only possible completions.
11545 See
11546 <FONT SIZE=-1><B>SHELL VARIABLES</B></FONT>
11547 above for a description of
11548 <FONT SIZE=-1><B>FIGNORE</B>.
11549
11550 </FONT>
11551 This option is enabled by default.
11552 <DT><B>globstar</B>
11553
11554 <DD>
11555 If set, the pattern <B>**</B> used in a pathname expansion context will
11556 match a files and zero or more directories and subdirectories.
11557 If the pattern is followed by a <B>/</B>, only directories and
11558 subdirectories match.
11559 <DT><B>gnu_errfmt</B>
11560
11561 <DD>
11562 If set, shell error messages are written in the standard GNU error
11563 message format.
11564 <DT><B>histappend</B>
11565
11566 <DD>
11567 If set, the history list is appended to the file named by the value
11568 of the
11569 <FONT SIZE=-1><B>HISTFILE</B>
11570
11571 </FONT>
11572 variable when the shell exits, rather than overwriting the file.
11573 <DT><B>histreedit</B>
11574
11575 <DD>
11576 If set, and
11577 <B>readline</B>
11578
11579 is being used, a user is given the opportunity to re-edit a
11580 failed history substitution.
11581 <DT><B>histverify</B>
11582
11583 <DD>
11584 If set, and
11585 <B>readline</B>
11586
11587 is being used, the results of history substitution are not immediately
11588 passed to the shell parser. Instead, the resulting line is loaded into
11589 the <B>readline</B> editing buffer, allowing further modification.
11590 <DT><B>hostcomplete</B>
11591
11592 <DD>
11593 If set, and
11594 <B>readline</B>
11595
11596 is being used, <B>bash</B> will attempt to perform hostname completion when a
11597 word containing a <B>@</B> is being completed (see
11598 <B>Completing</B>
11599
11600 under
11601 <FONT SIZE=-1><B>READLINE</B>
11602
11603 </FONT>
11604 above).
11605 This is enabled by default.
11606 <DT><B>huponexit</B>
11607
11608 <DD>
11609 If set, <B>bash</B> will send
11610 <FONT SIZE=-1><B>SIGHUP</B>
11611
11612 </FONT>
11613 to all jobs when an interactive login shell exits.
11614 <DT><B>interactive_comments</B>
11615
11616 <DD>
11617 If set, allow a word beginning with
11618 <B>#</B>
11619
11620 to cause that word and all remaining characters on that
11621 line to be ignored in an interactive shell (see
11622 <FONT SIZE=-1><B>COMMENTS</B>
11623
11624 </FONT>
11625 above). This option is enabled by default.
11626 <DT><B>lastpipe</B>
11627
11628 <DD>
11629 If set, and job control is not active, the shell runs the last command of
11630 a pipeline not executed in the background in the current shell environment.
11631 <DT><B>lithist</B>
11632
11633 <DD>
11634 If set, and the
11635 <B>cmdhist</B>
11636
11637 option is enabled, multi-line commands are saved to the history with
11638 embedded newlines rather than using semicolon separators where possible.
11639 <DT><B>login_shell</B>
11640
11641 <DD>
11642 The shell sets this option if it is started as a login shell (see
11643 <FONT SIZE=-1><B>INVOCATION</B>
11644
11645 </FONT>
11646 above).
11647 The value may not be changed.
11648 <DT><B>mailwarn</B>
11649
11650 <DD>
11651 If set, and a file that <B>bash</B> is checking for mail has been
11652 accessed since the last time it was checked, the message ``The mail in
11653 <I>mailfile</I> has been read'' is displayed.
11654 <DT><B>no_empty_cmd_completion</B>
11655
11656 <DD>
11657 If set, and
11658 <B>readline</B>
11659
11660 is being used,
11661 <B>bash</B>
11662
11663 will not attempt to search the
11664 <FONT SIZE=-1><B>PATH</B>
11665
11666 </FONT>
11667 for possible completions when
11668 completion is attempted on an empty line.
11669 <DT><B>nocaseglob</B>
11670
11671 <DD>
11672 If set,
11673 <B>bash</B>
11674
11675 matches filenames in a case-insensitive fashion when performing pathname
11676 expansion (see
11677 <B>Pathname Expansion</B>
11678
11679 above).
11680 <DT><B>nocasematch</B>
11681
11682 <DD>
11683 If set,
11684 <B>bash</B>
11685
11686 matches patterns in a case-insensitive fashion when performing matching
11687 while executing <B>case</B> or <B>[[</B> conditional commands.
11688 <DT><B>nullglob</B>
11689
11690 <DD>
11691 If set,
11692 <B>bash</B>
11693
11694 allows patterns which match no
11695 files (see
11696 <B>Pathname Expansion</B>
11697
11698 above)
11699 to expand to a null string, rather than themselves.
11700 <DT><B>progcomp</B>
11701
11702 <DD>
11703 If set, the programmable completion facilities (see
11704 <B>Programmable Completion</B> above) are enabled.
11705 This option is enabled by default.
11706 <DT><B>promptvars</B>
11707
11708 <DD>
11709 If set, prompt strings undergo
11710 parameter expansion, command substitution, arithmetic
11711 expansion, and quote removal after being expanded as described in
11712 <FONT SIZE=-1><B>PROMPTING</B>
11713
11714 </FONT>
11715 above. This option is enabled by default.
11716 <DT><B>restricted_shell</B>
11717
11718 <DD>
11719 The shell sets this option if it is started in restricted mode (see
11720 <FONT SIZE=-1><B>RESTRICTED SHELL</B>
11721
11722 </FONT>
11723 below).
11724 The value may not be changed.
11725 This is not reset when the startup files are executed, allowing
11726 the startup files to discover whether or not a shell is restricted.
11727 <DT><B>shift_verbose</B>
11728
11729 <DD>
11730 If set, the
11731 <B>shift</B>
11732
11733 builtin prints an error message when the shift count exceeds the
11734 number of positional parameters.
11735 <DT><B>sourcepath</B>
11736
11737 <DD>
11738 If set, the
11739 <B>source</B> (<B>.</B>) builtin uses the value of
11740 <FONT SIZE=-1><B>PATH</B>
11741
11742 </FONT>
11743 to find the directory containing the file supplied as an argument.
11744 This option is enabled by default.
11745 <DT><B>xpg_echo</B>
11746
11747 <DD>
11748 If set, the <B>echo</B> builtin expands backslash-escape sequences
11749 by default.
11750 </DL></DL>
11751
11752 <DT><B>suspend</B> [<B>-f</B>]<DD>
11753 Suspend the execution of this shell until it receives a
11754 <FONT SIZE=-1><B>SIGCONT</B>
11755
11756 </FONT>
11757 signal. A login shell cannot be suspended; the
11758 <B>-f</B>
11759
11760 option can be used to override this and force the suspension.
11761 The return status is 0 unless the shell is a login shell and
11762 <B>-f</B>
11763
11764 is not supplied, or if job control is not enabled.
11765 <DT><B>test</B> <I>expr</I><DD>
11766
11767 <DT><B>[</B> <I>expr</I> <B>]</B><DD>
11768 Return a status of 0 or 1 depending on
11769 the evaluation of the conditional expression
11770 <I>expr</I>.
11771
11772 Each operator and operand must be a separate argument.
11773 Expressions are composed of the primaries described above under
11774 <FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>.
11775
11776 </FONT>
11777 <B>test</B> does not accept any options, nor does it accept and ignore
11778 an argument of <B>--</B> as signifying the end of options.
11779 <P>
11780
11781
11782 Expressions may be combined using the following operators, listed
11783 in decreasing order of precedence.
11784 The evaluation depends on the number of arguments; see below.
11785 <DL COMPACT><DT><DD>
11786
11787 <DL COMPACT>
11788 <DT><B>! </B><I>expr</I>
11789
11790 <DD>
11791 True if
11792 <I>expr</I>
11793
11794 is false.
11795 <DT><B>( </B><I>expr</I> )
11796
11797 <DD>
11798 Returns the value of <I>expr</I>.
11799 This may be used to override the normal precedence of operators.
11800 <DT><I>expr1</I> -<B>a</B> <I>expr2</I><DD>
11801 True if both
11802 <I>expr1</I>
11803
11804 and
11805 <I>expr2</I>
11806
11807 are true.
11808 <DT><I>expr1</I> -<B>o</B> <I>expr2</I><DD>
11809 True if either
11810 <I>expr1</I>
11811
11812 or
11813 <I>expr2</I>
11814
11815 is true.
11816
11817 </DL>
11818 <P>
11819
11820 <B>test</B> and <B>[</B> evaluate conditional
11821 expressions using a set of rules based on the number of arguments.
11822 <P>
11823
11824
11825
11826 <DL COMPACT>
11827 <DT>0 arguments<DD>
11828 The expression is false.
11829 <DT>1 argument<DD>
11830 The expression is true if and only if the argument is not null.
11831 <DT>2 arguments<DD>
11832 If the first argument is <B>!</B>, the expression is true if and
11833 only if the second argument is null.
11834 If the first argument is one of the unary conditional operators listed above
11835 under
11836 <FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>,
11837
11838 </FONT>
11839 the expression is true if the unary test is true.
11840 If the first argument is not a valid unary conditional operator, the expression
11841 is false.
11842 <DT>3 arguments<DD>
11843 If the second argument is one of the binary conditional operators listed above
11844 under
11845 <FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>,
11846
11847 </FONT>
11848 the result of the expression is the result of the binary test using
11849 the first and third arguments as operands.
11850 The <B>-a</B> and <B>-o</B> operators are considered binary operators
11851 when there are three arguments.
11852 If the first argument is <B>!</B>, the value is the negation of
11853 the two-argument test using the second and third arguments.
11854 If the first argument is exactly <B>(</B> and the third argument is
11855 exactly <B>)</B>, the result is the one-argument test of the second
11856 argument.
11857 Otherwise, the expression is false.
11858 <DT>4 arguments<DD>
11859 If the first argument is <B>!</B>, the result is the negation of
11860 the three-argument expression composed of the remaining arguments.
11861 Otherwise, the expression is parsed and evaluated according to
11862 precedence using the rules listed above.
11863 <DT>5 or more arguments<DD>
11864 The expression is parsed and evaluated according to precedence
11865 using the rules listed above.
11866 </DL></DL>
11867
11868
11869 <DT><B>times</B>
11870
11871 <DD>
11872 Print the accumulated user and system times for the shell and
11873 for processes run from the shell. The return status is 0.
11874 <DT><B>trap</B> [<B>-lp</B>] [[<I>arg</I>] <I>sigspec</I> ...]<DD>
11875 The command
11876 <I>arg</I>
11877
11878 is to be read and executed when the shell receives
11879 signal(s)
11880 <I>sigspec</I>.
11881
11882 If
11883 <I>arg</I>
11884
11885 is absent (and there is a single <I>sigspec</I>) or
11886 <B>-</B>,
11887
11888 each specified signal is
11889 reset to its original disposition (the value it had
11890 upon entrance to the shell).
11891 If
11892 <I>arg</I>
11893
11894 is the null string the signal specified by each
11895 <I>sigspec</I>
11896
11897 is ignored by the shell and by the commands it invokes.
11898 If
11899 <I>arg</I>
11900
11901 is not present and
11902 <B>-p</B>
11903
11904 has been supplied, then the trap commands associated with each
11905 <I>sigspec</I>
11906
11907 are displayed.
11908 If no arguments are supplied or if only
11909 <B>-p</B>
11910
11911 is given,
11912 <B>trap</B>
11913
11914 prints the list of commands associated with each signal.
11915 The
11916 <B>-l</B>
11917
11918 option causes the shell to print a list of signal names and
11919 their corresponding numbers.
11920 Each
11921 <I>sigspec</I>
11922
11923 is either
11924 a signal name defined in &lt;<I>signal.h</I>&gt;, or a signal number.
11925 Signal names are case insensitive and the
11926 <FONT SIZE=-1><B>SIG</B>
11927
11928 </FONT>
11929 prefix is optional.
11930 <P>
11931
11932
11933 If a
11934 <I>sigspec</I>
11935
11936 is
11937 <FONT SIZE=-1><B>EXIT</B>
11938
11939 </FONT>
11940 (0) the command
11941 <I>arg</I>
11942
11943 is executed on exit from the shell.
11944 If a
11945 <I>sigspec</I>
11946
11947 is
11948 <FONT SIZE=-1><B>DEBUG</B>,
11949
11950 </FONT>
11951 the command
11952 <I>arg</I>
11953
11954 is executed before every <I>simple command</I>, <I>for</I> command,
11955 <I>case</I> command, <I>select</I> command, every arithmetic <I>for</I>
11956 command, and before the first command executes in a shell function (see
11957 <FONT SIZE=-1><B>SHELL GRAMMAR</B>
11958
11959 </FONT>
11960 above).
11961 Refer to the description of the <B>extdebug</B> option to the
11962 <B>shopt</B> builtin for details of its effect on the <B>DEBUG</B> trap.
11963 If a
11964 <I>sigspec</I>
11965
11966 is
11967 <FONT SIZE=-1><B>RETURN</B>,
11968
11969 </FONT>
11970 the command
11971 <I>arg</I>
11972
11973 is executed each time a shell function or a script executed with
11974 the <B>.</B> or <B>source</B> builtins finishes executing.
11975 <P>
11976
11977
11978 If a
11979 <I>sigspec</I>
11980
11981 is
11982 <FONT SIZE=-1><B>ERR</B>,
11983
11984 </FONT>
11985 the command
11986 <I>arg</I>
11987
11988 is executed whenever a simple command has a non-zero exit status,
11989 subject to the following conditions.
11990 The
11991 <FONT SIZE=-1><B>ERR</B>
11992
11993 </FONT>
11994 trap is not executed if the failed
11995 command is part of the command list immediately following a
11996 <B>while</B>
11997
11998 or
11999 <B>until</B>
12000
12001 keyword,
12002 part of the test in an
12003 <I>if</I>
12004
12005 statement, part of a command executed in a
12006 <B>&amp;&amp;</B>
12007
12008 or
12009 <B>||</B>
12010
12011 list, or if the command's return value is
12012 being inverted via
12013 <B>!</B>.
12014
12015 These are the same conditions obeyed by the <B>errexit</B> option.
12016 <P>
12017
12018
12019 Signals ignored upon entry to the shell cannot be trapped or reset.
12020 Trapped signals that are not being ignored are reset to their original
12021 values in a subshell or subshell environment when one is created.
12022 The return status is false if any
12023 <I>sigspec</I>
12024
12025 is invalid; otherwise
12026 <B>trap</B>
12027
12028 returns true.
12029 <DT><B>type</B> [<B>-aftpP</B>] <I>name</I> [<I>name</I> ...]<DD>
12030 With no options,
12031 indicate how each
12032 <I>name</I>
12033
12034 would be interpreted if used as a command name.
12035 If the
12036 <B>-t</B>
12037
12038 option is used,
12039 <B>type</B>
12040
12041 prints a string which is one of
12042 <I>alias</I>,
12043
12044 <I>keyword</I>,
12045
12046 <I>function</I>,
12047
12048 <I>builtin</I>,
12049
12050 or
12051 <I>file </I>
12052
12053 if
12054 <I>name</I>
12055
12056 is an alias, shell reserved word, function, builtin, or disk file,
12057 respectively.
12058 If the
12059 <I>name</I>
12060
12061 is not found, then nothing is printed, and an exit status of false
12062 is returned.
12063 If the
12064 <B>-p</B>
12065
12066 option is used,
12067 <B>type</B>
12068
12069 either returns the name of the disk file
12070 that would be executed if
12071 <I>name</I>
12072
12073 were specified as a command name,
12074 or nothing if
12075 <TT>type -t name</TT>
12076
12077 would not return
12078 <I>file</I>.
12079
12080 The
12081 <B>-P</B>
12082
12083 option forces a
12084 <FONT SIZE=-1><B>PATH</B>
12085
12086 </FONT>
12087 search for each <I>name</I>, even if
12088 <TT>type -t name</TT>
12089
12090 would not return
12091 <I>file</I>.
12092
12093 If a command is hashed,
12094 <B>-p</B>
12095
12096 and
12097 <B>-P</B>
12098
12099 print the hashed value, not necessarily the file that appears
12100 first in
12101 <FONT SIZE=-1><B>PATH</B>.
12102
12103 </FONT>
12104 If the
12105 <B>-a</B>
12106
12107 option is used,
12108 <B>type</B>
12109
12110 prints all of the places that contain
12111 an executable named
12112 <I>name</I>.
12113
12114 This includes aliases and functions,
12115 if and only if the
12116 <B>-p</B>
12117
12118 option is not also used.
12119 The table of hashed commands is not consulted
12120 when using
12121 <B>-a</B>.
12122
12123 The
12124 <B>-f</B>
12125
12126 option suppresses shell function lookup, as with the <B>command</B> builtin.
12127 <B>type</B>
12128
12129 returns true if all of the arguments are found, false if
12130 any are not found.
12131 <DT><B>ulimit</B> [<B>-HSTabcdefilmnpqrstuvx</B> [<I>limit</I>]]<DD>
12132 Provides control over the resources available to the shell and to
12133 processes started by it, on systems that allow such control.
12134 The <B>-H</B> and <B>-S</B> options specify that the hard or soft limit is
12135 set for the given resource.
12136 A hard limit cannot be increased by a non-root user once it is set;
12137 a soft limit may be increased up to the value of the hard limit.
12138 If neither <B>-H</B> nor <B>-S</B> is specified, both the soft and hard
12139 limits are set.
12140 The value of
12141 <I>limit</I>
12142
12143 can be a number in the unit specified for the resource
12144 or one of the special values
12145 <B>hard</B>,
12146
12147 <B>soft</B>,
12148
12149 or
12150 <B>unlimited</B>,
12151
12152 which stand for the current hard limit, the current soft limit, and
12153 no limit, respectively.
12154 If
12155 <I>limit</I>
12156
12157 is omitted, the current value of the soft limit of the resource is
12158 printed, unless the <B>-H</B> option is given. When more than one
12159 resource is specified, the limit name and unit are printed before the value.
12160 Other options are interpreted as follows:
12161 <DL COMPACT><DT><DD>
12162
12163 <DL COMPACT>
12164 <DT><B>-a</B>
12165
12166 <DD>
12167 All current limits are reported
12168 <DT><B>-b</B>
12169
12170 <DD>
12171 The maximum socket buffer size
12172 <DT><B>-c</B>
12173
12174 <DD>
12175 The maximum size of core files created
12176 <DT><B>-d</B>
12177
12178 <DD>
12179 The maximum size of a process's data segment
12180 <DT><B>-e</B>
12181
12182 <DD>
12183 The maximum scheduling priority (&quot;nice&quot;)
12184 <DT><B>-f</B>
12185
12186 <DD>
12187 The maximum size of files written by the shell and its children
12188 <DT><B>-i</B>
12189
12190 <DD>
12191 The maximum number of pending signals
12192 <DT><B>-l</B>
12193
12194 <DD>
12195 The maximum size that may be locked into memory
12196 <DT><B>-m</B>
12197
12198 <DD>
12199 The maximum resident set size (many systems do not honor this limit)
12200 <DT><B>-n</B>
12201
12202 <DD>
12203 The maximum number of open file descriptors (most systems do not
12204 allow this value to be set)
12205 <DT><B>-p</B>
12206
12207 <DD>
12208 The pipe size in 512-byte blocks (this may not be set)
12209 <DT><B>-q</B>
12210
12211 <DD>
12212 The maximum number of bytes in POSIX message queues
12213 <DT><B>-r</B>
12214
12215 <DD>
12216 The maximum real-time scheduling priority
12217 <DT><B>-s</B>
12218
12219 <DD>
12220 The maximum stack size
12221 <DT><B>-t</B>
12222
12223 <DD>
12224 The maximum amount of cpu time in seconds
12225 <DT><B>-u</B>
12226
12227 <DD>
12228 The maximum number of processes available to a single user
12229 <DT><B>-v</B>
12230
12231 <DD>
12232 The maximum amount of virtual memory available to the shell and, on
12233 some systems, to its children
12234 <DT><B>-x</B>
12235
12236 <DD>
12237 The maximum number of file locks
12238 <DT><B>-T</B>
12239
12240 <DD>
12241 The maximum number of threads
12242
12243 </DL>
12244 <P>
12245
12246 If
12247 <I>limit</I>
12248
12249 is given, it is the new value of the specified resource (the
12250 <B>-a</B>
12251
12252 option is display only).
12253 If no option is given, then
12254 <B>-f</B>
12255
12256 is assumed. Values are in 1024-byte increments, except for
12257 <B>-t</B>,
12258
12259 which is in seconds,
12260 <B>-p</B>,
12261
12262 which is in units of 512-byte blocks,
12263 and
12264 <B>-T</B>,
12265
12266 <B>-b</B>,
12267
12268 <B>-n</B>,
12269
12270 and
12271 <B>-u</B>,
12272
12273 which are unscaled values.
12274 The return status is 0 unless an invalid option or argument is supplied,
12275 or an error occurs while setting a new limit.
12276 </DL>
12277
12278 <DT><B>umask</B> [<B>-p</B>] [<B>-S</B>] [<I>mode</I>]<DD>
12279 The user file-creation mask is set to
12280 <I>mode</I>.
12281
12282 If
12283 <I>mode</I>
12284
12285 begins with a digit, it
12286 is interpreted as an octal number; otherwise
12287 it is interpreted as a symbolic mode mask similar
12288 to that accepted by
12289 <I>chmod</I>(1).
12290
12291 If
12292 <I>mode</I>
12293
12294 is omitted, the current value of the mask is printed.
12295 The
12296 <B>-S</B>
12297
12298 option causes the mask to be printed in symbolic form; the
12299 default output is an octal number.
12300 If the
12301 <B>-p</B>
12302
12303 option is supplied, and
12304 <I>mode</I>
12305
12306 is omitted, the output is in a form that may be reused as input.
12307 The return status is 0 if the mode was successfully changed or if
12308 no <I>mode</I> argument was supplied, and false otherwise.
12309 <DT><B>unalias</B> [-<B>a</B>] [<I>name</I> ...]<DD>
12310 Remove each <I>name</I> from the list of defined aliases. If
12311 <B>-a</B>
12312
12313 is supplied, all alias definitions are removed. The return
12314 value is true unless a supplied
12315 <I>name</I>
12316
12317 is not a defined alias.
12318 <DT><B>unset</B> [-<B>fv</B>] [<I>name</I> ...]<DD>
12319 For each
12320 <I>name</I>,
12321
12322 remove the corresponding variable or function.
12323 If no options are supplied, or the
12324 <B>-v</B>
12325
12326 option is given, each
12327 <I>name</I>
12328
12329 refers to a shell variable.
12330 Read-only variables may not be unset.
12331 If
12332 <B>-f</B>
12333
12334 is specified, each
12335 <I>name</I>
12336
12337 refers to a shell function, and the function definition
12338 is removed.
12339 Each unset variable or function is removed from the environment
12340 passed to subsequent commands.
12341 If any of
12342 <FONT SIZE=-1><B>COMP_WORDBREAKS</B>,
12343
12344 </FONT>
12345 <FONT SIZE=-1><B>RANDOM</B>,
12346
12347 </FONT>
12348 <FONT SIZE=-1><B>SECONDS</B>,
12349
12350 </FONT>
12351 <FONT SIZE=-1><B>LINENO</B>,
12352
12353 </FONT>
12354 <FONT SIZE=-1><B>HISTCMD</B>,
12355
12356 </FONT>
12357 <FONT SIZE=-1><B>FUNCNAME</B>,
12358
12359 </FONT>
12360 <FONT SIZE=-1><B>GROUPS</B>,
12361
12362 </FONT>
12363 or
12364 <FONT SIZE=-1><B>DIRSTACK</B>
12365
12366 </FONT>
12367 are unset, they lose their special properties, even if they are
12368 subsequently reset. The exit status is true unless a
12369 <I>name</I>
12370
12371 is readonly.
12372 <DT><B>wait</B> [<I>n ...</I>]<DD>
12373 Wait for each specified process and return its termination status.
12374 Each
12375 <I>n</I>
12376
12377 may be a process
12378 ID or a job specification; if a job spec is given, all processes
12379 in that job's pipeline are waited for. If
12380 <I>n</I>
12381
12382 is not given, all currently active child processes
12383 are waited for, and the return status is zero. If
12384 <I>n</I>
12385
12386 specifies a non-existent process or job, the return status is
12387 127. Otherwise, the return status is the exit status of the last
12388 process or job waited for.
12389
12390
12391 </DL>
12392 <A NAME="lbDC">&nbsp;</A>
12393 <H3>RESTRICTED SHELL</H3>
12394
12395
12396
12397 <P>
12398
12399 If
12400 <B>bash</B>
12401
12402 is started with the name
12403 <B>rbash</B>,
12404
12405 or the
12406 <B>-r</B>
12407
12408 option is supplied at invocation,
12409 the shell becomes restricted.
12410 A restricted shell is used to
12411 set up an environment more controlled than the standard shell.
12412 It behaves identically to
12413 <B>bash</B>
12414
12415 with the exception that the following are disallowed or not performed:
12416 <DL COMPACT>
12417 <DT>*<DD>
12418 changing directories with <B>cd</B>
12419 <DT>*<DD>
12420 setting or unsetting the values of
12421 <FONT SIZE=-1><B>SHELL</B>,
12422
12423 </FONT>
12424 <FONT SIZE=-1><B>PATH</B>,
12425
12426 </FONT>
12427 <FONT SIZE=-1><B>ENV</B>,
12428
12429 </FONT>
12430 or
12431 <FONT SIZE=-1><B>BASH_ENV</B>
12432
12433 </FONT>
12434 <DT>*<DD>
12435 specifying command names containing
12436 <B>/</B>
12437
12438 <DT>*<DD>
12439 specifying a file name containing a
12440 <B>/</B>
12441
12442 as an argument to the
12443 <B>.</B>
12444
12445 builtin command
12446 <DT>*<DD>
12447 specifying a filename containing a slash as an argument to the
12448 <B>-p</B>
12449
12450 option to the
12451 <B>hash</B>
12452
12453 builtin command
12454 <DT>*<DD>
12455 importing function definitions from the shell environment at startup
12456 <DT>*<DD>
12457 parsing the value of
12458 <FONT SIZE=-1><B>SHELLOPTS</B>
12459
12460 </FONT>
12461 from the shell environment at startup
12462 <DT>*<DD>
12463 redirecting output using the &gt;, &gt;|, &lt;&gt;, &gt;&amp;, &amp;&gt;, and &gt;&gt; redirection operators
12464 <DT>*<DD>
12465 using the
12466 <B>exec</B>
12467
12468 builtin command to replace the shell with another command
12469 <DT>*<DD>
12470 adding or deleting builtin commands with the
12471 <B>-f</B>
12472
12473 and
12474 <B>-d</B>
12475
12476 options to the
12477 <B>enable</B>
12478
12479 builtin command
12480 <DT>*<DD>
12481 using the <B>enable</B> builtin command to enable disabled shell builtins
12482 <DT>*<DD>
12483 specifying the
12484 <B>-p</B>
12485
12486 option to the
12487 <B>command</B>
12488
12489 builtin command
12490 <DT>*<DD>
12491 turning off restricted mode with
12492 <B>set +r</B> or <B>set +o restricted</B>.
12493 </DL>
12494 <P>
12495
12496 These restrictions are enforced after any startup files are read.
12497 <P>
12498
12499
12500 When a command that is found to be a shell script is executed
12501 (see
12502 <FONT SIZE=-1><B>COMMAND EXECUTION</B>
12503
12504 </FONT>
12505
12506 above),
12507
12508 <B>rbash</B>
12509
12510 turns off any restrictions in the shell spawned to execute the
12511 script.
12512
12513
12514 <A NAME="lbDD">&nbsp;</A>
12515 <H3>SEE ALSO</H3>
12516
12517
12518 <DL COMPACT>
12519 <DT><I>Bash Reference Manual</I>, Brian Fox and Chet Ramey<DD>
12520 <DT><I>The Gnu Readline Library</I>, Brian Fox and Chet Ramey<DD>
12521 <DT><I>The Gnu History Library</I>, Brian Fox and Chet Ramey<DD>
12522 <DT><I>Portable Operating System Interface (POSIX) Part 2: Shell and Utilities</I>, IEEE<DD>
12523 <DT><I>sh</I>(1), <I>ksh</I>(1), <I>csh</I>(1)<DD>
12524 <DT><I>emacs</I>(1), <I>vi</I>(1)<DD>
12525 <DT><I>readline</I>(3)<DD>
12526
12527 </DL>
12528 <A NAME="lbDE">&nbsp;</A>
12529 <H3>FILES</H3>
12530
12531
12532 <DL COMPACT>
12533 <DT>
12534 <A HREF="file:/bin/bash"><I>/bin/bash</I></A>
12535
12536 <DD>
12537 The <B>bash</B> executable
12538 <DT>
12539 <A HREF="file:/etc/profile"><I>/etc/profile</I></A>
12540
12541 <DD>
12542 The systemwide initialization file, executed for login shells
12543 <DT>
12544 <A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>
12545
12546 <DD>
12547 The personal initialization file, executed for login shells
12548 <DT>
12549 <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
12550
12551 <DD>
12552 The individual per-interactive-shell startup file
12553 <DT>
12554 <A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A>
12555
12556 <DD>
12557 The individual login shell cleanup file, executed when a login shell exits
12558 <DT>
12559 <A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>
12560
12561 <DD>
12562 Individual <I>readline</I> initialization file
12563
12564 </DL>
12565 <A NAME="lbDF">&nbsp;</A>
12566 <H3>AUTHORS</H3>
12567
12568 Brian Fox, Free Software Foundation
12569 <BR>
12570
12571 <A HREF="mailto:bfox@gnu.org">bfox@gnu.org</A>
12572 <P>
12573
12574 Chet Ramey, Case Western Reserve University
12575 <BR>
12576
12577 <A HREF="mailto:chet.ramey@case.edu">chet.ramey@case.edu</A>
12578 <A NAME="lbDG">&nbsp;</A>
12579 <H3>BUG REPORTS</H3>
12580
12581 If you find a bug in
12582 <B>bash,</B>
12583
12584 you should report it. But first, you should
12585 make sure that it really is a bug, and that it appears in the latest
12586 version of
12587 <B>bash</B>.
12588
12589 The latest version is always available from
12590 <I><A HREF="ftp://ftp.gnu.org/pub/gnu/bash/">ftp://ftp.gnu.org/pub/gnu/bash/</A></I>.
12591 <P>
12592
12593 Once you have determined that a bug actually exists, use the
12594 <I>bashbug</I>
12595
12596 command to submit a bug report.
12597 If you have a fix, you are encouraged to mail that as well!
12598 Suggestions and `philosophical' bug reports may be mailed
12599 to <I><A HREF="mailto:bug-bash@gnu.org">bug-bash@gnu.org</A></I> or posted to the Usenet
12600 newsgroup
12601 <A HREF="news:gnu.bash.bug">gnu.bash.bug</A>.
12602
12603 <P>
12604
12605 ALL bug reports should include:
12606 <P>
12607
12608
12609 <DL COMPACT>
12610 <DT>The version number of <B>bash</B><DD>
12611 <DT>The hardware and operating system<DD>
12612 <DT>The compiler used to compile<DD>
12613 <DT>A description of the bug behaviour<DD>
12614 <DT>A short script or `recipe' which exercises the bug<DD>
12615
12616 </DL>
12617 <P>
12618
12619 <I>bashbug</I>
12620
12621 inserts the first three items automatically into the template
12622 it provides for filing a bug report.
12623 <P>
12624
12625 Comments and bug reports concerning
12626 this manual page should be directed to
12627 <I><A HREF="mailto:chet@po.cwru.edu">chet@po.cwru.edu</A></I>.
12628
12629 <A NAME="lbDH">&nbsp;</A>
12630 <H3>BUGS</H3>
12631
12632 <P>
12633
12634 It's too big and too slow.
12635 <P>
12636
12637 There are some subtle differences between
12638 <B>bash</B>
12639
12640 and traditional versions of
12641 <B>sh</B>,
12642
12643 mostly because of the
12644 <FONT SIZE=-1><B>POSIX</B>
12645
12646 </FONT>
12647 specification.
12648 <P>
12649
12650 Aliases are confusing in some uses.
12651 <P>
12652
12653 Shell builtin commands and functions are not stoppable/restartable.
12654 <P>
12655
12656 Compound commands and command sequences of the form `a ; b ; c'
12657 are not handled gracefully when process suspension is attempted.
12658 When a process is stopped, the shell immediately executes the next
12659 command in the sequence.
12660 It suffices to place the sequence of commands between
12661 parentheses to force it into a subshell, which may be stopped as
12662 a unit.
12663 <P>
12664
12665 Array variables may not (yet) be exported.
12666 <P>
12667
12668 There may be only one active coprocess at a time.
12669
12670
12671
12672 <HR>
12673 <TABLE WIDTH=100%>
12674 <TR>
12675 <TH ALIGN=LEFT width=33%>GNU Bash-4.2<TH ALIGN=CENTER width=33%>2010 September 6<TH ALIGN=RIGHT width=33%>BASH(1)
12676 </TR>
12677 </TABLE>
12678 <HR>
12679 <A NAME="index">&nbsp;</A><H2>Index</H2>
12680 <DL>
12681 <DT><A HREF="#lbAB">NAME</A><DD>
12682 <DT><A HREF="#lbAC">SYNOPSIS</A><DD>
12683 <DT><A HREF="#lbAD">COPYRIGHT</A><DD>
12684 <DT><A HREF="#lbAE">DESCRIPTION</A><DD>
12685 <DT><A HREF="#lbAF">OPTIONS</A><DD>
12686 <DT><A HREF="#lbAG">ARGUMENTS</A><DD>
12687 <DT><A HREF="#lbAH">INVOCATION</A><DD>
12688 <DT><A HREF="#lbAI">DEFINITIONS</A><DD>
12689 <DT><A HREF="#lbAJ">RESERVED WORDS</A><DD>
12690 <DT><A HREF="#lbAK">SHELL GRAMMAR</A><DD>
12691 <DL>
12692 <DT><A HREF="#lbAL">Simple Commands</A><DD>
12693 <DT><A HREF="#lbAM">Pipelines</A><DD>
12694 <DT><A HREF="#lbAN">Lists</A><DD>
12695 <DT><A HREF="#lbAO">Compound Commands</A><DD>
12696 <DT><A HREF="#lbAP">Coprocesses</A><DD>
12697 <DT><A HREF="#lbAQ">Shell Function Definitions</A><DD>
12698 </DL>
12699 <DT><A HREF="#lbAR">COMMENTS</A><DD>
12700 <DT><A HREF="#lbAS">QUOTING</A><DD>
12701 <DT><A HREF="#lbAT">PARAMETERS</A><DD>
12702 <DL>
12703 <DT><A HREF="#lbAU">Positional Parameters</A><DD>
12704 <DT><A HREF="#lbAV">Special Parameters</A><DD>
12705 <DT><A HREF="#lbAW">Shell Variables</A><DD>
12706 <DT><A HREF="#lbAX">Arrays</A><DD>
12707 </DL>
12708 <DT><A HREF="#lbAY">EXPANSION</A><DD>
12709 <DL>
12710 <DT><A HREF="#lbAZ">Brace Expansion</A><DD>
12711 <DT><A HREF="#lbBA">Tilde Expansion</A><DD>
12712 <DT><A HREF="#lbBB">Parameter Expansion</A><DD>
12713 <DT><A HREF="#lbBC">Command Substitution</A><DD>
12714 <DT><A HREF="#lbBD">Arithmetic Expansion</A><DD>
12715 <DT><A HREF="#lbBE">Process Substitution</A><DD>
12716 <DT><A HREF="#lbBF">Word Splitting</A><DD>
12717 <DT><A HREF="#lbBG">Pathname Expansion</A><DD>
12718 <DT><A HREF="#lbBH">Quote Removal</A><DD>
12719 </DL>
12720 <DT><A HREF="#lbBI">REDIRECTION</A><DD>
12721 <DL>
12722 <DT><A HREF="#lbBJ">Redirecting Input</A><DD>
12723 <DT><A HREF="#lbBK">Redirecting Output</A><DD>
12724 <DT><A HREF="#lbBL">Appending Redirected Output</A><DD>
12725 <DT><A HREF="#lbBM">Redirecting Standard Output and Standard Error</A><DD>
12726 <DT><A HREF="#lbBN">Appending Standard Output and Standard Error</A><DD>
12727 <DT><A HREF="#lbBO">Here Documents</A><DD>
12728 <DT><A HREF="#lbBP">Here Strings</A><DD>
12729 <DT><A HREF="#lbBQ">Duplicating File Descriptors</A><DD>
12730 <DT><A HREF="#lbBR">Moving File Descriptors</A><DD>
12731 <DT><A HREF="#lbBS">Opening File Descriptors for Reading and Writing</A><DD>
12732 </DL>
12733 <DT><A HREF="#lbBT">ALIASES</A><DD>
12734 <DT><A HREF="#lbBU">FUNCTIONS</A><DD>
12735 <DT><A HREF="#lbBV">ARITHMETIC EVALUATION</A><DD>
12736 <DT><A HREF="#lbBW">CONDITIONAL EXPRESSIONS</A><DD>
12737 <DT><A HREF="#lbBX">SIMPLE COMMAND EXPANSION</A><DD>
12738 <DT><A HREF="#lbBY">COMMAND EXECUTION</A><DD>
12739 <DT><A HREF="#lbBZ">COMMAND EXECUTION ENVIRONMENT</A><DD>
12740 <DT><A HREF="#lbCA">ENVIRONMENT</A><DD>
12741 <DT><A HREF="#lbCB">EXIT STATUS</A><DD>
12742 <DT><A HREF="#lbCC">SIGNALS</A><DD>
12743 <DT><A HREF="#lbCD">JOB CONTROL</A><DD>
12744 <DT><A HREF="#lbCE">PROMPTING</A><DD>
12745 <DT><A HREF="#lbCF">READLINE</A><DD>
12746 <DL>
12747 <DT><A HREF="#lbCG">Readline Notation</A><DD>
12748 <DT><A HREF="#lbCH">Readline Initialization</A><DD>
12749 <DT><A HREF="#lbCI">Readline Key Bindings</A><DD>
12750 <DT><A HREF="#lbCJ">Readline Variables</A><DD>
12751 <DT><A HREF="#lbCK">Readline Conditional Constructs</A><DD>
12752 <DT><A HREF="#lbCL">Searching</A><DD>
12753 <DT><A HREF="#lbCM">Readline Command Names</A><DD>
12754 <DT><A HREF="#lbCN">Commands for Moving</A><DD>
12755 <DT><A HREF="#lbCO">Commands for Manipulating the History</A><DD>
12756 <DT><A HREF="#lbCP">Commands for Changing Text</A><DD>
12757 <DT><A HREF="#lbCQ">Killing and Yanking</A><DD>
12758 <DT><A HREF="#lbCR">Numeric Arguments</A><DD>
12759 <DT><A HREF="#lbCS">Completing</A><DD>
12760 <DT><A HREF="#lbCT">Keyboard Macros</A><DD>
12761 <DT><A HREF="#lbCU">Miscellaneous</A><DD>
12762 <DT><A HREF="#lbCV">Programmable Completion</A><DD>
12763 </DL>
12764 <DT><A HREF="#lbCW">HISTORY</A><DD>
12765 <DT><A HREF="#lbCX">HISTORY EXPANSION</A><DD>
12766 <DL>
12767 <DT><A HREF="#lbCY">Event Designators</A><DD>
12768 <DT><A HREF="#lbCZ">Word Designators</A><DD>
12769 <DT><A HREF="#lbDA">Modifiers</A><DD>
12770 </DL>
12771 <DT><A HREF="#lbDB">SHELL BUILTIN COMMANDS</A><DD>
12772 <DT><A HREF="#lbDC">RESTRICTED SHELL</A><DD>
12773 <DT><A HREF="#lbDD">SEE ALSO</A><DD>
12774 <DT><A HREF="#lbDE">FILES</A><DD>
12775 <DT><A HREF="#lbDF">AUTHORS</A><DD>
12776 <DT><A HREF="#lbDG">BUG REPORTS</A><DD>
12777 <DT><A HREF="#lbDH">BUGS</A><DD>
12778 </DL>
12779 <HR>
12780 This document was created by man2html from bash.1.<BR>
12781 Time: 25 October 2010 12:00:43 EDT
12782 </BODY>
12783 </HTML>