]> git.ipfire.org Git - thirdparty/bash.git/blob - doc/bash.html
d809369003a6de00105a6816a30f1860d158b027
[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%>2022 September 19<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
31
32
33
34
35
36
37
38
39
40
41
42 <A NAME="lbAB">&nbsp;</A>
43 <H3>NAME</H3>
44
45 bash - GNU Bourne-Again SHell
46 <A NAME="lbAC">&nbsp;</A>
47 <H3>SYNOPSIS</H3>
48
49 <B>bash</B>
50
51 [options]
52 [command_string | file]
53 <A NAME="lbAD">&nbsp;</A>
54 <H3>COPYRIGHT</H3>
55
56
57 Bash is Copyright &#169; 1989-2022 by the Free Software Foundation, Inc.
58 <A NAME="lbAE">&nbsp;</A>
59 <H3>DESCRIPTION</H3>
60
61 <B>Bash</B>
62
63 is an <B>sh</B>-compatible command language interpreter that
64 executes commands read from the standard input or from a file.
65 <B>Bash</B>
66
67 also incorporates useful features from the <I>Korn</I> and <I>C</I>
68 shells (<B>ksh</B> and <B>csh</B>).
69 <P>
70
71 <B>Bash</B>
72
73 is intended to be a conformant implementation of the
74 Shell and Utilities portion of the IEEE POSIX specification
75 (IEEE Standard 1003.1).
76 <B>Bash</B>
77
78 can be configured to be POSIX-conformant by default.
79 <A NAME="lbAF">&nbsp;</A>
80 <H3>OPTIONS</H3>
81
82 All of the single-character shell options documented in the
83 description of the <B>set</B> builtin command, including <B>-o</B>,
84 can be used as options when the shell is invoked.
85 In addition, <B>bash</B>
86 interprets the following options when it is invoked:
87 <P>
88
89
90 <DL COMPACT>
91 <DT><B>-c</B>
92
93 <DD>
94 If the
95 <B>-c</B>
96
97 option is present, then commands are read from the first non-option argument
98 <I>command_string</I>.
99
100 If there are arguments after the
101 <I>command_string</I>,
102
103 the first argument is assigned to
104 <B>$0</B>
105
106 and any remaining arguments are assigned to the positional parameters.
107 The assignment to
108 <B>$0</B>
109
110 sets the name of the shell, which is used in warning and error messages.
111 <DT><B>-i</B>
112
113 <DD>
114 If the
115 <B>-i</B>
116
117 option is present, the shell is
118 <I>interactive</I>.
119
120 <DT><B>-l</B>
121
122 <DD>
123 Make
124 <B>bash</B>
125
126 act as if it had been invoked as a login shell (see
127 <FONT SIZE=-1><B>INVOCATION</B>
128
129 </FONT>
130 below).
131 <DT><B>-r</B>
132
133 <DD>
134 If the
135 <B>-r</B>
136
137 option is present, the shell becomes
138 <I>restricted</I>
139
140 (see
141 <FONT SIZE=-1><B>RESTRICTED SHELL</B>
142
143 </FONT>
144 below).
145 <DT><B>-s</B>
146
147 <DD>
148 If the
149 <B>-s</B>
150
151 option is present, or if no arguments remain after option
152 processing, then commands are read from the standard input.
153 This option allows the positional parameters to be set
154 when invoking an interactive shell or when reading input
155 through a pipe.
156 <DT><B>-D</B>
157
158 <DD>
159 A list of all double-quoted strings preceded by <B>$</B>
160 is printed on the standard output.
161 These are the strings that
162 are subject to language translation when the current locale
163 is not <B>C</B> or <B>POSIX</B>.
164 This implies the <B>-n</B> option; no commands will be executed.
165 <DT><B>[-+]O [</B><I>shopt_option</I>]
166
167 <DD>
168 <I>shopt_option</I> is one of the shell options accepted by the
169 <B>shopt</B> builtin (see
170 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
171
172 </FONT>
173 below).
174 If <I>shopt_option</I> is present, <B>-O</B> sets the value of that option;
175 <B>+O</B> unsets it.
176 If <I>shopt_option</I> is not supplied, the names and values of the shell
177 options accepted by <B>shopt</B> are printed on the standard output.
178 If the invocation option is <B>+O</B>, the output is displayed in a format
179 that may be reused as input.
180 <DT><B>--</B>
181
182 <DD>
183 A
184 <B>--</B>
185
186 signals the end of options and disables further option processing.
187 Any arguments after the
188 <B>--</B>
189
190 are treated as filenames and arguments. An argument of
191 <B>-</B>
192
193 is equivalent to <B>--</B>.
194
195 </DL>
196 <P>
197
198 <B>Bash</B>
199
200 also interprets a number of multi-character options.
201 These options must appear on the command line before the
202 single-character options to be recognized.
203 <P>
204
205
206 <DL COMPACT>
207 <DT><B>--debugger</B>
208
209 <DD>
210 Arrange for the debugger profile to be executed before the shell
211 starts.
212 Turns on extended debugging mode (see the description of the
213 <B>extdebug</B>
214
215 option to the
216 <B>shopt</B>
217
218 builtin below).
219 <DT><B>--dump-po-strings</B>
220
221 <DD>
222 Equivalent to <B>-D</B>, but the output is in the GNU <I>gettext</I>
223 <B>po</B> (portable object) file format.
224 <DT><B>--dump-strings</B>
225
226 <DD>
227 Equivalent to <B>-D</B>.
228 <DT><B>--help</B>
229
230 <DD>
231 Display a usage message on standard output and exit successfully.
232 <DT><B>--init-file</B> <I>file</I><DD>
233
234 <DT><B>--rcfile</B> <I>file</I><DD>
235
236 Execute commands from
237 <I>file</I>
238
239 instead of the standard personal initialization file
240 <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
241
242 if the shell is interactive (see
243 <FONT SIZE=-1><B>INVOCATION</B>
244
245 </FONT>
246 below).
247 <DT><B>--login</B>
248
249 <DD>
250 Equivalent to <B>-l</B>.
251 <DT><B>--noediting</B>
252
253 <DD>
254 Do not use the GNU
255 <B>readline</B>
256
257 library to read command lines when the shell is interactive.
258 <DT><B>--noprofile</B>
259
260 <DD>
261 Do not read either the system-wide startup file
262
263 <A HREF="file:/etc/profile"><I>/etc/profile</I></A>
264
265 or any of the personal initialization files
266 <A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>,
267
268 <A HREF="file:~/.bash_login"><I>~/.bash_login</I></A>,
269
270 or
271 <A HREF="file:~/.profile"><I>~/.profile</I></A>.
272
273 By default,
274 <B>bash</B>
275
276 reads these files when it is invoked as a login shell (see
277 <FONT SIZE=-1><B>INVOCATION</B>
278
279 </FONT>
280 below).
281 <DT><B>--norc</B>
282
283 <DD>
284 Do not read and execute the personal initialization file
285 <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
286
287 if the shell is interactive.
288 This option is on by default if the shell is invoked as
289 <B>sh</B>.
290
291 <DT><B>--posix</B>
292
293 <DD>
294 Change the behavior of <B>bash</B> where the default operation differs
295 from the POSIX standard to match the standard (<I>posix mode</I>).
296 See
297 <FONT SIZE=-1><B>SEE ALSO</B>
298
299 </FONT>
300 below for a reference to a document that details how posix mode affects
301 bash's behavior.
302 <DT><B>--restricted</B>
303
304 <DD>
305 The shell becomes restricted (see
306 <FONT SIZE=-1><B>RESTRICTED SHELL</B>
307
308 </FONT>
309 below).
310 <DT><B>--verbose</B>
311
312 <DD>
313 Equivalent to <B>-v</B>.
314 <DT><B>--version</B>
315
316 <DD>
317 Show version information for this instance of
318 <B>bash</B>
319
320 on the standard output and exit successfully.
321
322 </DL>
323 <A NAME="lbAG">&nbsp;</A>
324 <H3>ARGUMENTS</H3>
325
326 If arguments remain after option processing, and neither the
327 <B>-c</B>
328
329 nor the
330 <B>-s</B>
331
332 option has been supplied, the first argument is assumed to
333 be the name of a file containing shell commands.
334 If
335 <B>bash</B>
336
337 is invoked in this fashion,
338 <B>$0</B>
339
340 is set to the name of the file, and the positional parameters
341 are set to the remaining arguments.
342 <B>Bash</B>
343
344 reads and executes commands from this file, then exits.
345 <B>Bash</B>'s exit status is the exit status of the last command
346 executed in the script.
347 If no commands are executed, the exit status is 0.
348 An attempt is first made to open the file in the current directory, and,
349 if no file is found, then the shell searches the directories in
350 <FONT SIZE=-1><B>PATH</B>
351
352 </FONT>
353 for the script.
354 <A NAME="lbAH">&nbsp;</A>
355 <H3>INVOCATION</H3>
356
357 A <I>login shell</I> is one whose first character of argument zero is a
358 <B>-</B>,
359
360 or one started with the
361 <B>--login</B>
362
363 option.
364 <P>
365
366 An <I>interactive</I> shell is one started without non-option arguments
367 (unless <B>-s</B> is specified)
368 and without the
369 <B>-c</B>
370
371 option,
372 whose standard input and error are
373 both connected to terminals (as determined by
374 <I>isatty</I>(3)),
375
376 or one started with the
377 <B>-i</B>
378
379 option.
380 <FONT SIZE=-1><B>PS1</B>
381
382 </FONT>
383 is set and
384 <B>$-</B>
385
386 includes
387 <B>i</B>
388
389 if
390 <B>bash</B>
391
392 is interactive,
393 allowing a shell script or a startup file to test this state.
394 <P>
395
396 The following paragraphs describe how
397 <B>bash</B>
398
399 executes its startup files.
400 If any of the files exist but cannot be read,
401 <B>bash</B>
402
403 reports an error.
404 Tildes are expanded in filenames as described below under
405 <B>Tilde Expansion</B>
406
407 in the
408 <FONT SIZE=-1><B>EXPANSION</B>
409
410 </FONT>
411 section.
412 <P>
413
414 When
415 <B>bash</B>
416
417 is invoked as an interactive login shell, or as a non-interactive shell
418 with the <B>--login</B> option, it first reads and
419 executes commands from the file <A HREF="file:/etc/profile"><I>/etc/profile</I></A>, if that
420 file exists.
421 After reading that file, it looks for <A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>,
422 <A HREF="file:~/.bash_login"><I>~/.bash_login</I></A>, and <A HREF="file:~/.profile"><I>~/.profile</I></A>, in that order, and reads
423 and executes commands from the first one that exists and is readable.
424 The
425 <B>--noprofile</B>
426
427 option may be used when the shell is started to inhibit this behavior.
428 <P>
429
430 When an interactive login shell exits,
431 or a non-interactive login shell executes the <B>exit</B> builtin command,
432 <B>bash</B>
433
434 reads and executes commands from the file <A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A>, if it
435 exists.
436 <P>
437
438 When an interactive shell that is not a login shell is started,
439 <B>bash</B>
440
441 reads and executes commands from <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>, if that file exists.
442 This may be inhibited by using the
443 <B>--norc</B>
444
445 option.
446 The <B>--rcfile</B> <I>file</I> option will force
447 <B>bash</B>
448
449 to read and execute commands from <I>file</I> instead of <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>.
450 <P>
451
452 When
453 <B>bash</B>
454
455 is started non-interactively, to run a shell script, for example, it
456 looks for the variable
457 <FONT SIZE=-1><B>BASH_ENV</B>
458
459 </FONT>
460 in the environment, expands its value if it appears there, and uses the
461 expanded value as the name of a file to read and execute.
462 <B>Bash</B>
463
464 behaves as if the following command were executed:
465 <P>
466 <DL COMPACT><DT><DD>
467 <TT>if [ -n &quot;$BASH_ENV&quot; ]; then . &quot;$BASH_ENV&quot;; fi</TT>
468
469 </DL>
470
471 <P>
472 but the value of the
473 <FONT SIZE=-1><B>PATH</B>
474
475 </FONT>
476 variable is not used to search for the filename.
477 <P>
478
479 If
480 <B>bash</B>
481
482 is invoked with the name
483 <B>sh</B>,
484
485 it tries to mimic the startup behavior of historical versions of
486 <B>sh</B>
487
488 as closely as possible,
489 while conforming to the POSIX standard as well.
490 When invoked as an interactive login shell, or a non-interactive
491 shell with the <B>--login</B> option, it first attempts to
492 read and execute commands from
493 <A HREF="file:/etc/profile"><I>/etc/profile</I></A>
494
495 and
496 <A HREF="file:~/.profile"><I>~/.profile</I></A>,
497
498 in that order.
499 The
500 <B>--noprofile</B>
501
502 option may be used to inhibit this behavior.
503 When invoked as an interactive shell with the name
504 <B>sh</B>,
505
506 <B>bash</B>
507
508 looks for the variable
509 <FONT SIZE=-1><B>ENV</B>,
510
511 </FONT>
512 expands its value if it is defined, and uses the
513 expanded value as the name of a file to read and execute.
514 Since a shell invoked as
515 <B>sh</B>
516
517 does not attempt to read and execute commands from any other startup
518 files, the
519 <B>--rcfile</B>
520
521 option has no effect.
522 A non-interactive shell invoked with the name
523 <B>sh</B>
524
525 does not attempt to read any other startup files.
526 When invoked as
527 <B>sh</B>,
528
529 <B>bash</B>
530
531 enters
532 <I>posix</I>
533
534 mode after the startup files are read.
535 <P>
536
537 When
538 <B>bash</B>
539
540 is started in
541 <I>posix</I>
542
543 mode, as with the
544 <B>--posix</B>
545
546 command line option, it follows the POSIX standard for startup files.
547 In this mode, interactive shells expand the
548 <FONT SIZE=-1><B>ENV</B>
549
550 </FONT>
551 variable and commands are read and executed from the file
552 whose name is the expanded value.
553 No other startup files are read.
554 <P>
555
556 <B>Bash</B>
557
558 attempts to determine when it is being run with its standard input
559 connected to a network connection, as when executed by
560 the historical remote shell daemon, usually <I>rshd</I>,
561 or the secure shell daemon <I>sshd</I>.
562 If
563 <B>bash</B>
564
565 determines it is being run non-interactively in this fashion,
566 it reads and executes commands from <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>,
567 if that file exists and is readable.
568 It will not do this if invoked as <B>sh</B>.
569 The
570 <B>--norc</B>
571
572 option may be used to inhibit this behavior, and the
573 <B>--rcfile</B>
574
575 option may be used to force another file to be read, but neither
576 <I>rshd</I> nor <I>sshd</I> generally invoke the shell with those options
577 or allow them to be specified.
578 <P>
579
580 If the shell is started with the effective user (group) id not equal to the
581 real user (group) id, and the <B>-p</B> option is not supplied, no startup
582 files are read, shell functions are not inherited from the environment, the
583 <FONT SIZE=-1><B>SHELLOPTS</B>,
584
585 </FONT>
586 <FONT SIZE=-1><B>BASHOPTS</B>,
587
588 </FONT>
589 <FONT SIZE=-1><B>CDPATH</B>,
590
591 </FONT>
592 and
593 <FONT SIZE=-1><B>GLOBIGNORE</B>
594
595 </FONT>
596 variables, if they appear in the environment, are ignored,
597 and the effective user id is set to the real user id.
598 If the <B>-p</B> option is supplied at invocation, the startup behavior is
599 the same, but the effective user id is not reset.
600 <A NAME="lbAI">&nbsp;</A>
601 <H3>DEFINITIONS</H3>
602
603 The following definitions are used throughout the rest of this
604 document.
605
606 <DL COMPACT>
607 <DT><B>blank</B>
608
609 <DD>
610 A space or tab.
611 <DT><B>word</B>
612
613 <DD>
614 A sequence of characters considered as a single unit by the shell.
615 Also known as a
616 <B>token</B>.
617
618 <DT><B>name</B>
619
620 <DD>
621 A
622 <I>word</I>
623
624 consisting only of alphanumeric characters and underscores, and
625 beginning with an alphabetic character or an underscore. Also
626 referred to as an
627 <B>identifier</B>.
628
629 <DT><B>metacharacter</B>
630
631 <DD>
632 A character that, when unquoted, separates words. One of the following:
633 <BR>
634
635 <DL COMPACT><DT><DD>
636 <P>
637
638 <B>| &amp; ; ( ) &lt; &gt; space tab newline</B>
639
640 </DL>
641
642 <DT><B>control operator</B>
643
644 <DD>
645 A <I>token</I> that performs a control function. It is one of the following
646 symbols:
647 <DL COMPACT><DT><DD>
648 <P>
649
650 <B>|| &amp; &amp;&amp; ; ;; ;&amp; ;;&amp; ( ) | |&amp; &lt;newline&gt;</B>
651
652 </DL>
653
654
655 </DL>
656 <A NAME="lbAJ">&nbsp;</A>
657 <H3>RESERVED WORDS</H3>
658
659 <I>Reserved words</I> are words that have a special meaning to the shell.
660 The following words are recognized as reserved when unquoted and either
661 the first word of a command (see
662 <FONT SIZE=-1><B>SHELL GRAMMAR</B>
663
664 </FONT>
665 below), the third word of a
666 <B>case</B>
667
668 or
669 <B>select</B>
670
671 command
672 (only <B>in</B> is valid), or the third word of a
673 <B>for</B>
674
675 command (only <B>in</B> and <B>do</B> are valid):
676 <DL COMPACT><DT><DD>
677
678 <P>
679
680 <B>
681 </B>
682
683 ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]]
684 </DL>
685
686
687 <A NAME="lbAK">&nbsp;</A>
688 <H3>SHELL GRAMMAR</H3>
689
690 This section describes the syntax of the various forms of shell commands.
691 <A NAME="lbAL">&nbsp;</A>
692 <H4>Simple Commands</H4>
693
694 A <I>simple command</I> is a sequence of optional variable assignments
695 followed by <B>blank</B>-separated words and redirections, and
696 terminated by a <I>control operator</I>. The first word
697 specifies the command to be executed, and is passed as argument zero.
698 The remaining words are passed as arguments to the invoked command.
699 <P>
700
701 The return value of a <I>simple command</I> is its exit status, or
702 128+<I>n</I> if the command is terminated by signal
703 <I>n</I>.
704
705 <A NAME="lbAM">&nbsp;</A>
706 <H4>Pipelines</H4>
707
708 A <I>pipeline</I> is a sequence of one or more commands separated by
709 one of the control operators
710 <B>|</B>
711
712 or <B>|&amp;</B>.
713 The format for a pipeline is:
714 <DL COMPACT><DT><DD>
715 <P>
716
717 [<B>time</B> [<B>-p</B>]] [ ! ] <I>command1</I> [ [<B>|</B>|<B>|&amp;</B>] <I>command2</I> ... ]
718 </DL>
719
720 <P>
721
722 The standard output of
723 <I>command1</I>
724
725 is connected via a pipe to the standard input of
726 <I>command2</I>.
727
728 This connection is performed before any redirections specified by the
729 <I>command1</I>(see
730
731 <FONT SIZE=-1><B>REDIRECTION</B>
732
733 </FONT>
734 below).
735 If <B>|&amp;</B> is used, <I>command1</I>'s standard error, in addition to its
736 standard output, is connected to
737 <I>command2</I>'s standard input through the pipe;
738 it is shorthand for <B>2&gt;&amp;1 |</B>.
739 This implicit redirection of the standard error to the standard output is
740 performed after any redirections specified by <I>command1</I>.
741 <P>
742
743 The return status of a pipeline is the exit status of the last
744 command, unless the <B>pipefail</B> option is enabled.
745 If <B>pipefail</B> is enabled, the pipeline's return status is the
746 value of the last (rightmost) command to exit with a non-zero status,
747 or zero if all commands exit successfully.
748 If the reserved word
749 <B>!</B>
750
751 precedes a pipeline, the exit status of that pipeline is the logical
752 negation of the exit status as described above.
753 The shell waits for all commands in the pipeline to
754 terminate before returning a value.
755 <P>
756
757 If the
758 <B>time</B>
759
760 reserved word precedes a pipeline, the elapsed as well as user and
761 system time consumed by its execution are reported when the pipeline
762 terminates.
763 The <B>-p</B> option changes the output format to that specified by POSIX.
764 When the shell is in <I>posix mode</I>, it does not recognize
765 <B>time</B> as a reserved word if the next token begins with a `-'.
766 The
767 <FONT SIZE=-1><B>TIMEFORMAT</B>
768
769 </FONT>
770 variable may be set to a format string that specifies how the timing
771 information should be displayed; see the description of
772 <FONT SIZE=-1><B>TIMEFORMAT</B>
773
774 </FONT>
775 under
776 <B>Shell Variables</B>
777
778 below.
779 <P>
780
781 When the shell is in <I>posix mode</I>, <B>time</B>
782 may be followed by a newline. In this case, the shell displays the
783 total user and system time consumed by the shell and its children.
784 The
785 <FONT SIZE=-1><B>TIMEFORMAT</B>
786
787 </FONT>
788 variable may be used to specify the format of
789 the time information.
790 <P>
791
792 Each command in a multi-command pipeline,
793 where pipes are created,
794 is executed in a <I>subshell</I>, which is a
795 separate process.
796 See
797 <FONT SIZE=-1><B>COMMAND EXECUTION ENVIRONMENT</B></FONT>
798 for a description of subshells and a subshell environment.
799 If the <B>lastpipe</B> option is enabled using the <B>shopt</B> builtin
800 (see the description of <B>shopt</B> below),
801 the last element of a pipeline may be run by the shell process
802 when job control is not active.
803 <A NAME="lbAN">&nbsp;</A>
804 <H4>Lists</H4>
805
806 A <I>list</I> is a sequence of one or more pipelines separated by one
807 of the operators
808 <B>;</B>,
809
810 <B>&amp;</B>,
811
812 <B>&amp;&amp;</B>,
813
814 or
815 <B>||</B>,
816
817 and optionally terminated by one of
818 <B>;</B>,
819
820 <B>&amp;</B>,
821
822 or
823 <B>&lt;newline&gt;</B>.
824
825 <P>
826
827 Of these list operators,
828 <B>&amp;&amp;</B>
829
830 and
831 <B>||</B>
832
833 have equal precedence, followed by
834 <B>;</B>
835
836 and
837 <B>&amp;</B>,
838
839 which have equal precedence.
840 <P>
841
842 A sequence of one or more newlines may appear in a <I>list</I> instead
843 of a semicolon to delimit commands.
844 <P>
845
846 If a command is terminated by the control operator
847 <B>&amp;</B>,
848
849 the shell executes the command in the <I>background</I>
850 in a subshell.
851 The shell does not wait for the command to
852 finish, and the return status is 0.
853 These are referred to as <I>asynchronous</I> commands.
854 Commands separated by a
855 <B>;</B>
856
857 are executed sequentially; the shell waits for each
858 command to terminate in turn. The return status is the
859 exit status of the last command executed.
860 <P>
861
862 AND and OR lists are sequences of one or more pipelines separated by the
863 <B>&amp;&amp;</B> and <B>||</B> control operators, respectively.
864 AND and OR lists are executed with left associativity.
865 An AND list has the form
866 <DL COMPACT><DT><DD>
867 <P>
868
869 <I>command1</I> <B>&amp;&amp;</B> <I>command2</I>
870 </DL>
871
872 <P>
873
874 <I>command2</I>
875
876 is executed if, and only if,
877 <I>command1</I>
878
879 returns an exit status of zero (success).
880 <P>
881
882 An OR list has the form
883 <DL COMPACT><DT><DD>
884 <P>
885
886 <I>command1</I> <B>||</B> <I>command2</I>
887 </DL>
888
889 <P>
890
891 <I>command2</I>
892
893 is executed if, and only if,
894 <I>command1</I>
895
896 returns a non-zero exit status.
897 The return status of
898 AND and OR lists is the exit status of the last command
899 executed in the list.
900 <A NAME="lbAO">&nbsp;</A>
901 <H4>Compound Commands</H4>
902
903 A <I>compound command</I> is one of the following.
904 In most cases a <I>list</I> in a command's description may be separated from
905 the rest of the command by one or more newlines, and may be followed by a
906 newline in place of a semicolon.
907 <DL COMPACT>
908 <DT>(<I>list</I>)<DD>
909 <I>list</I> is executed in a subshell (see
910 <FONT SIZE=-1><B>COMMAND EXECUTION ENVIRONMENT</B></FONT>
911 below for a description of a subshell environment).
912 Variable assignments and builtin
913 commands that affect the shell's environment do not remain in effect
914 after the command completes. The return status is the exit status of
915 <I>list</I>.
916 <DT>{ <I>list</I>; }<DD>
917 <I>list</I> is simply executed in the current shell environment.
918 <I>list</I> must be terminated with a newline or semicolon.
919 This is known as a <I>group command</I>.
920 The return status is the exit status of
921 <I>list</I>.
922 Note that unlike the metacharacters <B>(</B> and <B>)</B>, <B>{</B> and
923 <B>}</B> are <I>reserved words</I> and must occur where a reserved
924 word is permitted to be recognized. Since they do not cause a word
925 break, they must be separated from <I>list</I> by whitespace or another
926 shell metacharacter.
927 <DT>((<I>expression</I>))<DD>
928 The <I>expression</I> is evaluated according to the rules described
929 below under
930 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
931
932 </FONT>
933 If the value of the expression is non-zero, the return status is 0;
934 otherwise the return status is 1.
935 The <I>expression</I>
936 undergoes the same expansions
937 as if it were within double quotes,
938 but double quote characters in <I>expression</I> are not treated specially
939 and are removed.
940 <DT><B>[[</B> <I>expression</I> <B>]]</B><DD>
941 Return a status of 0 or 1 depending on the evaluation of
942 the conditional expression <I>expression</I>.
943 Expressions are composed of the primaries described below under
944 <FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>.
945
946 </FONT>
947 The words between the <B>[[</B> and <B>]]</B> do not undergo word splitting
948 and pathname expansion.
949 The shell performs tilde expansion, parameter and
950 variable expansion, arithmetic expansion, command substitution, process
951 substitution, and quote removal on those words
952 (the expansions that would occur if the words were enclosed in double quotes).
953 Conditional operators such as <B>-f</B> must be unquoted to be recognized
954 as primaries.
955 <P>
956
957
958 When used with <B>[[</B>, the <B>&lt;</B> and <B>&gt;</B> operators sort
959 lexicographically using the current locale.
960 <P>
961
962
963 When the <B>==</B> and <B>!=</B> operators are used, the string to the
964 right of the operator is considered a pattern and matched according
965 to the rules described below under <B>Pattern Matching</B>,
966 as if the <B>extglob</B> shell option were enabled.
967 The <B>=</B> operator is equivalent to <B>==</B>.
968 If the
969 <B>nocasematch</B>
970
971 shell option is enabled, the match is performed without regard to the case
972 of alphabetic characters.
973 The return value is 0 if the string matches (<B>==</B>) or does not match
974 (<B>!=</B>) the pattern, and 1 otherwise.
975 Any part of the pattern may be quoted to force the quoted portion
976 to be matched as a string.
977 <P>
978
979
980 An additional binary operator, <B>=~</B>, is available, with the same
981 precedence as <B>==</B> and <B>!=</B>.
982 When it is used, the string to the right of the operator is considered
983 a POSIX extended regular expression and matched accordingly
984 (using the POSIX <I>regcomp</I> and <I>regexec</I> interfaces
985 usually described in <I>regex</I>(3)).
986 The return value is 0 if the string matches
987 the pattern, and 1 otherwise.
988 If the regular expression is syntactically incorrect, the conditional
989 expression's return value is 2.
990 If the
991 <B>nocasematch</B>
992
993 shell option is enabled, the match is performed without regard to the case
994 of alphabetic characters.
995 If any part of the pattern is quoted, the quoted portion is matched literally.
996 This means every character in the quoted portion matches itself,
997 instead of having any special pattern matching meaning.
998 If the pattern is stored in a shell variable, quoting the variable
999 expansion forces the entire pattern to be matched literally.
1000 Treat bracket expressions in regular expressions carefully,
1001 since normal quoting and pattern characters lose their meanings
1002 between brackets.
1003 <P>
1004
1005
1006 The pattern will match if it matches any part of the string.
1007 Anchor the pattern using the <B>^</B> and <B>$</B> regular expression
1008 operators to force it to match the entire string.
1009 The array variable
1010 <FONT SIZE=-1><B>BASH_REMATCH</B>
1011
1012 </FONT>
1013 records which parts of the string matched the pattern.
1014 The element of
1015 <FONT SIZE=-1><B>BASH_REMATCH</B>
1016
1017 </FONT>
1018 with index 0 contains the portion of
1019 the string matching the entire regular expression.
1020 Substrings matched by parenthesized subexpressions within the regular
1021 expression are saved in the remaining
1022 <FONT SIZE=-1><B>BASH_REMATCH</B>
1023
1024 </FONT>
1025 indices. The element of
1026 <FONT SIZE=-1><B>BASH_REMATCH</B>
1027
1028 </FONT>
1029 with index <I>n</I> is the portion of the
1030 string matching the <I>n</I>th parenthesized subexpression.
1031 Bash sets
1032 <FONT SIZE=-1><B>BASH_REMATCH</B>
1033
1034 </FONT>
1035 in the global scope; declaring it as a local variable will lead to
1036 unexpected results.
1037 <P>
1038
1039
1040 Expressions may be combined using the following operators, listed
1041 in decreasing order of precedence:
1042 <P>
1043
1044
1045 <DL COMPACT><DT><DD>
1046
1047 <DL COMPACT>
1048 <DT><B>( </B><I>expression</I> )
1049
1050 <DD>
1051 Returns the value of <I>expression</I>.
1052 This may be used to override the normal precedence of operators.
1053 <DT><B>! </B><I>expression</I>
1054
1055 <DD>
1056 True if
1057 <I>expression</I>
1058
1059 is false.
1060 <DT><I>expression1</I> <B>&amp;&amp;</B> <I>expression2</I><DD>
1061 True if both
1062 <I>expression1</I>
1063
1064 and
1065 <I>expression2</I>
1066
1067 are true.
1068 <DT><I>expression1</I> <B>||</B> <I>expression2</I><DD>
1069 True if either
1070 <I>expression1</I>
1071
1072 or
1073 <I>expression2</I>
1074
1075 is true.
1076
1077 </DL>
1078 <P>
1079
1080 The <B>&amp;&amp;</B> and <B>||</B>
1081 operators do not evaluate <I>expression2</I> if the value of
1082 <I>expression1</I> is sufficient to determine the return value of
1083 the entire conditional expression.
1084 </DL>
1085
1086 <DT><B>for</B> <I>name</I> [ [ <B>in</B> [ <I>word ...</I> ] ] ; ] <B>do</B> <I>list</I> ; <B>done</B><DD>
1087 The list of words following <B>in</B> is expanded, generating a list
1088 of items.
1089 The variable <I>name</I> is set to each element of this list
1090 in turn, and <I>list</I> is executed each time.
1091 If the <B>in</B> <I>word</I> is omitted, the <B>for</B> command executes
1092 <I>list</I> once for each positional parameter that is set (see
1093 <FONT SIZE=-1><B>PARAMETERS</B>
1094
1095 </FONT>
1096 below).
1097 The return status is the exit status of the last command that executes.
1098 If the expansion of the items following <B>in</B> results in an empty
1099 list, no commands are executed, and the return status is 0.
1100 <DT><B>for</B> (( <I>expr1</I> ; <I>expr2</I> ; <I>expr3</I> )) ; <B>do</B> <I>list</I> ; <B>done</B><DD>
1101 First, the arithmetic expression <I>expr1</I> is evaluated according
1102 to the rules described below under
1103 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
1104
1105 </FONT>
1106 The arithmetic expression <I>expr2</I> is then evaluated repeatedly
1107 until it evaluates to zero.
1108 Each time <I>expr2</I> evaluates to a non-zero value, <I>list</I> is
1109 executed and the arithmetic expression <I>expr3</I> is evaluated.
1110 If any expression is omitted, it behaves as if it evaluates to 1.
1111 The return value is the exit status of the last command in <I>list</I>
1112 that is executed, or false if any of the expressions is invalid.
1113 <DT><B>select</B> <I>name</I> [ <B>in</B> <I>word</I> ] ; <B>do</B> <I>list</I> ; <B>done</B><DD>
1114 The list of words following <B>in</B> is expanded, generating a list
1115 of items, and the set of expanded words is printed on the standard
1116 error, each preceded by a number. If the <B>in</B>
1117 <I>word</I> is omitted, the positional parameters are printed (see
1118 <FONT SIZE=-1><B>PARAMETERS</B>
1119
1120 </FONT>
1121 below).
1122 <B>select</B>
1123
1124 then displays the
1125 <FONT SIZE=-1><B>PS3</B>
1126
1127 </FONT>
1128 prompt and reads a line from the standard input.
1129 If the line consists of a number corresponding to one of
1130 the displayed words, then the value of
1131 <I>name</I>
1132
1133 is set to that word.
1134 If the line is empty, the words and prompt are displayed again.
1135 If EOF is read, the <B>select</B> command completes and returns 1.
1136 Any other value read causes
1137 <I>name</I>
1138
1139 to be set to null. The line read is saved in the variable
1140 <FONT SIZE=-1><B>REPLY</B>.
1141
1142 </FONT>
1143 The
1144 <I>list</I>
1145
1146 is executed after each selection until a
1147 <B>break</B>
1148
1149 command is executed.
1150 The exit status of
1151 <B>select</B>
1152
1153 is the exit status of the last command executed in
1154 <I>list</I>,
1155
1156 or zero if no commands were executed.
1157 <DT><B>case</B> <I>word</I> <B>in</B> [ [(] <I>pattern</I> [ <B>|</B> <I>pattern</I> ]
1158 <DD>
1159 A <B>case</B> command first expands <I>word</I>, and tries to match
1160 it against each <I>pattern</I> in turn, using the matching rules
1161 described under
1162 <B>Pattern Matching</B>
1163
1164 below.
1165 The <I>word</I> is expanded using tilde
1166 expansion, parameter and variable expansion, arithmetic expansion,
1167 command substitution, process substitution and quote removal.
1168 Each <I>pattern</I> examined is expanded using tilde
1169 expansion, parameter and variable expansion, arithmetic expansion,
1170 command substitution, process substitution, and quote removal.
1171 If the
1172 <B>nocasematch</B>
1173
1174 shell option is enabled, the match is performed without regard to the case
1175 of alphabetic characters.
1176 When a match is found, the corresponding <I>list</I> is executed.
1177 If the <B>;;</B> operator is used, no subsequent matches are attempted after
1178 the first pattern match.
1179 Using <B>;&amp;</B> in place of <B>;;</B> causes execution to continue with
1180 the <I>list</I> associated with the next set of patterns.
1181 Using <B>;;&amp;</B> in place of <B>;;</B> causes the shell to test the next
1182 pattern list in the statement, if any, and execute any associated <I>list</I>
1183 on a successful match,
1184 continuing the case statement execution as if the pattern list had not matched.
1185 The exit status is zero if no
1186 pattern matches. Otherwise, it is the exit status of the
1187 last command executed in <I>list</I>.
1188 <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>
1189 The
1190 <B>if</B>
1191
1192 <I>list</I>
1193
1194 is executed. If its exit status is zero, the
1195 <B>then</B> <I>list</I> is executed. Otherwise, each <B>elif</B>
1196 <I>list</I> is executed in turn, and if its exit status is zero,
1197 the corresponding <B>then</B> <I>list</I> is executed and the
1198 command completes. Otherwise, the <B>else</B> <I>list</I> is
1199 executed, if present. The exit status is the exit status of the
1200 last command executed, or zero if no condition tested true.
1201 <DT><B>while</B> <I>list-1</I>; <B>do</B> <I>list-2</I>; <B>done</B><DD>
1202
1203 <DT><B>until</B> <I>list-1</I>; <B>do</B> <I>list-2</I>; <B>done</B><DD>
1204
1205 The <B>while</B> command continuously executes the list
1206 <I>list-2</I> as long as the last command in the list <I>list-1</I> returns
1207 an exit status of zero. The <B>until</B> command is identical
1208 to the <B>while</B> command, except that the test is negated:
1209 <I>list-2</I>
1210
1211 is executed as long as the last command in
1212 <I>list-1</I>
1213
1214 returns a non-zero exit status.
1215 The exit status of the <B>while</B> and <B>until</B> commands
1216 is the exit status
1217 of the last command executed in <I>list-2</I>, or zero if
1218 none was executed.
1219 </DL>
1220 <A NAME="lbAP">&nbsp;</A>
1221 <H4>Coprocesses</H4>
1222
1223 A <I>coprocess</I> is a shell command preceded by the <B>coproc</B> reserved
1224 word.
1225 A coprocess is executed asynchronously in a subshell, as if the command
1226 had been terminated with the <B>&amp;</B> control operator, with a two-way pipe
1227 established between the executing shell and the coprocess.
1228 <P>
1229
1230 The syntax for a coprocess is:
1231 <DL COMPACT><DT><DD>
1232 <P>
1233
1234 <B>coproc</B> [<I>NAME</I>] <I>command</I> [<I>redirections</I>]
1235 </DL>
1236
1237 <P>
1238
1239 This creates a coprocess named <I>NAME</I>.
1240 <I>command</I> may be either a simple command or a compound
1241 command (see above).
1242 <I>NAME</I> is a shell variable name.
1243 If <I>NAME</I> is not supplied, the default name is <B>COPROC</B>.
1244 <P>
1245
1246 The recommended form to use for a coprocess is
1247 <DL COMPACT><DT><DD>
1248 <P>
1249
1250 <B>coproc</B> <I>NAME</I> { <I>command</I> [<I>redirections</I>]; }
1251 </DL>
1252
1253 <P>
1254
1255 This form is recommended because simple commands result in the coprocess
1256 always being named <B>COPROC</B>, and it is simpler to use and more complete
1257 than the other compound commands.
1258 <P>
1259
1260 If <I>command</I> is a compound command, <I>NAME</I> is optional. The
1261 word following <B>coproc</B> determines whether that word is interpreted
1262 as a variable name: it is interpreted as <I>NAME</I> if it is not a
1263 reserved word that introduces a compound command.
1264 If <I>command</I> is a simple command, <I>NAME</I> is not allowed; this
1265 is to avoid confusion between <I>NAME</I> and the first word of the simple
1266 command.
1267 <P>
1268
1269 When the coprocess is executed, the shell creates an array variable (see
1270 <B>Arrays</B>
1271
1272 below) named <I>NAME</I> in the context of the executing shell.
1273 The standard output of
1274 <I>command</I>
1275
1276 is connected via a pipe to a file descriptor in the executing shell,
1277 and that file descriptor is assigned to <I>NAME</I>[0].
1278 The standard input of
1279 <I>command</I>
1280
1281 is connected via a pipe to a file descriptor in the executing shell,
1282 and that file descriptor is assigned to <I>NAME</I>[1].
1283 This pipe is established before any redirections specified by the
1284 command (see
1285 <FONT SIZE=-1><B>REDIRECTION</B>
1286
1287 </FONT>
1288 below).
1289 The file descriptors can be utilized as arguments to shell commands
1290 and redirections using standard word expansions.
1291 Other than those created to execute command and process substitutions,
1292 the file descriptors are not available in subshells.
1293 <P>
1294
1295 The process ID of the shell spawned to execute the coprocess is
1296 available as the value of the variable <I>NAME</I>_PID.
1297 The <B>wait</B>
1298 builtin command may be used to wait for the coprocess to terminate.
1299 <P>
1300
1301 Since the coprocess is created as an asynchronous command,
1302 the <B>coproc</B> command always returns success.
1303 The return status of a coprocess is the exit status of <I>command</I>.
1304 <A NAME="lbAQ">&nbsp;</A>
1305 <H4>Shell Function Definitions</H4>
1306
1307 A shell function is an object that is called like a simple command and
1308 executes a compound command with a new set of positional parameters.
1309 Shell functions are declared as follows:
1310 <DL COMPACT>
1311 <DT><I>fname</I> () <I>compound-command</I> [<I>redirection</I>]<DD>
1312
1313 <DT><B>function</B> <I>fname</I> [()] <I>compound-command</I> [<I>redirection</I>]<DD>
1314
1315 This defines a function named <I>fname</I>.
1316 The reserved word <B>function</B> is optional.
1317 If the <B>function</B> reserved word is supplied, the parentheses are optional.
1318 The <I>body</I> of the function is the compound command
1319 <I>compound-command</I>
1320
1321 (see <B>Compound Commands</B> above).
1322 That command is usually a <I>list</I> of commands between { and }, but
1323 may be any command listed under <B>Compound Commands</B> above.
1324 If the <B>function</B> reserved word is used, but the
1325 parentheses are not supplied, the braces are recommended.
1326 <I>compound-command</I> is executed whenever <I>fname</I> is specified as the
1327 name of a simple command.
1328 When in <I>posix mode</I>, <I>fname</I> must be a valid shell <I>name</I>
1329 and may not be the name of one of the
1330 POSIX <I>special builtins</I>.
1331 In default mode, a function name can be any unquoted shell word that does
1332 not contain <B>$</B>.
1333 Any redirections (see
1334 <FONT SIZE=-1><B>REDIRECTION</B>
1335
1336 </FONT>
1337 below) specified when a function is defined are performed
1338 when the function is executed.
1339 The exit status of a function definition is zero unless a syntax error
1340 occurs or a readonly function with the same name already exists.
1341 When executed, the exit status of a function is the exit status of the
1342 last command executed in the body. (See
1343 <FONT SIZE=-1><B>FUNCTIONS</B>
1344
1345 </FONT>
1346 below.)
1347 </DL>
1348 <A NAME="lbAR">&nbsp;</A>
1349 <H3>COMMENTS</H3>
1350
1351 In a non-interactive shell, or an interactive shell in which the
1352 <B>interactive_comments</B>
1353
1354 option to the
1355 <B>shopt</B>
1356
1357 builtin is enabled (see
1358 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
1359
1360 </FONT>
1361 below), a word beginning with
1362 <B>#</B>
1363
1364 causes that word and all remaining characters on that line to
1365 be ignored. An interactive shell without the
1366 <B>interactive_comments</B>
1367
1368 option enabled does not allow comments. The
1369 <B>interactive_comments</B>
1370
1371 option is on by default in interactive shells.
1372 <A NAME="lbAS">&nbsp;</A>
1373 <H3>QUOTING</H3>
1374
1375 <I>Quoting</I> is used to remove the special meaning of certain
1376 characters or words to the shell. Quoting can be used to
1377 disable special treatment for special characters, to prevent
1378 reserved words from being recognized as such, and to prevent
1379 parameter expansion.
1380 <P>
1381
1382 Each of the <I>metacharacters</I> listed above under
1383 <FONT SIZE=-1><B>DEFINITIONS</B>
1384
1385 </FONT>
1386 has special meaning to the shell and must be quoted if it is to
1387 represent itself.
1388 <P>
1389
1390 When the command history expansion facilities are being used
1391 (see
1392 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
1393
1394 </FONT>
1395 below), the
1396 <I>history expansion</I> character, usually <B>!</B>, must be quoted
1397 to prevent history expansion.
1398 <P>
1399
1400 There are three quoting mechanisms: the
1401 <I>escape character</I>,
1402
1403 single quotes, and double quotes.
1404 <P>
1405
1406 A non-quoted backslash (<B>\</B>) is the
1407 <I>escape character</I>.
1408
1409 It preserves the literal value of the next character that follows,
1410 with the exception of &lt;newline&gt;. If a <B>\</B>&lt;newline&gt; pair
1411 appears, and the backslash is not itself quoted, the <B>\</B>&lt;newline&gt;
1412 is treated as a line continuation (that is, it is removed from the
1413 input stream and effectively ignored).
1414 <P>
1415
1416 Enclosing characters in single quotes preserves the literal value
1417 of each character within the quotes. A single quote may not occur
1418 between single quotes, even when preceded by a backslash.
1419 <P>
1420
1421 Enclosing characters in double quotes preserves the literal value
1422 of all characters within the quotes, with the exception of
1423 <B>$</B>,
1424
1425 <B>`</B>,
1426
1427 <B>\</B>,
1428
1429 and, when history expansion is enabled,
1430 <B>!</B>.
1431
1432 When the shell is in <I>posix mode</I>, the <B>!</B> has no special meaning
1433 within double quotes, even when history expansion is enabled.
1434 The characters
1435 <B>$</B>
1436
1437 and
1438 <B>`</B>
1439
1440 retain their special meaning within double quotes. The backslash
1441 retains its special meaning only when followed by one of the following
1442 characters:
1443 <B>$</B>,
1444
1445 <B>`</B>,
1446
1447 <B>&quot;</B>,
1448 <B>\</B>,
1449
1450 or
1451 <B>&lt;newline&gt;</B>.
1452
1453 A double quote may be quoted within double quotes by preceding it with
1454 a backslash.
1455 If enabled, history expansion will be performed unless an
1456 <B>!</B>
1457
1458 appearing in double quotes is escaped using a backslash.
1459 The backslash preceding the
1460 <B>!</B>
1461
1462 is not removed.
1463 <P>
1464
1465 The special parameters
1466 <B>*</B>
1467
1468 and
1469 <B>@</B>
1470
1471 have special meaning when in double
1472 quotes (see
1473 <FONT SIZE=-1><B>PARAMETERS</B>
1474
1475 </FONT>
1476 below).
1477 <P>
1478
1479 Character sequences of the form <B>$</B>aq<I>string</I>aq are treated
1480 as a special variant of single quotes.
1481 The sequence expands to <I>string</I>, with backslash-escaped characters
1482 in <I>string</I> replaced as specified by the ANSI C standard.
1483 Backslash escape sequences, if present, are decoded as follows:
1484 <DL COMPACT><DT><DD>
1485
1486 <DL COMPACT>
1487 <DT><B>\a</B>
1488
1489 <DD>
1490 alert (bell)
1491 <DT><B>\b</B>
1492
1493 <DD>
1494 backspace
1495 <DT><B>\e</B>
1496
1497 <DD>
1498 <DT><B>\E</B>
1499
1500 <DD>
1501 an escape character
1502 <DT><B>\f</B>
1503
1504 <DD>
1505 form feed
1506 <DT><B>\n</B>
1507
1508 <DD>
1509 new line
1510 <DT><B>\r</B>
1511
1512 <DD>
1513 carriage return
1514 <DT><B>\t</B>
1515
1516 <DD>
1517 horizontal tab
1518 <DT><B>\v</B>
1519
1520 <DD>
1521 vertical tab
1522 <DT><B>\\</B>
1523
1524 <DD>
1525 backslash
1526 <DT><B>\aq</B>
1527
1528 <DD>
1529 single quote
1530 <DT><B>\dq</B>
1531
1532 <DD>
1533 double quote
1534 <DT><B>\?</B>
1535
1536 <DD>
1537 question mark
1538 <DT><B>\</B><I>nnn</I>
1539
1540 <DD>
1541 the eight-bit character whose value is the octal value <I>nnn</I>
1542 (one to three octal digits)
1543 <DT><B>\x</B><I>HH</I>
1544
1545 <DD>
1546 the eight-bit character whose value is the hexadecimal value <I>HH</I>
1547 (one or two hex digits)
1548 <DT><B>\u</B><I>HHHH</I>
1549
1550 <DD>
1551 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
1552 <I>HHHH</I> (one to four hex digits)
1553 <DT><B>\U</B><I>HHHHHHHH</I>
1554
1555 <DD>
1556 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
1557 <I>HHHHHHHH</I> (one to eight hex digits)
1558 <DT><B>\c</B><I>x</I>
1559
1560 <DD>
1561 a control-<I>x</I> character
1562
1563 </DL></DL>
1564
1565 <P>
1566
1567 The expanded result is single-quoted, as if the dollar sign had
1568 not been present.
1569 <P>
1570
1571 A double-quoted string preceded by a dollar sign (<B>$</B>dq<I>string</I>dq)
1572 will cause the string to be translated according to the current locale.
1573 The <I>gettext</I> infrastructure performs the lookup and
1574 translation, using the <B>LC_MESSAGES</B>, <B>TEXTDOMAINDIR</B>,
1575 and <B>TEXTDOMAIN</B> shell variables.
1576 If the current locale is <B>C</B> or <B>POSIX</B>,
1577 if there are no translations available,
1578 or if the string is not translated,
1579 the dollar sign is ignored.
1580 This is a form of double quoting, so the string remains double-quoted
1581 by default, whether or not it is translated and replaced.
1582 If the <B>noexpand_translation</B> option is enabled
1583 using the <B>shopt</B> builtin,
1584 translated strings are single-quoted instead of double-quoted.
1585 See the description of
1586 <B>shopt</B>
1587
1588 below under
1589 <FONT SIZE=-1><B>SHELL</B>BUILTIN<B>COMMANDS</B>.
1590
1591 </FONT>
1592 <A NAME="lbAT">&nbsp;</A>
1593 <H3>PARAMETERS</H3>
1594
1595 A
1596 <I>parameter</I>
1597
1598 is an entity that stores values.
1599 It can be a
1600 <I>name</I>,
1601
1602 a number, or one of the special characters listed below under
1603 <B>Special Parameters</B>.
1604
1605 A
1606 <I>variable</I>
1607
1608 is a parameter denoted by a
1609 <I>name</I>.
1610
1611 A variable has a <I>value</I> and zero or more <I>attributes</I>.
1612 Attributes are assigned using the
1613 <B>declare</B>
1614
1615 builtin command (see
1616 <B>declare</B>
1617
1618 below in
1619 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>).
1620
1621 </FONT>
1622 <P>
1623
1624 A parameter is set if it has been assigned a value. The null string is
1625 a valid value. Once a variable is set, it may be unset only by using
1626 the
1627 <B>unset</B>
1628
1629 builtin command (see
1630 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
1631
1632 </FONT>
1633 below).
1634 <P>
1635
1636 A
1637 <I>variable</I>
1638
1639 may be assigned to by a statement of the form
1640 <DL COMPACT><DT><DD>
1641 <P>
1642
1643 <I>name</I>=[<I>value</I>]
1644 </DL>
1645
1646 <P>
1647
1648 If
1649 <I>value</I>
1650
1651 is not given, the variable is assigned the null string. All
1652 <I>values</I>
1653
1654 undergo tilde expansion, parameter and variable expansion,
1655 command substitution, arithmetic expansion, and quote
1656 removal (see
1657 <FONT SIZE=-1><B>EXPANSION</B>
1658
1659 </FONT>
1660 below). If the variable has its
1661 <B>integer</B>
1662
1663 attribute set, then
1664 <I>value</I>
1665
1666 is evaluated as an arithmetic expression even if the $((...)) expansion is
1667 not used (see
1668 <B>Arithmetic Expansion</B>
1669
1670 below).
1671 Word splitting and pathname expansion are not performed.
1672 Assignment statements may also appear as arguments to the
1673 <B>alias</B>,
1674
1675 <B>declare</B>,
1676
1677 <B>typeset</B>,
1678
1679 <B>export</B>,
1680
1681 <B>readonly</B>,
1682
1683 and
1684 <B>local</B>
1685
1686 builtin commands (<I>declaration</I> commands).
1687 When in <I>posix mode</I>, these builtins may appear in a command after
1688 one or more instances of the <B>command</B> builtin and retain these
1689 assignment statement properties.
1690 <P>
1691
1692 In the context where an assignment statement is assigning a value
1693 to a shell variable or array index, the += operator can be used to
1694 append to or add to the variable's previous value.
1695 This includes arguments to builtin commands such as <B>declare</B> that
1696 accept assignment statements (<I>declaration</I> commands).
1697 When += is applied to a variable for which the <B>integer</B> attribute has been
1698 set, <I>value</I> is evaluated as an arithmetic expression and added to the
1699 variable's current value, which is also evaluated.
1700 When += is applied to an array variable using compound assignment (see
1701 <B>Arrays</B>
1702
1703 below), the
1704 variable's value is not unset (as it is when using =), and new values are
1705 appended to the array beginning at one greater than the array's maximum index
1706 (for indexed arrays) or added as additional key-value pairs in an
1707 associative array.
1708 When applied to a string-valued variable, <I>value</I> is expanded and
1709 appended to the variable's value.
1710 <P>
1711
1712 A variable can be assigned the <I>nameref</I> attribute using the
1713 <B>-n</B> option to the <B>declare</B> or <B>local</B> builtin commands
1714 (see the descriptions of <B>declare</B> and <B>local</B> below)
1715 to create a <I>nameref</I>, or a reference to another variable.
1716 This allows variables to be manipulated indirectly.
1717 Whenever the nameref variable is referenced, assigned to, unset, or has
1718 its attributes modified (other than using or changing the <I>nameref</I>
1719 attribute itself), the
1720 operation is actually performed on the variable specified by the nameref
1721 variable's value.
1722 A nameref is commonly used within shell functions to refer to a variable
1723 whose name is passed as an argument to the function.
1724 For instance, if a variable name is passed to a shell function as its first
1725 argument, running
1726 <P>
1727 <DL COMPACT><DT><DD>
1728 <TT>declare -n ref=$1</TT>
1729
1730 </DL>
1731
1732 <P>
1733 inside the function creates a nameref variable <B>ref</B> whose value is
1734 the variable name passed as the first argument.
1735 References and assignments to <B>ref</B>, and changes to its attributes,
1736 are treated as references, assignments, and attribute modifications
1737 to the variable whose name was passed as <B>$1</B>.
1738 If the control variable in a <B>for</B> loop has the nameref attribute,
1739 the list of words can be a list of shell variables, and a name reference
1740 will be established for each word in the list, in turn, when the loop is
1741 executed.
1742 Array variables cannot be given the <B>nameref</B> attribute.
1743 However, nameref variables can reference array variables and subscripted
1744 array variables.
1745 Namerefs can be unset using the <B>-n</B> option to the <B>unset</B> builtin.
1746 Otherwise, if <B>unset</B> is executed with the name of a nameref variable
1747 as an argument, the variable referenced by the nameref variable will be unset.
1748 <A NAME="lbAU">&nbsp;</A>
1749 <H4>Positional Parameters</H4>
1750
1751 A
1752 <I>positional parameter</I>
1753
1754 is a parameter denoted by one or more
1755 digits, other than the single digit 0. Positional parameters are
1756 assigned from the shell's arguments when it is invoked,
1757 and may be reassigned using the
1758 <B>set</B>
1759
1760 builtin command. Positional parameters may not be assigned to
1761 with assignment statements. The positional parameters are
1762 temporarily replaced when a shell function is executed (see
1763 <FONT SIZE=-1><B>FUNCTIONS</B>
1764
1765 </FONT>
1766 below).
1767 <P>
1768
1769 When a positional parameter consisting of more than a single
1770 digit is expanded, it must be enclosed in braces (see
1771 <FONT SIZE=-1><B>EXPANSION</B>
1772
1773 </FONT>
1774 below).
1775 <A NAME="lbAV">&nbsp;</A>
1776 <H4>Special Parameters</H4>
1777
1778 The shell treats several parameters specially. These parameters may
1779 only be referenced; assignment to them is not allowed.
1780
1781 <DL COMPACT>
1782 <DT><B>*</B>
1783
1784 <DD>
1785 Expands to the positional parameters, starting from one.
1786 When the expansion is not within double quotes, each positional parameter
1787 expands to a separate word.
1788 In contexts where it is performed, those words
1789 are subject to further word splitting and pathname expansion.
1790 When the expansion occurs within double quotes, it expands to a single word
1791 with the value of each parameter separated by the first character of the
1792 <FONT SIZE=-1><B>IFS</B>
1793
1794 </FONT>
1795 special variable. That is, &quot;<B>$*</B>&quot; is equivalent
1796 to &quot;<B>$1</B><I>c</I><B>$2</B><I>c</I><B>...</B>&quot;, where
1797 <I>c</I>
1798
1799 is the first character of the value of the
1800 <FONT SIZE=-1><B>IFS</B>
1801
1802 </FONT>
1803 variable. If
1804 <FONT SIZE=-1><B>IFS</B>
1805
1806 </FONT>
1807 is unset, the parameters are separated by spaces.
1808 If
1809 <FONT SIZE=-1><B>IFS</B>
1810
1811 </FONT>
1812 is null, the parameters are joined without intervening separators.
1813 <DT><B>@</B>
1814
1815 <DD>
1816 Expands to the positional parameters, starting from one.
1817 In contexts where word splitting is performed, this expands each
1818 positional parameter to a separate word; if not within double
1819 quotes, these words are subject to word splitting.
1820 In contexts where word splitting is not performed,
1821 this expands to a single word
1822 with each positional parameter separated by a space.
1823 When the
1824 expansion occurs within double quotes, each parameter expands to a
1825 separate word. That is, &quot;<B>$@</B>&quot; is equivalent to
1826 &quot;<B>$1</B>&quot; &quot;<B>$2</B>&quot; ...
1827 If the double-quoted expansion occurs within a word, the expansion of
1828 the first parameter is joined with the beginning part of the original
1829 word, and the expansion of the last parameter is joined with the last
1830 part of the original word.
1831 When there are no positional parameters, &quot;<B>$@</B>&quot; and
1832 <B>$@</B>
1833
1834 expand to nothing (i.e., they are removed).
1835 <DT><B>#</B>
1836
1837 <DD>
1838 Expands to the number of positional parameters in decimal.
1839 <DT><B>?</B>
1840
1841 <DD>
1842 Expands to the exit status of the most recently executed foreground
1843 pipeline.
1844 <DT><B>-</B>
1845
1846 <DD>
1847 Expands to the current option flags as specified upon invocation,
1848 by the
1849 <B>set</B>
1850
1851 builtin command, or those set by the shell itself
1852 (such as the
1853 <B>-i</B>
1854
1855 option).
1856 <DT><B>$</B>
1857
1858 <DD>
1859 Expands to the process ID of the shell. In a subshell, it
1860 expands to the process ID of the current shell, not the
1861 subshell.
1862 <DT><B>!</B>
1863
1864 <DD>
1865 Expands to the process ID of the job most recently placed into the
1866 background, whether executed as an asynchronous command or using
1867 the <B>bg</B> builtin (see
1868 <FONT SIZE=-1><B>JOB CONTROL</B>
1869
1870 </FONT>
1871 below).
1872 <DT><B>0</B>
1873
1874 <DD>
1875 Expands to the name of the shell or shell script. This is set at
1876 shell initialization. If
1877 <B>bash</B>
1878
1879 is invoked with a file of commands,
1880 <B>$0</B>
1881
1882 is set to the name of that file. If
1883 <B>bash</B>
1884
1885 is started with the
1886 <B>-c</B>
1887
1888 option, then
1889 <B>$0</B>
1890
1891 is set to the first argument after the string to be
1892 executed, if one is present. Otherwise, it is set
1893 to the filename used to invoke
1894 <B>bash</B>,
1895
1896 as given by argument zero.
1897
1898 </DL>
1899 <A NAME="lbAW">&nbsp;</A>
1900 <H4>Shell Variables</H4>
1901
1902 The following variables are set by the shell:
1903 <P>
1904
1905
1906 <DL COMPACT>
1907 <DT><B>_</B>
1908
1909 <DD>
1910 At shell startup, set to the pathname used to invoke the
1911 shell or shell script being executed as passed in the environment
1912 or argument list.
1913 Subsequently, expands to the last argument to the previous simple
1914 command executed in the foreground, after expansion.
1915 Also set to the full pathname used to invoke each command executed
1916 and placed in the environment exported to that command.
1917 When checking mail, this parameter holds the name of the mail file
1918 currently being checked.
1919 <DT><B>BASH</B>
1920
1921 <DD>
1922 Expands to the full filename used to invoke this instance of
1923 <B>bash</B>.
1924
1925 <DT><B>BASHOPTS</B>
1926
1927 <DD>
1928 A colon-separated list of enabled shell options. Each word in
1929 the list is a valid argument for the
1930 <B>-s</B>
1931
1932 option to the
1933 <B>shopt</B>
1934
1935 builtin command (see
1936 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
1937
1938 </FONT>
1939 below). The options appearing in
1940 <FONT SIZE=-1><B>BASHOPTS</B>
1941
1942 </FONT>
1943 are those reported as
1944 <I>on</I>
1945
1946 by <B>shopt</B>.
1947 If this variable is in the environment when
1948 <B>bash</B>
1949
1950 starts up, each shell option in the list will be enabled before
1951 reading any startup files.
1952 This variable is read-only.
1953 <DT><B>BASHPID</B>
1954
1955 <DD>
1956 Expands to the process ID of the current <B>bash</B> process.
1957 This differs from <B>$$</B> under certain circumstances, such as subshells
1958 that do not require <B>bash</B> to be re-initialized.
1959 Assignments to
1960 <FONT SIZE=-1><B>BASHPID</B>
1961
1962 </FONT>
1963 have no effect.
1964 If
1965 <B>BASHPID</B>
1966
1967 is unset, it loses its special properties, even if it is
1968 subsequently reset.
1969 <DT><B>BASH_ALIASES</B>
1970
1971 <DD>
1972 An associative array variable whose members correspond to the internal
1973 list of aliases as maintained by the <B>alias</B> builtin.
1974 Elements added to this array appear in the alias list; however,
1975 unsetting array elements currently does not cause aliases to be removed
1976 from the alias list.
1977 If
1978 <B>BASH_ALIASES</B>
1979
1980 is unset, it loses its special properties, even if it is
1981 subsequently reset.
1982 <DT><B>BASH_ARGC</B>
1983
1984 <DD>
1985 An array variable whose values are the number of parameters in each
1986 frame of the current <B>bash</B> execution call stack.
1987 The number of
1988 parameters to the current subroutine (shell function or script executed
1989 with <B>.</B> or <B>source</B>) is at the top of the stack.
1990 When a subroutine is executed, the number of parameters passed is pushed onto
1991 <FONT SIZE=-1><B>BASH_ARGC</B>.
1992
1993 </FONT>
1994 The shell sets
1995 <FONT SIZE=-1><B>BASH_ARGC</B>
1996
1997 </FONT>
1998 only when in extended debugging mode (see the description of the
1999 <B>extdebug</B>
2000
2001 option to the
2002 <B>shopt</B>
2003
2004 builtin below).
2005 Setting <B>extdebug</B> after the shell has started to execute a script,
2006 or referencing this variable when <B>extdebug</B> is not set,
2007 may result in inconsistent values.
2008 <DT><B>BASH_ARGV</B>
2009
2010 <DD>
2011 An array variable containing all of the parameters in the current <B>bash</B>
2012 execution call stack. The final parameter of the last subroutine call
2013 is at the top of the stack; the first parameter of the initial call is
2014 at the bottom. When a subroutine is executed, the parameters supplied
2015 are pushed onto
2016 <FONT SIZE=-1><B>BASH_ARGV</B>.
2017
2018 </FONT>
2019 The shell sets
2020 <FONT SIZE=-1><B>BASH_ARGV</B>
2021
2022 </FONT>
2023 only when in extended debugging mode
2024 (see the description of the
2025 <B>extdebug</B>
2026
2027 option to the
2028 <B>shopt</B>
2029
2030 builtin below).
2031 Setting <B>extdebug</B> after the shell has started to execute a script,
2032 or referencing this variable when <B>extdebug</B> is not set,
2033 may result in inconsistent values.
2034 <DT><B>BASH_ARGV0</B>
2035
2036 <DD>
2037 When referenced, this variable expands to the name of the shell or shell
2038 script (identical to
2039 <B>$0</B>;
2040
2041 see the description of special parameter 0 above).
2042 Assignment to
2043 <B>BASH_ARGV0</B>
2044
2045 causes the value assigned to also be assigned to <B>$0</B>.
2046 If
2047 <B>BASH_ARGV0</B>
2048
2049 is unset, it loses its special properties, even if it is
2050 subsequently reset.
2051 <DT><B>BASH_CMDS</B>
2052
2053 <DD>
2054 An associative array variable whose members correspond to the internal
2055 hash table of commands as maintained by the <B>hash</B> builtin.
2056 Elements added to this array appear in the hash table; however,
2057 unsetting array elements currently does not cause command names to be removed
2058 from the hash table.
2059 If
2060 <B>BASH_CMDS</B>
2061
2062 is unset, it loses its special properties, even if it is
2063 subsequently reset.
2064 <DT><B>BASH_COMMAND</B>
2065
2066 <DD>
2067 The command currently being executed or about to be executed, unless the
2068 shell is executing a command as the result of a trap,
2069 in which case it is the command executing at the time of the trap.
2070 If
2071 <B>BASH_COMMAND</B>
2072
2073 is unset, it loses its special properties, even if it is
2074 subsequently reset.
2075 <DT><B>BASH_EXECUTION_STRING</B>
2076
2077 <DD>
2078 The command argument to the <B>-c</B> invocation option.
2079 <DT><B>BASH_LINENO</B>
2080
2081 <DD>
2082 An array variable whose members are the line numbers in source files
2083 where each corresponding member of
2084 <FONT SIZE=-1><B>FUNCNAME</B>
2085
2086 </FONT>
2087 was invoked.
2088 <B>${BASH_LINENO[</B><I>$i</I><B>]}</B> is the line number in the source
2089 file (<B>${BASH_SOURCE[</B><I>$i+1</I><B>]}</B>) where
2090 <B>${FUNCNAME[</B><I>$i</I><B>]}</B> was called
2091 (or <B>${BASH_LINENO[</B><I>$i-1</I><B>]}</B> if referenced within another
2092 shell function).
2093 Use
2094 <FONT SIZE=-1><B>LINENO</B>
2095
2096 </FONT>
2097 to obtain the current line number.
2098 <DT><B>BASH_LOADABLES_PATH</B>
2099
2100 <DD>
2101 A colon-separated list of directories in which the shell looks for
2102 dynamically loadable builtins specified by the
2103 <B>enable</B>
2104
2105 command.
2106 <DT><B>BASH_REMATCH</B>
2107
2108 <DD>
2109 An array variable whose members are assigned by the <B>=~</B> binary
2110 operator to the <B>[[</B> conditional command.
2111 The element with index 0 is the portion of the string
2112 matching the entire regular expression.
2113 The element with index <I>n</I> is the portion of the
2114 string matching the <I>n</I>th parenthesized subexpression.
2115 <DT><B>BASH_SOURCE</B>
2116
2117 <DD>
2118 An array variable whose members are the source filenames
2119 where the corresponding shell function names in the
2120 <FONT SIZE=-1><B>FUNCNAME</B>
2121
2122 </FONT>
2123 array variable are defined.
2124 The shell function
2125 <B>${FUNCNAME[</B><I>$i</I><B>]}</B> is defined in the file
2126 <B>${BASH_SOURCE[</B><I>$i</I><B>]}</B> and called from
2127 <B>${BASH_SOURCE[</B><I>$i+1</I><B>]}</B>.
2128 <DT><B>BASH_SUBSHELL</B>
2129
2130 <DD>
2131 Incremented by one within each subshell or subshell environment when
2132 the shell begins executing in that environment.
2133 The initial value is 0.
2134 If
2135 <B>BASH_SUBSHELL</B>
2136
2137 is unset, it loses its special properties, even if it is
2138 subsequently reset.
2139 <DT><B>BASH_VERSINFO</B>
2140
2141 <DD>
2142 A readonly array variable whose members hold version information for
2143 this instance of
2144 <B>bash</B>.
2145
2146 The values assigned to the array members are as follows:
2147 <P>
2148 <DL COMPACT><DT><DD>
2149 <DL COMPACT>
2150 <DT><B>BASH_VERSINFO[</B>0]
2151
2152 <DD>
2153 The major version number (the <I>release</I>).
2154 <DT><B>BASH_VERSINFO[</B>1]
2155
2156 <DD>
2157 The minor version number (the <I>version</I>).
2158 <DT><B>BASH_VERSINFO[</B>2]
2159
2160 <DD>
2161 The patch level.
2162 <DT><B>BASH_VERSINFO[</B>3]
2163
2164 <DD>
2165 The build version.
2166 <DT><B>BASH_VERSINFO[</B>4]
2167
2168 <DD>
2169 The release status (e.g., <I>beta1</I>).
2170 <DT><B>BASH_VERSINFO[</B>5]
2171
2172 <DD>
2173 The value of
2174 <FONT SIZE=-1><B>MACHTYPE</B>.
2175
2176 </FONT>
2177 </DL></DL>
2178
2179 <DT><B>BASH_VERSION</B>
2180
2181 <DD>
2182 Expands to a string describing the version of this instance of
2183 <B>bash</B>.
2184
2185 <DT><B>COMP_CWORD</B>
2186
2187 <DD>
2188 An index into <B>${COMP_WORDS}</B> of the word containing the current
2189 cursor position.
2190 This variable is available only in shell functions invoked by the
2191 programmable completion facilities (see <B>Programmable Completion</B>
2192 below).
2193 <DT><B>COMP_KEY</B>
2194
2195 <DD>
2196 The key (or final key of a key sequence) used to invoke the current
2197 completion function.
2198 <DT><B>COMP_LINE</B>
2199
2200 <DD>
2201 The current command line.
2202 This variable is available only in shell functions and external
2203 commands invoked by the
2204 programmable completion facilities (see <B>Programmable Completion</B>
2205 below).
2206 <DT><B>COMP_POINT</B>
2207
2208 <DD>
2209 The index of the current cursor position relative to the beginning of
2210 the current command.
2211 If the current cursor position is at the end of the current command,
2212 the value of this variable is equal to <B>${#COMP_LINE}</B>.
2213 This variable is available only in shell functions and external
2214 commands invoked by the
2215 programmable completion facilities (see <B>Programmable Completion</B>
2216 below).
2217 <DT><B>COMP_TYPE</B>
2218
2219 <DD>
2220 Set to an integer value corresponding to the type of completion attempted
2221 that caused a completion function to be called:
2222 <I>TAB</I>, for normal completion,
2223 <I>?</I>, for listing completions after successive tabs,
2224 <I>!</I>, for listing alternatives on partial word completion,
2225 <I>@</I>, to list completions if the word is not unmodified,
2226 or
2227 <I>%</I>, for menu completion.
2228 This variable is available only in shell functions and external
2229 commands invoked by the
2230 programmable completion facilities (see <B>Programmable Completion</B>
2231 below).
2232 <DT><B>COMP_WORDBREAKS</B>
2233
2234 <DD>
2235 The set of characters that the <B>readline</B> library treats as word
2236 separators when performing word completion.
2237 If
2238 <FONT SIZE=-1><B>COMP_WORDBREAKS</B>
2239
2240 </FONT>
2241 is unset, it loses its special properties, even if it is
2242 subsequently reset.
2243 <DT><B>COMP_WORDS</B>
2244
2245 <DD>
2246 An array variable (see <B>Arrays</B> below) consisting of the individual
2247 words in the current command line.
2248 The line is split into words as <B>readline</B> would split it, using
2249 <FONT SIZE=-1><B>COMP_WORDBREAKS</B>
2250
2251 </FONT>
2252 as described above.
2253 This variable is available only in shell functions invoked by the
2254 programmable completion facilities (see <B>Programmable Completion</B>
2255 below).
2256 <DT><B>COPROC</B>
2257
2258 <DD>
2259 An array variable (see <B>Arrays</B> below) created to hold the file descriptors
2260 for output from and input to an unnamed coprocess (see <B>Coprocesses</B>
2261 above).
2262 <DT><B>DIRSTACK</B>
2263
2264 <DD>
2265 An array variable (see
2266 <B>Arrays</B>
2267
2268 below) containing the current contents of the directory stack.
2269 Directories appear in the stack in the order they are displayed by the
2270 <B>dirs</B>
2271
2272 builtin.
2273 Assigning to members of this array variable may be used to modify
2274 directories already in the stack, but the
2275 <B>pushd</B>
2276
2277 and
2278 <B>popd</B>
2279
2280 builtins must be used to add and remove directories.
2281 Assignment to this variable will not change the current directory.
2282 If
2283 <FONT SIZE=-1><B>DIRSTACK</B>
2284
2285 </FONT>
2286 is unset, it loses its special properties, even if it is
2287 subsequently reset.
2288 <DT><B>EPOCHREALTIME</B>
2289
2290 <DD>
2291 Each time this parameter is referenced, it expands to the number of seconds
2292 since the Unix Epoch (see <I>time</I>(3)) as a floating point value
2293 with micro-second granularity.
2294 Assignments to
2295 <FONT SIZE=-1><B>EPOCHREALTIME</B>
2296
2297 </FONT>
2298 are ignored.
2299 If
2300 <FONT SIZE=-1><B>EPOCHREALTIME</B>
2301
2302 </FONT>
2303 is unset, it loses its special properties, even if it is
2304 subsequently reset.
2305 <DT><B>EPOCHSECONDS</B>
2306
2307 <DD>
2308 Each time this parameter is referenced, it expands to the number of seconds
2309 since the Unix Epoch (see <I>time</I>(3)).
2310 Assignments to
2311 <FONT SIZE=-1><B>EPOCHSECONDS</B>
2312
2313 </FONT>
2314 are ignored.
2315 If
2316 <FONT SIZE=-1><B>EPOCHSECONDS</B>
2317
2318 </FONT>
2319 is unset, it loses its special properties, even if it is
2320 subsequently reset.
2321 <DT><B>EUID</B>
2322
2323 <DD>
2324 Expands to the effective user ID of the current user, initialized at
2325 shell startup. This variable is readonly.
2326 <DT><B>FUNCNAME</B>
2327
2328 <DD>
2329 An array variable containing the names of all shell functions
2330 currently in the execution call stack.
2331 The element with index 0 is the name of any currently-executing
2332 shell function.
2333 The bottom-most element (the one with the highest index) is
2334 <TT>&quot;main&quot;</TT>.
2335
2336 This variable exists only when a shell function is executing.
2337 Assignments to
2338 <FONT SIZE=-1><B>FUNCNAME</B>
2339
2340 </FONT>
2341 have no effect.
2342 If
2343 <FONT SIZE=-1><B>FUNCNAME</B>
2344
2345 </FONT>
2346 is unset, it loses its special properties, even if it is
2347 subsequently reset.
2348 <P>
2349
2350
2351 This variable can be used with <B>BASH_LINENO</B> and <B>BASH_SOURCE</B>.
2352 Each element of <B>FUNCNAME</B> has corresponding elements in
2353 <B>BASH_LINENO</B> and <B>BASH_SOURCE</B> to describe the call stack.
2354 For instance, <B>${FUNCNAME[</B><I>$i</I><B>]}</B> was called from the file
2355 <B>${BASH_SOURCE[</B><I>$i+1</I><B>]}</B> at line number
2356 <B>${BASH_LINENO[</B><I>$i</I><B>]}</B>.
2357 The <B>caller</B> builtin displays the current call stack using this
2358 information.
2359 <DT><B>GROUPS</B>
2360
2361 <DD>
2362 An array variable containing the list of groups of which the current
2363 user is a member.
2364 Assignments to
2365 <FONT SIZE=-1><B>GROUPS</B>
2366
2367 </FONT>
2368 have no effect.
2369 If
2370 <FONT SIZE=-1><B>GROUPS</B>
2371
2372 </FONT>
2373 is unset, it loses its special properties, even if it is
2374 subsequently reset.
2375 <DT><B>HISTCMD</B>
2376
2377 <DD>
2378 The history number, or index in the history list, of the current
2379 command.
2380 Assignments to
2381 <FONT SIZE=-1><B>HISTCMD</B>
2382
2383 </FONT>
2384 are ignored.
2385 If
2386 <FONT SIZE=-1><B>HISTCMD</B>
2387
2388 </FONT>
2389 is unset, it loses its special properties, even if it is
2390 subsequently reset.
2391 <DT><B>HOSTNAME</B>
2392
2393 <DD>
2394 Automatically set to the name of the current host.
2395 <DT><B>HOSTTYPE</B>
2396
2397 <DD>
2398 Automatically set to a string that uniquely
2399 describes the type of machine on which
2400 <B>bash</B>
2401
2402 is executing.
2403 The default is system-dependent.
2404 <DT><B>LINENO</B>
2405
2406 <DD>
2407 Each time this parameter is referenced, the shell substitutes
2408 a decimal number representing the current sequential line number
2409 (starting with 1) within a script or function. When not in a
2410 script or function, the value substituted is not guaranteed to
2411 be meaningful.
2412 If
2413 <FONT SIZE=-1><B>LINENO</B>
2414
2415 </FONT>
2416 is unset, it loses its special properties, even if it is
2417 subsequently reset.
2418 <DT><B>MACHTYPE</B>
2419
2420 <DD>
2421 Automatically set to a string that fully describes the system
2422 type on which
2423 <B>bash</B>
2424
2425 is executing, in the standard GNU <I>cpu-company-system</I> format.
2426 The default is system-dependent.
2427 <DT><B>MAPFILE</B>
2428
2429 <DD>
2430 An array variable (see <B>Arrays</B> below) created to hold the text
2431 read by the <B>mapfile</B> builtin when no variable name is supplied.
2432 <DT><B>OLDPWD</B>
2433
2434 <DD>
2435 The previous working directory as set by the
2436 <B>cd</B>
2437
2438 command.
2439 <DT><B>OPTARG</B>
2440
2441 <DD>
2442 The value of the last option argument processed by the
2443 <B>getopts</B>
2444
2445 builtin command (see
2446 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2447
2448 </FONT>
2449 below).
2450 <DT><B>OPTIND</B>
2451
2452 <DD>
2453 The index of the next argument to be processed by the
2454 <B>getopts</B>
2455
2456 builtin command (see
2457 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2458
2459 </FONT>
2460 below).
2461 <DT><B>OSTYPE</B>
2462
2463 <DD>
2464 Automatically set to a string that
2465 describes the operating system on which
2466 <B>bash</B>
2467
2468 is executing.
2469 The default is system-dependent.
2470 <DT><B>PIPESTATUS</B>
2471
2472 <DD>
2473 An array variable (see
2474 <B>Arrays</B>
2475
2476 below) containing a list of exit status values from the processes
2477 in the most-recently-executed foreground pipeline (which may
2478 contain only a single command).
2479 <DT><B>PPID</B>
2480
2481 <DD>
2482 The process ID of the shell's parent. This variable is readonly.
2483 <DT><B>PWD</B>
2484
2485 <DD>
2486 The current working directory as set by the
2487 <B>cd</B>
2488
2489 command.
2490 <DT><B>RANDOM</B>
2491
2492 <DD>
2493 Each time this parameter is referenced, it expands to a random integer
2494 between 0 and 32767.
2495 Assigning
2496 a value to
2497 <FONT SIZE=-1><B>RANDOM</B>
2498
2499 </FONT>
2500 initializes (seeds) the sequence of random numbers.
2501 If
2502 <FONT SIZE=-1><B>RANDOM</B>
2503
2504 </FONT>
2505 is unset, it loses its special properties, even if it is
2506 subsequently reset.
2507 <DT><B>READLINE_ARGUMENT</B>
2508
2509 <DD>
2510 Any numeric argument given to a readline command that was defined using
2511 <TT>bind -x</TT>
2512
2513 (see
2514 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2515
2516 </FONT>
2517 below)
2518 when it was invoked.
2519 <DT><B>READLINE_LINE</B>
2520
2521 <DD>
2522 The contents of the
2523 <B>readline</B>
2524
2525 line buffer, for use with
2526 <TT>bind -x</TT>
2527
2528 (see
2529 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2530
2531 </FONT>
2532 below).
2533 <DT><B>READLINE_MARK</B>
2534
2535 <DD>
2536 The position of the mark (saved insertion point) in the
2537 <B>readline</B>
2538
2539 line buffer, for use with
2540 <TT>bind -x</TT>
2541
2542 (see
2543 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2544
2545 </FONT>
2546 below).
2547 The characters between the insertion point and the mark are often
2548 called the <I>region</I>.
2549 <DT><B>READLINE_POINT</B>
2550
2551 <DD>
2552 The position of the insertion point in the
2553 <B>readline</B>
2554
2555 line buffer, for use with
2556 <TT>bind -x</TT>
2557
2558 (see
2559 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2560
2561 </FONT>
2562 below).
2563 <DT><B>REPLY</B>
2564
2565 <DD>
2566 Set to the line of input read by the
2567 <B>read</B>
2568
2569 builtin command when no arguments are supplied.
2570 <DT><B>SECONDS</B>
2571
2572 <DD>
2573 Each time this parameter is
2574 referenced, it expands to the number of seconds since shell invocation.
2575 If a value is assigned to
2576 <FONT SIZE=-1><B>SECONDS</B>,
2577
2578 </FONT>
2579 the value returned upon subsequent
2580 references is
2581 the number of seconds since the assignment plus the value assigned.
2582 The number of seconds at shell invocation and the current time are always
2583 determined by querying the system clock.
2584 If
2585 <FONT SIZE=-1><B>SECONDS</B>
2586
2587 </FONT>
2588 is unset, it loses its special properties, even if it is
2589 subsequently reset.
2590 <DT><B>SHELLOPTS</B>
2591
2592 <DD>
2593 A colon-separated list of enabled shell options. Each word in
2594 the list is a valid argument for the
2595 <B>-o</B>
2596
2597 option to the
2598 <B>set</B>
2599
2600 builtin command (see
2601 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2602
2603 </FONT>
2604 below). The options appearing in
2605 <FONT SIZE=-1><B>SHELLOPTS</B>
2606
2607 </FONT>
2608 are those reported as
2609 <I>on</I>
2610
2611 by <B>set -o</B>.
2612 If this variable is in the environment when
2613 <B>bash</B>
2614
2615 starts up, each shell option in the list will be enabled before
2616 reading any startup files.
2617 This variable is read-only.
2618 <DT><B>SHLVL</B>
2619
2620 <DD>
2621 Incremented by one each time an instance of
2622 <B>bash</B>
2623
2624 is started.
2625 <DT><B>SRANDOM</B>
2626
2627 <DD>
2628 This variable expands to a 32-bit pseudo-random number each time it is
2629 referenced. The random number generator is not linear on systems that
2630 support <TT>/dev/urandom</TT> or <I>arc4random</I>, so each returned number
2631 has no relationship to the numbers preceding it.
2632 The random number generator cannot be seeded, so assignments to this
2633 variable have no effect.
2634 If
2635 <FONT SIZE=-1><B>SRANDOM</B>
2636
2637 </FONT>
2638 is unset, it loses its special properties,
2639 even if it is subsequently reset.
2640 <DT><B>UID</B>
2641
2642 <DD>
2643 Expands to the user ID of the current user, initialized at shell startup.
2644 This variable is readonly.
2645
2646 </DL>
2647 <P>
2648
2649 The following variables are used by the shell. In some cases,
2650 <B>bash</B>
2651
2652 assigns a default value to a variable; these cases are noted
2653 below.
2654 <P>
2655
2656
2657 <DL COMPACT>
2658 <DT><B>BASH_COMPAT</B>
2659
2660 <DD>
2661 The value is used to set the shell's compatibility level.
2662 See
2663 <FONT SIZE=-1><B>SHELL COMPATIBILITY MODE</B>
2664
2665 </FONT>
2666 below for a description of the various compatibility
2667 levels and their effects.
2668 The value may be a decimal number (e.g., 4.2) or an integer (e.g., 42)
2669 corresponding to the desired compatibility level.
2670 If <B>BASH_COMPAT</B> is unset or set to the empty string, the compatibility
2671 level is set to the default for the current version.
2672 If <B>BASH_COMPAT</B> is set to a value that is not one of the valid
2673 compatibility levels, the shell prints an error message and sets the
2674 compatibility level to the default for the current version.
2675 The valid values correspond to the compatibility levels
2676 described below under
2677 <FONT SIZE=-1><B>SHELL COMPATIBILITY MODE</B>.
2678
2679 </FONT>
2680 For example, 4.2 and 42 are valid values that correspond
2681 to the <B>compat42</B> <B>shopt</B> option
2682 and set the compatibility level to 42.
2683 The current version is also a valid value.
2684 <DT><B>BASH_ENV</B>
2685
2686 <DD>
2687 If this parameter is set when <B>bash</B> is executing a shell script,
2688 its value is interpreted as a filename containing commands to
2689 initialize the shell, as in
2690 <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>.
2691
2692 The value of
2693 <FONT SIZE=-1><B>BASH_ENV</B>
2694
2695 </FONT>
2696 is subjected to parameter expansion, command substitution, and arithmetic
2697 expansion before being interpreted as a filename.
2698 <FONT SIZE=-1><B>PATH</B>
2699
2700 </FONT>
2701 is not used to search for the resultant filename.
2702 <DT><B>BASH_XTRACEFD</B>
2703
2704 <DD>
2705 If set to an integer corresponding to a valid file descriptor, <B>bash</B>
2706 will write the trace output generated when
2707 <TT>set -x</TT>
2708
2709 is enabled to that file descriptor.
2710 The file descriptor is closed when
2711 <FONT SIZE=-1><B>BASH_XTRACEFD</B>
2712
2713 </FONT>
2714 is unset or assigned a new value.
2715 Unsetting
2716 <FONT SIZE=-1><B>BASH_XTRACEFD</B>
2717
2718 </FONT>
2719 or assigning it the empty string causes the
2720 trace output to be sent to the standard error.
2721 Note that setting
2722 <FONT SIZE=-1><B>BASH_XTRACEFD</B>
2723
2724 </FONT>
2725 to 2 (the standard error file
2726 descriptor) and then unsetting it will result in the standard error
2727 being closed.
2728 <DT><B>CDPATH</B>
2729
2730 <DD>
2731 The search path for the
2732 <B>cd</B>
2733
2734 command.
2735 This is a colon-separated list of directories in which the shell looks
2736 for destination directories specified by the
2737 <B>cd</B>
2738
2739 command.
2740 A sample value is
2741 <TT>&quot;.:~:/usr&quot;</TT>.
2742
2743 <DT><B>CHILD_MAX</B>
2744
2745 <DD>
2746 Set the number of exited child status values for the shell to remember.
2747 Bash will not allow this value to be decreased below a POSIX-mandated
2748 minimum, and there is a maximum value (currently 8192) that this may
2749 not exceed.
2750 The minimum value is system-dependent.
2751 <DT><B>COLUMNS</B>
2752
2753 <DD>
2754 Used by the <B>select</B> compound command to determine the terminal width
2755 when printing selection lists.
2756 Automatically set if the
2757 <B>checkwinsize</B>
2758
2759 option is enabled or in an interactive shell upon receipt of a
2760 <FONT SIZE=-1><B>SIGWINCH</B>.
2761
2762 </FONT>
2763 <DT><B>COMPREPLY</B>
2764
2765 <DD>
2766 An array variable from which <B>bash</B> reads the possible completions
2767 generated by a shell function invoked by the programmable completion
2768 facility (see <B>Programmable Completion</B> below).
2769 Each array element contains one possible completion.
2770 <DT><B>EMACS</B>
2771
2772 <DD>
2773 If <B>bash</B> finds this variable in the environment when the shell starts
2774 with value
2775 <TT>t</TT>,
2776
2777 it assumes that the shell is running in an Emacs shell buffer and disables
2778 line editing.
2779 <DT><B>ENV</B>
2780
2781 <DD>
2782 Expanded and executed similarly to
2783 <FONT SIZE=-1><B>BASH_ENV</B>
2784
2785 </FONT>
2786 (see <B>INVOCATION</B> above)
2787 when an interactive shell is invoked in <I>posix mode</I>.
2788 <DT><B>EXECIGNORE</B>
2789
2790 <DD>
2791 A colon-separated list of shell patterns (see <B>Pattern Matching</B>)
2792 defining the list of filenames to be ignored by command search using
2793 <B>PATH</B>.
2794 Files whose full pathnames match one of these patterns are not considered
2795 executable files for the purposes of completion and command execution
2796 via <B>PATH</B> lookup.
2797 This does not affect the behavior of the <B>[</B>, <B>test</B>, and <B>[[</B>
2798 commands.
2799 Full pathnames in the command hash table are not subject to <B>EXECIGNORE</B>.
2800 Use this variable to ignore shared library files that have the executable
2801 bit set, but are not executable files.
2802 The pattern matching honors the setting of the <B>extglob</B> shell
2803 option.
2804 <DT><B>FCEDIT</B>
2805
2806 <DD>
2807 The default editor for the
2808 <B>fc</B>
2809
2810 builtin command.
2811 <DT><B>FIGNORE</B>
2812
2813 <DD>
2814 A colon-separated list of suffixes to ignore when performing
2815 filename completion (see
2816 <FONT SIZE=-1><B>READLINE</B>
2817
2818 </FONT>
2819 below).
2820 A filename whose suffix matches one of the entries in
2821 <FONT SIZE=-1><B>FIGNORE</B>
2822
2823 </FONT>
2824 is excluded from the list of matched filenames.
2825 A sample value is
2826 <TT>&quot;.o:~&quot;</TT>.
2827
2828 <DT><B>FUNCNEST</B>
2829
2830 <DD>
2831 If set to a numeric value greater than 0, defines a maximum function
2832 nesting level. Function invocations that exceed this nesting level
2833 will cause the current command to abort.
2834 <DT><B>GLOBIGNORE</B>
2835
2836 <DD>
2837 A colon-separated list of patterns defining the set of file names to
2838 be ignored by pathname expansion.
2839 If a file name matched by a pathname expansion pattern also matches one
2840 of the patterns in
2841 <FONT SIZE=-1><B>GLOBIGNORE</B>,
2842
2843 </FONT>
2844 it is removed from the list of matches.
2845 <DT><B>HISTCONTROL</B>
2846
2847 <DD>
2848 A colon-separated list of values controlling how commands are saved on
2849 the history list.
2850 If the list of values includes
2851 <I>ignorespace</I>,
2852
2853 lines which begin with a
2854 <B>space</B>
2855
2856 character are not saved in the history list.
2857 A value of
2858 <I>ignoredups</I>
2859
2860 causes lines matching the previous history entry to not be saved.
2861 A value of
2862 <I>ignoreboth</I>
2863
2864 is shorthand for <I>ignorespace</I> and <I>ignoredups</I>.
2865 A value of
2866 <I>erasedups</I>
2867
2868 causes all previous lines matching the current line to be removed from
2869 the history list before that line is saved.
2870 Any value not in the above list is ignored.
2871 If
2872 <FONT SIZE=-1><B>HISTCONTROL</B>
2873
2874 </FONT>
2875 is unset, or does not include a valid value,
2876 all lines read by the shell parser are saved on the history list,
2877 subject to the value of
2878 <FONT SIZE=-1><B>HISTIGNORE</B>.
2879
2880 </FONT>
2881 The second and subsequent lines of a multi-line compound command are
2882 not tested, and are added to the history regardless of the value of
2883 <FONT SIZE=-1><B>HISTCONTROL</B>.
2884
2885 </FONT>
2886 <DT><B>HISTFILE</B>
2887
2888 <DD>
2889 The name of the file in which command history is saved (see
2890 <FONT SIZE=-1><B>HISTORY</B>
2891
2892 </FONT>
2893 below). The default value is <A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>. If unset, the
2894 command history is not saved when a shell exits.
2895 <DT><B>HISTFILESIZE</B>
2896
2897 <DD>
2898 The maximum number of lines contained in the history file. When this
2899 variable is assigned a value, the history file is truncated, if
2900 necessary,
2901 to contain no more than that number of lines by removing the oldest entries.
2902 The history file is also truncated to this size after
2903 writing it when a shell exits.
2904 If the value is 0, the history file is truncated to zero size.
2905 Non-numeric values and numeric values less than zero inhibit truncation.
2906 The shell sets the default value to the value of <B>HISTSIZE</B>
2907 after reading any startup files.
2908 <DT><B>HISTIGNORE</B>
2909
2910 <DD>
2911 A colon-separated list of patterns used to decide which command lines
2912 should be saved on the history list. Each pattern is anchored at the
2913 beginning of the line and must match the complete line (no implicit
2914 `<B>*</B>' is appended). Each pattern is tested against the line
2915 after the checks specified by
2916 <FONT SIZE=-1><B>HISTCONTROL</B>
2917
2918 </FONT>
2919 are applied.
2920 In addition to the normal shell pattern matching characters, `<B>&amp;</B>'
2921 matches the previous history line. `<B>&amp;</B>' may be escaped using a
2922 backslash; the backslash is removed before attempting a match.
2923 The second and subsequent lines of a multi-line compound command are
2924 not tested, and are added to the history regardless of the value of
2925 <FONT SIZE=-1><B>HISTIGNORE</B>.
2926
2927 </FONT>
2928 The pattern matching honors the setting of the <B>extglob</B> shell
2929 option.
2930 <DT><B>HISTSIZE</B>
2931
2932 <DD>
2933 The number of commands to remember in the command history (see
2934 <FONT SIZE=-1><B>HISTORY</B>
2935
2936 </FONT>
2937 below).
2938 If the value is 0, commands are not saved in the history list.
2939 Numeric values less than zero result in every command being saved
2940 on the history list (there is no limit).
2941 The shell sets the default value to 500 after reading any startup files.
2942 <DT><B>HISTTIMEFORMAT</B>
2943
2944 <DD>
2945 If this variable is set and not null, its value is used as a format string
2946 for <I>strftime</I>(3) to print the time stamp associated with each history
2947 entry displayed by the <B>history</B> builtin.
2948 If this variable is set, time stamps are written to the history file so
2949 they may be preserved across shell sessions.
2950 This uses the history comment character to distinguish timestamps from
2951 other history lines.
2952 <DT><B>HOME</B>
2953
2954 <DD>
2955 The home directory of the current user; the default argument for the
2956 <B>cd</B> builtin command.
2957 The value of this variable is also used when performing tilde expansion.
2958 <DT><B>HOSTFILE</B>
2959
2960 <DD>
2961 Contains the name of a file in the same format as
2962
2963 <I>/etc/hosts</I>
2964
2965 that should be read when the shell needs to complete a
2966 hostname.
2967 The list of possible hostname completions may be changed while the
2968 shell is running;
2969 the next time hostname completion is attempted after the
2970 value is changed,
2971 <B>bash</B>
2972
2973 adds the contents of the new file to the existing list.
2974 If
2975 <FONT SIZE=-1><B>HOSTFILE</B>
2976
2977 </FONT>
2978 is set, but has no value, or does not name a readable file,
2979 <B>bash</B> attempts to read
2980
2981 <I>/etc/hosts</I>
2982
2983 to obtain the list of possible hostname completions.
2984 When
2985 <FONT SIZE=-1><B>HOSTFILE</B>
2986
2987 </FONT>
2988 is unset, the hostname list is cleared.
2989 <DT><B>IFS</B>
2990
2991 <DD>
2992 The
2993 <I>Internal Field Separator</I>
2994
2995 that is used
2996 for word splitting after expansion and to
2997 split lines into words with the
2998 <B>read</B>
2999
3000 builtin command. The default value is
3001 ``&lt;space&gt;&lt;tab&gt;&lt;newline&gt;''.
3002 <DT><B>IGNOREEOF</B>
3003
3004 <DD>
3005 Controls the
3006 action of an interactive shell on receipt of an
3007 <FONT SIZE=-1><B>EOF</B>
3008
3009 </FONT>
3010 character as the sole input. If set, the value is the number of
3011 consecutive
3012 <FONT SIZE=-1><B>EOF</B>
3013
3014 </FONT>
3015 characters which must be
3016 typed as the first characters on an input line before
3017 <B>bash</B>
3018
3019 exits. If the variable exists but does not have a numeric value, or
3020 has no value, the default value is 10. If it does not exist,
3021 <FONT SIZE=-1><B>EOF</B>
3022
3023 </FONT>
3024 signifies the end of input to the shell.
3025 <DT><B>INPUTRC</B>
3026
3027 <DD>
3028 The filename for the
3029 <B>readline</B>
3030
3031 startup file, overriding the default of
3032
3033 <A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>
3034
3035 (see
3036 <FONT SIZE=-1><B>READLINE</B>
3037
3038 </FONT>
3039 below).
3040 <DT><B>INSIDE_EMACS</B>
3041
3042 <DD>
3043 If this variable appears in the environment when the shell starts,
3044 <B>bash</B> assumes that it is running inside an Emacs shell buffer
3045 and may disable line editing, depending on the value of <B>TERM</B>.
3046 <DT><B>LANG</B>
3047
3048 <DD>
3049 Used to determine the locale category for any category not specifically
3050 selected with a variable starting with <B>LC_</B>.
3051 <DT><B>LC_ALL</B>
3052
3053 <DD>
3054 This variable overrides the value of
3055 <FONT SIZE=-1><B>LANG</B>
3056
3057 </FONT>
3058 and any other
3059 <B>LC_</B> variable specifying a locale category.
3060 <DT><B>LC_COLLATE</B>
3061
3062 <DD>
3063 This variable determines the collation order used when sorting the
3064 results of pathname expansion, and determines the behavior of range
3065 expressions, equivalence classes, and collating sequences within
3066 pathname expansion and pattern matching.
3067 <DT><B>LC_CTYPE</B>
3068
3069 <DD>
3070 This variable determines the interpretation of characters and the
3071 behavior of character classes within pathname expansion and pattern
3072 matching.
3073 <DT><B>LC_MESSAGES</B>
3074
3075 <DD>
3076 This variable determines the locale used to translate double-quoted
3077 strings preceded by a <B>$</B>.
3078 <DT><B>LC_NUMERIC</B>
3079
3080 <DD>
3081 This variable determines the locale category used for number formatting.
3082 <DT><B>LC_TIME</B>
3083
3084 <DD>
3085 This variable determines the locale category used for data and time
3086 formatting.
3087 <DT><B>LINES</B>
3088
3089 <DD>
3090 Used by the <B>select</B> compound command to determine the column length
3091 for printing selection lists.
3092 Automatically set if the
3093 <B>checkwinsize</B>
3094
3095 option is enabled or in an interactive shell upon receipt of a
3096 <FONT SIZE=-1><B>SIGWINCH</B>.
3097
3098 </FONT>
3099 <DT><B>MAIL</B>
3100
3101 <DD>
3102 If this parameter is set to a file or directory name and the
3103 <FONT SIZE=-1><B>MAILPATH</B>
3104
3105 </FONT>
3106 variable is not set,
3107 <B>bash</B>
3108
3109 informs the user of the arrival of mail in the specified file or
3110 Maildir-format directory.
3111 <DT><B>MAILCHECK</B>
3112
3113 <DD>
3114 Specifies how
3115 often (in seconds)
3116 <B>bash</B>
3117
3118 checks for mail. The default is 60 seconds. When it is time to check
3119 for mail, the shell does so before displaying the primary prompt.
3120 If this variable is unset, or set to a value that is not a number
3121 greater than or equal to zero, the shell disables mail checking.
3122 <DT><B>MAILPATH</B>
3123
3124 <DD>
3125 A colon-separated list of filenames to be checked for mail.
3126 The message to be printed when mail arrives in a particular file
3127 may be specified by separating the filename from the message with a `?'.
3128 When used in the text of the message, <B>$_</B> expands to the name of
3129 the current mailfile.
3130 Example:
3131 <DL COMPACT><DT><DD>
3132 <P>
3133
3134 <B>MAILPATH</B>=aq/var/mail/bfox?&quot;You have mail&quot;:~/shell-mail?&quot;$_ has mail!&quot;aq
3135 <P>
3136
3137 <B>Bash</B>
3138
3139 can be configured to supply
3140 a default value for this variable (there is no value by default),
3141 but the location of the user
3142 mail files that it uses is system dependent (e.g., /var/mail/<B>$USER</B>).
3143 </DL>
3144
3145 <DT><B>OPTERR</B>
3146
3147 <DD>
3148 If set to the value 1,
3149 <B>bash</B>
3150
3151 displays error messages generated by the
3152 <B>getopts</B>
3153
3154 builtin command (see
3155 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
3156
3157 </FONT>
3158 below).
3159 <FONT SIZE=-1><B>OPTERR</B>
3160
3161 </FONT>
3162 is initialized to 1 each time the shell is invoked or a shell
3163 script is executed.
3164 <DT><B>PATH</B>
3165
3166 <DD>
3167 The search path for commands. It
3168 is a colon-separated list of directories in which
3169 the shell looks for commands (see
3170 <FONT SIZE=-1><B>COMMAND EXECUTION</B>
3171
3172 </FONT>
3173 below).
3174 A zero-length (null) directory name in the value of
3175 <FONT SIZE=-1><B>PATH</B>
3176
3177 </FONT>
3178 indicates the current directory.
3179 A null directory name may appear as two adjacent colons, or as an initial
3180 or trailing colon.
3181 The default path is system-dependent,
3182 and is set by the administrator who installs
3183 <B>bash</B>.
3184
3185 A common value is
3186
3187 <TT>/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin</TT>.
3188
3189
3190 <DT><B>POSIXLY_CORRECT</B>
3191
3192 <DD>
3193 If this variable is in the environment when <B>bash</B> starts, the shell
3194 enters <I>posix mode</I> before reading the startup files, as if the
3195 <B>--posix</B>
3196
3197 invocation option had been supplied. If it is set while the shell is
3198 running, <B>bash</B> enables <I>posix mode</I>, as if the command
3199 <TT>set -o posix</TT>
3200
3201 had been executed.
3202 When the shell enters <I>posix mode</I>, it sets this variable if it was
3203 not already set.
3204 <DT><B>PROMPT_COMMAND</B>
3205
3206 <DD>
3207 If this variable is set, and is an array,
3208 the value of each set element is executed as a command
3209 prior to issuing each primary prompt.
3210 If this is set but not an array variable,
3211 its value is used as a command to execute instead.
3212 <DT><B>PROMPT_DIRTRIM</B>
3213
3214 <DD>
3215 If set to a number greater than zero, the value is used as the number of
3216 trailing directory components to retain when expanding the <B>\w</B> and
3217 <B>\W</B> prompt string escapes (see
3218 <FONT SIZE=-1><B>PROMPTING</B>
3219
3220 </FONT>
3221 below). Characters removed are replaced with an ellipsis.
3222 <DT><B>PS0</B>
3223
3224 <DD>
3225 The value of this parameter is expanded (see
3226 <FONT SIZE=-1><B>PROMPTING</B>
3227
3228 </FONT>
3229 below) and displayed by interactive shells after reading a command
3230 and before the command is executed.
3231 <DT><B>PS1</B>
3232
3233 <DD>
3234 The value of this parameter is expanded (see
3235 <FONT SIZE=-1><B>PROMPTING</B>
3236
3237 </FONT>
3238 below) and used as the primary prompt string. The default value is
3239 ``<B>\s-\v\$ </B>''.
3240 <DT><B>PS2</B>
3241
3242 <DD>
3243 The value of this parameter is expanded as with
3244 <FONT SIZE=-1><B>PS1</B>
3245
3246 </FONT>
3247 and used as the secondary prompt string. The default is
3248 ``<B>&gt; </B>''.
3249 <DT><B>PS3</B>
3250
3251 <DD>
3252 The value of this parameter is used as the prompt for the
3253 <B>select</B>
3254
3255 command (see
3256 <FONT SIZE=-1><B>SHELL GRAMMAR</B>
3257
3258 </FONT>
3259 above).
3260 <DT><B>PS4</B>
3261
3262 <DD>
3263 The value of this parameter is expanded as with
3264 <FONT SIZE=-1><B>PS1</B>
3265
3266 </FONT>
3267 and the value is printed before each command
3268 <B>bash</B>
3269
3270 displays during an execution trace. The first character of
3271 the expanded value of
3272 <FONT SIZE=-1><B>PS4</B>
3273
3274 </FONT>
3275 is replicated multiple times, as necessary, to indicate multiple
3276 levels of indirection. The default is ``<B>+ </B>''.
3277 <DT><B>SHELL</B>
3278
3279 <DD>
3280 This variable expands to the full pathname to the shell.
3281 If it is not set when the shell starts,
3282 <B>bash</B>
3283
3284 assigns to it the full pathname of the current user's login shell.
3285 <DT><B>TIMEFORMAT</B>
3286
3287 <DD>
3288 The value of this parameter is used as a format string specifying
3289 how the timing information for pipelines prefixed with the
3290 <B>time</B>
3291
3292 reserved word should be displayed.
3293 The <B>%</B> character introduces an escape sequence that is
3294 expanded to a time value or other information.
3295 The escape sequences and their meanings are as follows; the
3296 braces denote optional portions.
3297 <P>
3298 <DL COMPACT><DT><DD>
3299
3300 <DL COMPACT>
3301 <DT><B>%%</B>
3302
3303 <DD>
3304 A literal <B>%</B>.
3305 <DT><B>%[</B><I>p</I>][l]R
3306
3307 <DD>
3308 The elapsed time in seconds.
3309 <DT><B>%[</B><I>p</I>][l]U
3310
3311 <DD>
3312 The number of CPU seconds spent in user mode.
3313 <DT><B>%[</B><I>p</I>][l]S
3314
3315 <DD>
3316 The number of CPU seconds spent in system mode.
3317 <DT><B>%P</B>
3318
3319 <DD>
3320 The CPU percentage, computed as (%U + %S) / %R.
3321
3322 </DL></DL>
3323
3324 <DT><DD>
3325 The optional <I>p</I> is a digit specifying the <I>precision</I>,
3326 the number of fractional digits after a decimal point.
3327 A value of 0 causes no decimal point or fraction to be output.
3328 At most three places after the decimal point may be specified;
3329 values of <I>p</I> greater than 3 are changed to 3.
3330 If <I>p</I> is not specified, the value 3 is used.
3331 <DT><DD>
3332 The optional <B>l</B> specifies a longer format, including
3333 minutes, of the form <I>MM</I>m<I>SS</I>.<I>FF</I>s.
3334 The value of <I>p</I> determines whether or not the fraction is
3335 included.
3336 <DT><DD>
3337 If this variable is not set, <B>bash</B> acts as if it had the
3338 value <B>$aq\nreal\t%3lR\nuser\t%3lU\nsys\t%3lSaq</B>.
3339 If the value is null, no timing information is displayed.
3340 A trailing newline is added when the format string is displayed.
3341
3342 <DT><B>TMOUT</B>
3343
3344 <DD>
3345 If set to a value greater than zero,
3346 <FONT SIZE=-1><B>TMOUT</B>
3347
3348 </FONT>
3349 is treated as the
3350 default timeout for the <B>read</B> builtin.
3351 The <B>select</B> command terminates if input does not arrive
3352 after
3353 <FONT SIZE=-1><B>TMOUT</B>
3354
3355 </FONT>
3356 seconds when input is coming from a terminal.
3357 In an interactive shell, the value is interpreted as the
3358 number of seconds to wait for a line of input after issuing the
3359 primary prompt.
3360 <B>Bash</B>
3361
3362 terminates after waiting for that number of seconds if a complete
3363 line of input does not arrive.
3364 <DT><B>TMPDIR</B>
3365
3366 <DD>
3367 If set, <B>bash</B> uses its value as the name of a directory in which
3368 <B>bash</B> creates temporary files for the shell's use.
3369 <DT><B>auto_resume</B>
3370
3371 <DD>
3372 This variable controls how the shell interacts with the user and
3373 job control. If this variable is set, single word simple
3374 commands without redirections are treated as candidates for resumption
3375 of an existing stopped job. There is no ambiguity allowed; if there is
3376 more than one job beginning with the string typed, the job most recently
3377 accessed is selected. The
3378 <I>name</I>
3379
3380 of a stopped job, in this context, is the command line used to
3381 start it.
3382 If set to the value
3383 <I>exact</I>,
3384
3385 the string supplied must match the name of a stopped job exactly;
3386 if set to
3387 <I>substring</I>,
3388
3389 the string supplied needs to match a substring of the name of a
3390 stopped job. The
3391 <I>substring</I>
3392
3393 value provides functionality analogous to the
3394 <B>%?</B>
3395
3396 job identifier (see
3397 <FONT SIZE=-1><B>JOB CONTROL</B>
3398
3399 </FONT>
3400 below). If set to any other value, the supplied string must
3401 be a prefix of a stopped job's name; this provides functionality
3402 analogous to the <B>%</B><I>string</I> job identifier.
3403 <DT><B>histchars</B>
3404
3405 <DD>
3406 The two or three characters which control history expansion
3407 and tokenization (see
3408 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
3409
3410 </FONT>
3411 below). The first character is the <I>history expansion</I> character,
3412 the character which signals the start of a history
3413 expansion, normally `<B>!</B>'.
3414 The second character is the <I>quick substitution</I>
3415 character, which is used as shorthand for re-running the previous
3416 command entered, substituting one string for another in the command.
3417 The default is `<B>^</B>'.
3418 The optional third character is the character
3419 which indicates that the remainder of the line is a comment when found
3420 as the first character of a word, normally `<B>#</B>'. The history
3421 comment character causes history substitution to be skipped for the
3422 remaining words on the line. It does not necessarily cause the shell
3423 parser to treat the rest of the line as a comment.
3424
3425 </DL>
3426 <A NAME="lbAX">&nbsp;</A>
3427 <H4>Arrays</H4>
3428
3429 <B>Bash</B>
3430
3431 provides one-dimensional indexed and associative array variables.
3432 Any variable may be used as an indexed array; the
3433 <B>declare</B>
3434
3435 builtin will explicitly declare an array.
3436 There is no maximum
3437 limit on the size of an array, nor any requirement that members
3438 be indexed or assigned contiguously.
3439 Indexed arrays are referenced using integers (including arithmetic
3440 expressions) and are zero-based; associative arrays are referenced
3441 using arbitrary strings.
3442 Unless otherwise noted, indexed array indices must be non-negative integers.
3443 <P>
3444
3445 An indexed array is created automatically if any variable is assigned to
3446 using the syntax <I>name</I>[<I>subscript</I>]=<I>value</I>. The
3447 <I>subscript</I>
3448
3449 is treated as an arithmetic expression that must evaluate to a number.
3450 To explicitly declare an indexed array, use
3451 <B>declare -a </B><I>name</I>
3452
3453 (see
3454 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
3455
3456 </FONT>
3457 below).
3458 <B>declare -a </B><I>name</I>[<I>subscript</I>]
3459
3460 is also accepted; the <I>subscript</I> is ignored.
3461 <P>
3462
3463 Associative arrays are created using
3464 <B>declare -A </B><I>name</I>.
3465
3466 <P>
3467
3468 Attributes may be
3469 specified for an array variable using the
3470 <B>declare</B>
3471
3472 and
3473 <B>readonly</B>
3474
3475 builtins. Each attribute applies to all members of an array.
3476 <P>
3477
3478 Arrays are assigned to using compound assignments of the form
3479 <I>name</I>=<B>(</B>value<I>1</I> ... value<I>n</I><B>)</B>, where each
3480 <I>value</I> may be of the form [<I>subscript</I>]=<I>string</I>.
3481 Indexed array assignments do not require anything but <I>string</I>.
3482 Each <I>value</I> in the list is expanded using all the shell expansions
3483 described below under
3484 <FONT SIZE=-1><B>EXPANSION</B>.
3485
3486 </FONT>
3487 When assigning to indexed arrays, if the optional brackets and subscript
3488 are supplied, that index is assigned to;
3489 otherwise the index of the element assigned is the last index assigned
3490 to by the statement plus one. Indexing starts at zero.
3491 <P>
3492
3493 When assigning to an associative array, the words in a compound assignment
3494 may be either assignment statements, for which the subscript is required,
3495 or a list of words that is interpreted as a sequence of alternating keys
3496 and values:
3497 <I>name</I>=<B>( </B><I>key1 value1 key2 value2</I> ...<B>)</B>.
3498 These are treated identically to
3499 <I>name</I>=<B>(</B> [<I>key1</I>]=<I>value1</I> [<I>key2</I>]=<I>value2</I> ...<B>)</B>.
3500 The first word in the list determines how the remaining words
3501 are interpreted; all assignments in a list must be of the same type.
3502 When using key/value pairs, the keys may not be missing or empty;
3503 a final missing value is treated like the empty string.
3504 <P>
3505
3506 This syntax is also accepted by the
3507 <B>declare</B>
3508
3509 builtin. Individual array elements may be assigned to using the
3510 <I>name</I>[<I>subscript</I>]=<I>value</I> syntax introduced above.
3511 When assigning to an indexed array, if
3512 <I>name</I>
3513
3514 is subscripted by a negative number, that number is
3515 interpreted as relative to one greater than the maximum index of
3516 <I>name</I>, so negative indices count back from the end of the
3517 array, and an index of -1 references the last element.
3518 <P>
3519
3520 The += operator will append to an array variable when assigning
3521 using the compound assignment syntax; see
3522 <FONT SIZE=-1><B>PARAMETERS</B>
3523
3524 </FONT>
3525 above.
3526 <P>
3527
3528 Any element of an array may be referenced using
3529 ${<I>name</I>[<I>subscript</I>]}. The braces are required to avoid
3530 conflicts with pathname expansion. If
3531 <I>subscript</I> is <B>@</B> or <B>*</B>, the word expands to
3532 all members of <I>name</I>. These subscripts differ only when the
3533 word appears within double quotes. If the word is double-quoted,
3534 ${<I>name</I>[*]} expands to a single
3535 word with the value of each array member separated by the first
3536 character of the
3537 <FONT SIZE=-1><B>IFS</B>
3538
3539 </FONT>
3540 special variable, and ${<I>name</I>[@]} expands each element of
3541 <I>name</I> to a separate word. When there are no array members,
3542 ${<I>name</I>[@]} expands to nothing.
3543 If the double-quoted expansion occurs within a word, the expansion of
3544 the first parameter is joined with the beginning part of the original
3545 word, and the expansion of the last parameter is joined with the last
3546 part of the original word.
3547 This is analogous to the expansion
3548 of the special parameters <B>*</B> and <B>@</B> (see
3549 <B>Special Parameters</B>
3550
3551 above). ${#<I>name</I>[<I>subscript</I>]} expands to the length of
3552 ${<I>name</I>[<I>subscript</I>]}. If <I>subscript</I> is <B>*</B> or
3553 <B>@</B>, the expansion is the number of elements in the array.
3554 If the
3555 <I>subscript</I>
3556
3557 used to reference an element of an indexed array
3558 evaluates to a number less than zero, it is
3559 interpreted as relative to one greater than the maximum index of the array,
3560 so negative indices count back from the end of the
3561 array, and an index of -1 references the last element.
3562 <P>
3563
3564 Referencing an array variable without a subscript is equivalent to
3565 referencing the array with a subscript of 0.
3566 Any reference to a variable using a valid subscript is legal, and
3567 <B>bash</B>
3568
3569 will create an array if necessary.
3570 <P>
3571
3572 An array variable is considered set if a subscript has been assigned a
3573 value. The null string is a valid value.
3574 <P>
3575
3576 It is possible to obtain the keys (indices) of an array as well as the values.
3577 ${<B>!</B><I>name</I>[<I>@</I>]} and ${<B>!</B><I>name</I>[<I>*</I>]}
3578 expand to the indices assigned in array variable <I>name</I>.
3579 The treatment when in double quotes is similar to the expansion of the
3580 special parameters <I>@</I> and <I>*</I> within double quotes.
3581 <P>
3582
3583 The
3584 <B>unset</B>
3585
3586 builtin is used to destroy arrays. <B>unset</B> <I>name</I>[<I>subscript</I>]
3587 destroys the array element at index <I>subscript</I>,
3588 for both indexed and associative arrays.
3589 Negative subscripts to indexed arrays are interpreted as described above.
3590 Unsetting the last element of an array variable does not unset the variable.
3591 <B>unset</B> <I>name</I>, where <I>name</I> is an array,
3592 removes the entire array.
3593 <B>unset</B> <I>name</I>[<I>subscript</I>], where
3594 <I>subscript</I> is <B>*</B> or <B>@</B>, behaves differently depending on
3595 whether <I>name</I> is an indexed or associative array.
3596 If <I>name</I> is an associative array, this unsets the element with
3597 subscript <B>*</B> or <B>@</B>.
3598 If <I>name</I> is an indexed array, unset removes all of the elements but
3599 does not remove the array itself.
3600 <P>
3601
3602 When using a variable name with a subscript as an argument to a command,
3603 such as with <B>unset</B>, without using the word expansion syntax
3604 described above, the argument is subject to pathname expansion.
3605 If pathname expansion is not desired, the argument should be quoted.
3606 <P>
3607
3608 The
3609 <B>declare</B>,
3610
3611 <B>local</B>,
3612
3613 and
3614 <B>readonly</B>
3615
3616 builtins each accept a
3617 <B>-a</B>
3618
3619 option to specify an indexed array and a
3620 <B>-A</B>
3621
3622 option to specify an associative array.
3623 If both options are supplied,
3624 <B>-A</B>
3625
3626 takes precedence.
3627 The
3628 <B>read</B>
3629
3630 builtin accepts a
3631 <B>-a</B>
3632
3633 option to assign a list of words read from the standard input
3634 to an array. The
3635 <B>set</B>
3636
3637 and
3638 <B>declare</B>
3639
3640 builtins display array values in a way that allows them to be
3641 reused as assignments.
3642 <A NAME="lbAY">&nbsp;</A>
3643 <H3>EXPANSION</H3>
3644
3645 Expansion is performed on the command line after it has been split into
3646 words. There are seven kinds of expansion performed:
3647 <I>brace expansion</I>,
3648
3649 <I>tilde expansion</I>,
3650
3651 <I>parameter and variable expansion</I>,
3652
3653 <I>command substitution</I>,
3654
3655 <I>arithmetic expansion</I>,
3656
3657 <I>word splitting</I>,
3658
3659 and
3660 <I>pathname expansion</I>.
3661
3662 <P>
3663
3664 The order of expansions is:
3665 brace expansion;
3666 tilde expansion, parameter and variable expansion, arithmetic expansion,
3667 and command substitution (done in a left-to-right fashion);
3668 word splitting;
3669 and pathname expansion.
3670 <P>
3671
3672 On systems that can support it, there is an additional expansion
3673 available: <I>process substitution</I>.
3674 This is performed at the
3675 same time as tilde, parameter, variable, and arithmetic expansion and
3676 command substitution.
3677 <P>
3678
3679 After these expansions are performed, quote characters present in the
3680 original word are removed unless they have been quoted themselves
3681 (<I>quote removal</I>).
3682 <P>
3683
3684 Only brace expansion, word splitting, and pathname expansion
3685 can increase the number of words of the expansion; other expansions
3686 expand a single word to a single word.
3687 The only exceptions to this are the expansions of
3688 &quot;<B>$@</B>&quot; and &quot;<B>${</B><I>name</I><B>[@]}</B>&quot;,
3689 and, in most cases, <B>$*</B> and <B>${</B><I>name</I><B>[*]}</B>
3690 as explained above (see
3691 <FONT SIZE=-1><B>PARAMETERS</B>).
3692
3693 </FONT>
3694 <A NAME="lbAZ">&nbsp;</A>
3695 <H4>Brace Expansion</H4>
3696
3697 <I>Brace expansion</I>
3698
3699 is a mechanism by which arbitrary strings
3700 may be generated. This mechanism is similar to
3701 <I>pathname expansion</I>, but the filenames generated
3702 need not exist. Patterns to be brace expanded take
3703 the form of an optional
3704 <I>preamble</I>,
3705
3706 followed by either a series of comma-separated strings or
3707 a sequence expression between a pair of braces, followed by
3708 an optional
3709 <I>postscript</I>.
3710
3711 The preamble is prefixed to each string contained
3712 within the braces, and the postscript is then appended
3713 to each resulting string, expanding left to right.
3714 <P>
3715
3716 Brace expansions may be nested. The results of each expanded
3717 string are not sorted; left to right order is preserved.
3718 For example, a<B>{</B>d,c,b<B>}</B>e expands into `ade ace abe'.
3719 <P>
3720
3721 A sequence expression takes the form
3722 <B>{</B><I>x</I><B>..</B><I>y</I><B>[..</B><I>incr</I><B>]}</B>,
3723 where <I>x</I> and <I>y</I> are either integers or single letters,
3724 and <I>incr</I>, an optional increment, is an integer.
3725 When integers are supplied, the expression expands to each number between
3726 <I>x</I> and <I>y</I>, inclusive.
3727 Supplied integers may be prefixed with <I>0</I> to force each term to have the
3728 same width.
3729 When either <I>x</I> or y begins with a zero, the shell
3730 attempts to force all generated terms to contain the same number of digits,
3731 zero-padding where necessary.
3732 When letters are supplied, the expression expands to each character
3733 lexicographically between <I>x</I> and <I>y</I>, inclusive,
3734 using the default C locale.
3735 Note that both <I>x</I> and <I>y</I> must be of the same type
3736 (integer or letter).
3737 When the increment is supplied, it is used as the difference between
3738 each term. The default increment is 1 or -1 as appropriate.
3739 <P>
3740
3741 Brace expansion is performed before any other expansions,
3742 and any characters special to other expansions are preserved
3743 in the result. It is strictly textual.
3744 <B>Bash</B>
3745
3746 does not apply any syntactic interpretation to the context of the
3747 expansion or the text between the braces.
3748 <P>
3749
3750 A correctly-formed brace expansion must contain unquoted opening
3751 and closing braces, and at least one unquoted comma or a valid
3752 sequence expression.
3753 Any incorrectly formed brace expansion is left unchanged.
3754 A <B>{</B> or <B>,</B> may be quoted with a backslash to prevent its
3755 being considered part of a brace expression.
3756 To avoid conflicts with parameter expansion, the string <B>${</B>
3757 is not considered eligible for brace expansion, and inhibits brace
3758 expansion until the closing <B>}</B>.
3759 <P>
3760
3761 This construct is typically used as shorthand when the common
3762 prefix of the strings to be generated is longer than in the
3763 above example:
3764 <DL COMPACT><DT><DD>
3765 <P>
3766
3767 mkdir /usr/local/src/bash/{old,new,dist,bugs}
3768 </DL>
3769
3770 or
3771 <DL COMPACT><DT><DD>
3772 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
3773 </DL>
3774
3775 <P>
3776
3777 Brace expansion introduces a slight incompatibility with
3778 historical versions of
3779 <B>sh</B>.
3780
3781 <B>sh</B>
3782
3783 does not treat opening or closing braces specially when they
3784 appear as part of a word, and preserves them in the output.
3785 <B>Bash</B>
3786
3787 removes braces from words as a consequence of brace
3788 expansion. For example, a word entered to
3789 <B>sh</B>
3790
3791 as <I>file{1,2}</I>
3792 appears identically in the output. The same word is
3793 output as
3794 <I>file1 file2</I>
3795
3796 after expansion by
3797 <B>bash</B>.
3798
3799 If strict compatibility with
3800 <B>sh</B>
3801
3802 is desired, start
3803 <B>bash</B>
3804
3805 with the
3806 <B>+B</B>
3807
3808 option or disable brace expansion with the
3809 <B>+B</B>
3810
3811 option to the
3812 <B>set</B>
3813
3814 command (see
3815 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
3816
3817 </FONT>
3818 below).
3819 <A NAME="lbBA">&nbsp;</A>
3820 <H4>Tilde Expansion</H4>
3821
3822 If a word begins with an unquoted tilde character (`<B>~</B>'), all of
3823 the characters preceding the first unquoted slash (or all characters,
3824 if there is no unquoted slash) are considered a <I>tilde-prefix</I>.
3825 If none of the characters in the tilde-prefix are quoted, the
3826 characters in the tilde-prefix following the tilde are treated as a
3827 possible <I>login name</I>.
3828 If this login name is the null string, the tilde is replaced with the
3829 value of the shell parameter
3830 <FONT SIZE=-1><B>HOME</B>.
3831
3832 </FONT>
3833 If
3834 <FONT SIZE=-1><B>HOME</B>
3835
3836 </FONT>
3837 is unset, the home directory of the user executing the shell is
3838 substituted instead.
3839 Otherwise, the tilde-prefix is replaced with the home directory
3840 associated with the specified login name.
3841 <P>
3842
3843 If the tilde-prefix is a `~+', the value of the shell variable
3844 <FONT SIZE=-1><B>PWD</B>
3845
3846 </FONT>
3847 replaces the tilde-prefix.
3848 If the tilde-prefix is a `~-', the value of the shell variable
3849 <FONT SIZE=-1><B>OLDPWD</B>,
3850
3851 </FONT>
3852 if it is set, is substituted.
3853 If the characters following the tilde in the tilde-prefix consist
3854 of a number <I>N</I>, optionally prefixed
3855 by a `+' or a `-', the tilde-prefix is replaced with the corresponding
3856 element from the directory stack, as it would be displayed by the
3857 <B>dirs</B>
3858
3859 builtin invoked with the tilde-prefix as an argument.
3860 If the characters following the tilde in the tilde-prefix consist of a
3861 number without a leading `+' or `-', `+' is assumed.
3862 <P>
3863
3864 If the login name is invalid, or the tilde expansion fails, the word
3865 is unchanged.
3866 <P>
3867
3868 Each variable assignment is checked for unquoted tilde-prefixes immediately
3869 following a
3870 <B>:</B>
3871
3872 or the first
3873 <B>=</B>.
3874
3875 In these cases, tilde expansion is also performed.
3876 Consequently, one may use filenames with tildes in assignments to
3877 <FONT SIZE=-1><B>PATH</B>,
3878
3879 </FONT>
3880 <FONT SIZE=-1><B>MAILPATH</B>,
3881
3882 </FONT>
3883 and
3884 <FONT SIZE=-1><B>CDPATH</B>,
3885
3886 </FONT>
3887 and the shell assigns the expanded value.
3888 <P>
3889
3890 Bash also performs tilde expansion on words satisfying the conditions of
3891 variable assignments (as described above under
3892 <FONT SIZE=-1><B>PARAMETERS</B>)
3893
3894 </FONT>
3895 when they appear as arguments to simple commands.
3896 Bash does not do this, except for the <I>declaration</I> commands listed
3897 above, when in <I>posix mode</I>.
3898 <A NAME="lbBB">&nbsp;</A>
3899 <H4>Parameter Expansion</H4>
3900
3901 The `<B>$</B>' character introduces parameter expansion,
3902 command substitution, or arithmetic expansion. The parameter name
3903 or symbol to be expanded may be enclosed in braces, which
3904 are optional but serve to protect the variable to be expanded from
3905 characters immediately following it which could be
3906 interpreted as part of the name.
3907 <P>
3908
3909 When braces are used, the matching ending brace is the first `<B>}</B>'
3910 not escaped by a backslash or within a quoted string, and not within an
3911 embedded arithmetic expansion, command substitution, or parameter
3912 expansion.
3913 <P>
3914
3915
3916 <DL COMPACT>
3917 <DT>${<I>parameter</I>}<DD>
3918 The value of <I>parameter</I> is substituted. The braces are required
3919 when
3920 <I>parameter</I>
3921
3922 is a positional parameter with more than one digit,
3923 or when
3924 <I>parameter</I>
3925
3926 is followed by a character which is not to be
3927 interpreted as part of its name.
3928 The <I>parameter</I> is a shell parameter as described above
3929 <B>PARAMETERS</B>) or an array reference (<B>Arrays</B>).
3930
3931 </DL>
3932 <P>
3933
3934 If the first character of <I>parameter</I> is an exclamation point (<B>!</B>),
3935 and <I>parameter</I> is not a <I>nameref</I>,
3936 it introduces a level of indirection.
3937 <B>Bash</B> uses the value formed by expanding the rest of
3938 <I>parameter</I> as the new <I>parameter</I>; this is then
3939 expanded and that value is used in the rest of the expansion, rather
3940 than the expansion of the original <I>parameter</I>.
3941 This is known as <I>indirect expansion</I>.
3942 The value is subject to tilde expansion,
3943 parameter expansion, command substitution, and arithmetic expansion.
3944 If <I>parameter</I> is a nameref, this expands to the name of the
3945 parameter referenced by <I>parameter</I> instead of performing the
3946 complete indirect expansion.
3947 The exceptions to this are the expansions of ${<B>!</B><I>prefix</I><B>*</B>} and
3948 ${<B>!</B><I>name</I>[<I>@</I>]} described below.
3949 The exclamation point must immediately follow the left brace in order to
3950 introduce indirection.
3951 <P>
3952
3953 In each of the cases below, <I>word</I> is subject to tilde expansion,
3954 parameter expansion, command substitution, and arithmetic expansion.
3955 <P>
3956
3957 When not performing substring expansion, using the forms documented below
3958 (e.g., <B>:-</B>),
3959 <B>bash</B> tests for a parameter that is unset or null. Omitting the colon
3960 results in a test only for a parameter that is unset.
3961 <P>
3962
3963
3964 <DL COMPACT>
3965 <DT>${<I>parameter</I><B>:-</B><I>word</I>}<DD>
3966 <B>Use Default Values</B>. If
3967 <I>parameter</I>
3968
3969 is unset or null, the expansion of
3970 <I>word</I>
3971
3972 is substituted. Otherwise, the value of
3973 <I>parameter</I>
3974
3975 is substituted.
3976 <DT>${<I>parameter</I><B>:=</B><I>word</I>}<DD>
3977 <B>Assign Default Values</B>.
3978 If
3979 <I>parameter</I>
3980
3981 is unset or null, the expansion of
3982 <I>word</I>
3983
3984 is assigned to
3985 <I>parameter</I>.
3986
3987 The value of
3988 <I>parameter</I>
3989
3990 is then substituted. Positional parameters and special parameters may
3991 not be assigned to in this way.
3992 <DT>${<I>parameter</I><B>:?</B><I>word</I>}<DD>
3993 <B>Display Error if Null or Unset</B>.
3994 If
3995 <I>parameter</I>
3996
3997 is null or unset, the expansion of <I>word</I> (or a message to that effect
3998 if
3999 <I>word</I>
4000
4001 is not present) is written to the standard error and the shell, if it
4002 is not interactive, exits. Otherwise, the value of <I>parameter</I> is
4003 substituted.
4004 <DT>${<I>parameter</I><B>:+</B><I>word</I>}<DD>
4005 <B>Use Alternate Value</B>.
4006 If
4007 <I>parameter</I>
4008
4009 is null or unset, nothing is substituted, otherwise the expansion of
4010 <I>word</I>
4011
4012 is substituted.
4013 <DT>${<I>parameter</I><B>:</B><I>offset</I>}<DD>
4014
4015 <DT>${<I>parameter</I><B>:</B><I>offset</I><B>:</B><I>length</I>}<DD>
4016
4017 <B>Substring Expansion</B>.
4018 Expands to up to <I>length</I> characters of the value of <I>parameter</I>
4019 starting at the character specified by <I>offset</I>.
4020 If <I>parameter</I> is <B>@</B> or <B>*</B>, an indexed array subscripted by
4021 <B>@</B> or <B>*</B>, or an associative array name, the results differ as
4022 described below.
4023 If <I>length</I> is omitted, expands to the substring of the value of
4024 <I>parameter</I> starting at the character specified by <I>offset</I>
4025 and extending to the end of the value.
4026 <I>length</I> and <I>offset</I> are arithmetic expressions (see
4027 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
4028
4029 </FONT>
4030 below).
4031 <P>
4032 If <I>offset</I> evaluates to a number less than zero, the value
4033 is used as an offset in characters
4034 from the end of the value of <I>parameter</I>.
4035 If <I>length</I> evaluates to a number less than zero,
4036 it is interpreted as an offset in characters
4037 from the end of the value of <I>parameter</I> rather than
4038 a number of characters, and the expansion is the characters between
4039 <I>offset</I> and that result.
4040 Note that a negative offset must be separated from the colon by at least
4041 one space to avoid being confused with the <B>:-</B> expansion.
4042 <P>
4043 If <I>parameter</I> is <B>@</B> or <B>*</B>, the result is <I>length</I>
4044 positional parameters beginning at <I>offset</I>.
4045 A negative <I>offset</I> is taken relative to one greater than the greatest
4046 positional parameter, so an offset of -1 evaluates to the last positional
4047 parameter.
4048 It is an expansion error if <I>length</I> evaluates to a number less than
4049 zero.
4050 <P>
4051 If <I>parameter</I> is an indexed array name subscripted by @ or *,
4052 the result is the <I>length</I>
4053 members of the array beginning with ${<I>parameter</I>[<I>offset</I>]}.
4054 A negative <I>offset</I> is taken relative to one greater than the maximum
4055 index of the specified array.
4056 It is an expansion error if <I>length</I> evaluates to a number less than
4057 zero.
4058 <P>
4059 Substring expansion applied to an associative array produces undefined
4060 results.
4061 <P>
4062 Substring indexing is zero-based unless the positional parameters
4063 are used, in which case the indexing starts at 1 by default.
4064 If <I>offset</I> is 0, and the positional parameters are used, <B>$0</B> is
4065 prefixed to the list.
4066 <DT>${<B>!</B><I>prefix</I><B>*</B>}<DD>
4067
4068 <DT>${<B>!</B><I>prefix</I><B>@</B>}<DD>
4069
4070 <B>Names matching prefix</B>.
4071 Expands to the names of variables whose names begin with <I>prefix</I>,
4072 separated by the first character of the
4073 <FONT SIZE=-1><B>IFS</B>
4074
4075 </FONT>
4076 special variable.
4077 When <I>@</I> is used and the expansion appears within double quotes, each
4078 variable name expands to a separate word.
4079 <DT>${<B>!</B><I>name</I>[<I>@</I>]}<DD>
4080
4081 <DT>${<B>!</B><I>name</I>[<I>*</I>]}<DD>
4082
4083 <B>List of array keys</B>.
4084 If <I>name</I> is an array variable, expands to the list of array indices
4085 (keys) assigned in <I>name</I>.
4086 If <I>name</I> is not an array, expands to 0 if <I>name</I> is set and null
4087 otherwise.
4088 When <I>@</I> is used and the expansion appears within double quotes, each
4089 key expands to a separate word.
4090 <DT>${<B>#</B><I>parameter</I>}<DD>
4091 <B>Parameter length</B>.
4092 The length in characters of the value of <I>parameter</I> is substituted.
4093 If
4094 <I>parameter</I>
4095
4096 is
4097 <B>*</B>
4098
4099 or
4100 <B>@</B>,
4101
4102 the value substituted is the number of positional parameters.
4103 If
4104 <I>parameter</I>
4105
4106 is an array name subscripted by
4107 <B>*</B>
4108
4109 or
4110 <B>@</B>,
4111
4112 the value substituted is the number of elements in the array.
4113 If
4114 <I>parameter</I>
4115
4116 is an indexed array name subscripted by a negative number, that number is
4117 interpreted as relative to one greater than the maximum index of
4118 <I>parameter</I>, so negative indices count back from the end of the
4119 array, and an index of -1 references the last element.
4120 <DT>${<I>parameter</I><B>#</B><I>word</I>}<DD>
4121
4122 <DT>${<I>parameter</I><B>##</B><I>word</I>}<DD>
4123
4124 <B>Remove matching prefix pattern</B>.
4125 The
4126 <I>word</I>
4127
4128 is expanded to produce a pattern just as in pathname
4129 expansion, and matched against the expanded value of
4130 <I>parameter</I>
4131
4132 using the rules described under
4133 <B>Pattern Matching</B>
4134
4135 below.
4136 If the pattern matches the beginning of
4137 the value of
4138 <I>parameter</I>,
4139
4140 then the result of the expansion is the expanded value of
4141 <I>parameter</I>
4142
4143 with the shortest matching pattern (the ``<B>#</B>'' case) or the
4144 longest matching pattern (the ``<B>##</B>'' case) deleted.
4145 If
4146 <I>parameter</I>
4147
4148 is
4149 <B>@</B>
4150
4151 or
4152 <B>*</B>,
4153
4154 the pattern removal operation is applied to each positional
4155 parameter in turn, and the expansion is the resultant list.
4156 If
4157 <I>parameter</I>
4158
4159 is an array variable subscripted with
4160 <B>@</B>
4161
4162 or
4163 <B>*</B>,
4164
4165 the pattern removal operation is applied to each member of the
4166 array in turn, and the expansion is the resultant list.
4167 <DT>${<I>parameter</I><B>%</B><I>word</I>}<DD>
4168
4169 <DT>${<I>parameter</I><B>%%</B><I>word</I>}<DD>
4170
4171 <B>Remove matching suffix pattern</B>.
4172 The <I>word</I> is expanded to produce a pattern just as in
4173 pathname expansion, and matched against the expanded value of
4174 <I>parameter</I>
4175
4176 using the rules described under
4177 <B>Pattern Matching</B>
4178
4179 below.
4180 If the pattern matches a trailing portion of the expanded value of
4181 <I>parameter</I>,
4182
4183 then the result of the expansion is the expanded value of
4184 <I>parameter</I>
4185
4186 with the shortest matching pattern (the ``<B>%</B>'' case) or the
4187 longest matching pattern (the ``<B>%%</B>'' case) deleted.
4188 If
4189 <I>parameter</I>
4190
4191 is
4192 <B>@</B>
4193
4194 or
4195 <B>*</B>,
4196
4197 the pattern removal operation is applied to each positional
4198 parameter in turn, and the expansion is the resultant list.
4199 If
4200 <I>parameter</I>
4201
4202 is an array variable subscripted with
4203 <B>@</B>
4204
4205 or
4206 <B>*</B>,
4207
4208 the pattern removal operation is applied to each member of the
4209 array in turn, and the expansion is the resultant list.
4210 <DT>${<I>parameter</I><B>/</B><I>pattern</I><B>/</B><I>string</I>}<DD>
4211
4212 <DT>${<I>parameter</I><B>//</B><I>pattern</I><B>/</B><I>string</I>}<DD>
4213 <DT>${<I>parameter</I><B>/#</B><I>pattern</I><B>/</B><I>string</I>}<DD>
4214 <DT>${<I>parameter</I><B>/%</B><I>pattern</I><B>/</B><I>string</I>}<DD>
4215
4216 <B>Pattern substitution</B>.
4217 The <I>pattern</I> is expanded to produce a pattern just as in
4218 pathname expansion.
4219 <I>Parameter</I> is expanded and the longest match of <I>pattern</I>
4220 against its value is replaced with <I>string</I>.
4221 <I>string</I> undergoes tilde expansion, parameter and variable expansion,
4222 arithmetic expansion, command and process substitution, and quote removal.
4223 The match is performed using the rules described under
4224 <B>Pattern Matching</B>
4225
4226 below.
4227 In the first form above, only the first match is replaced.
4228 If there are two slashes separating <I>parameter</I> and <I>pattern</I>
4229 (the second form above), all matches of <I>pattern</I> are
4230 replaced with <I>string</I>.
4231 If <I>pattern</I> is preceded by <B>#</B> (the third form above),
4232 it must match at the beginning of the expanded value of <I>parameter</I>.
4233 If <I>pattern</I> is preceded by <B>%</B> (the fourth form above),
4234 it must match at the end of the expanded value of <I>parameter</I>.
4235 If the expansion of <I>string</I> is null,
4236 matches of <I>pattern</I> are deleted.
4237 If <I>string</I> is null,
4238 matches of <I>pattern</I> are deleted
4239 and the <B>/</B> following <I>pattern</I> may be omitted.
4240 <P>
4241 If the <B>patsub_replacement</B> shell option is enabled using <B>shopt</B>,
4242 any unquoted instances of <B>&amp;</B> in <I>string</I> are replaced with the
4243 matching portion of <I>pattern</I>.
4244 <P>
4245 Quoting any part of <I>string</I> inhibits replacement in the
4246 expansion of the quoted portion, including replacement strings stored
4247 in shell variables.
4248 Backslash will escape <B>&amp;</B> in <I>string</I>; the backslash is removed
4249 in order to permit a literal <B>&amp;</B> in the replacement string.
4250 Backslash can also be used to escape a backslash; <B>\\</B> results in
4251 a literal backslash in the replacement.
4252 Users should take care if <I>string</I> is double-quoted to avoid
4253 unwanted interactions between the backslash and double-quoting, since
4254 backslash has special meaning within double quotes.
4255 Pattern substitution performs the check for unquoted <B>&amp;</B> after
4256 expanding <I>string</I>;
4257 shell programmers should quote any occurrences of <B>&amp;</B>
4258 they want to be taken literally in the replacement
4259 and ensure any instances of <B>&amp;</B> they want to be replaced are unquoted.
4260 <P>
4261 If the
4262 <B>nocasematch</B>
4263
4264 shell option is enabled, the match is performed without regard to the case
4265 of alphabetic characters.
4266 If
4267 <I>parameter</I>
4268
4269 is
4270 <B>@</B>
4271
4272 or
4273 <B>*</B>,
4274
4275 the substitution operation is applied to each positional
4276 parameter in turn, and the expansion is the resultant list.
4277 If
4278 <I>parameter</I>
4279
4280 is an array variable subscripted with
4281 <B>@</B>
4282
4283 or
4284 <B>*</B>,
4285
4286 the substitution operation is applied to each member of the
4287 array in turn, and the expansion is the resultant list.
4288 <DT>${<I>parameter</I><B>^</B><I>pattern</I>}<DD>
4289
4290 <DT>${<I>parameter</I><B>^^</B><I>pattern</I>}<DD>
4291 <DT>${<I>parameter</I><B>,</B><I>pattern</I>}<DD>
4292 <DT>${<I>parameter</I><B>,,</B><I>pattern</I>}<DD>
4293
4294 <B>Case modification</B>.
4295 This expansion modifies the case of alphabetic characters in <I>parameter</I>.
4296 The <I>pattern</I> is expanded to produce a pattern just as in
4297 pathname expansion.
4298 Each character in the expanded value of <I>parameter</I> is tested against
4299 <I>pattern</I>, and, if it matches the pattern, its case is converted.
4300 The pattern should not attempt to match more than one character.
4301 The <B>^</B> operator converts lowercase letters matching <I>pattern</I>
4302 to uppercase; the <B>,</B> operator converts matching uppercase letters
4303 to lowercase.
4304 The <B>^^</B> and <B>,,</B> expansions convert each matched character in the
4305 expanded value; the <B>^</B> and <B>,</B> expansions match and convert only
4306 the first character in the expanded value.
4307 If <I>pattern</I> is omitted, it is treated like a <B>?</B>, which matches
4308 every character.
4309 If
4310 <I>parameter</I>
4311
4312 is
4313 <B>@</B>
4314
4315 or
4316 <B>*</B>,
4317
4318 the case modification operation is applied to each positional
4319 parameter in turn, and the expansion is the resultant list.
4320 If
4321 <I>parameter</I>
4322
4323 is an array variable subscripted with
4324 <B>@</B>
4325
4326 or
4327 <B>*</B>,
4328
4329 the case modification operation is applied to each member of the
4330 array in turn, and the expansion is the resultant list.
4331 <DT>${<I>parameter</I><B>@</B><I>operator</I>}<DD>
4332 <B>Parameter transformation</B>.
4333 The expansion is either a transformation of the value of <I>parameter</I>
4334 or information about <I>parameter</I> itself, depending on the value of
4335 <I>operator</I>. Each <I>operator</I> is a single letter:
4336 <P>
4337 <DL COMPACT><DT><DD>
4338
4339 <DL COMPACT>
4340 <DT><B>U</B>
4341
4342 <DD>
4343 The expansion is a string that is the value of <I>parameter</I> with lowercase
4344 alphabetic characters converted to uppercase.
4345 <DT><B>u</B>
4346
4347 <DD>
4348 The expansion is a string that is the value of <I>parameter</I> with the first
4349 character converted to uppercase, if it is alphabetic.
4350 <DT><B>L</B>
4351
4352 <DD>
4353 The expansion is a string that is the value of <I>parameter</I> with uppercase
4354 alphabetic characters converted to lowercase.
4355 <DT><B>Q</B>
4356
4357 <DD>
4358 The expansion is a string that is the value of <I>parameter</I> quoted in a
4359 format that can be reused as input.
4360 <DT><B>E</B>
4361
4362 <DD>
4363 The expansion is a string that is the value of <I>parameter</I> with backslash
4364 escape sequences expanded as with the <B>$aq...aq</B> quoting mechanism.
4365 <DT><B>P</B>
4366
4367 <DD>
4368 The expansion is a string that is the result of expanding the value of
4369 <I>parameter</I> as if it were a prompt string (see <B>PROMPTING</B> below).
4370 <DT><B>A</B>
4371
4372 <DD>
4373 The expansion is a string in the form of
4374 an assignment statement or <B>declare</B> command that, if
4375 evaluated, will recreate <I>parameter</I> with its attributes and value.
4376 <DT><B>K</B>
4377
4378 <DD>
4379 Produces a possibly-quoted version of the value of <I>parameter</I>,
4380 except that it prints the values of
4381 indexed and associative arrays as a sequence of quoted key-value pairs
4382 (see <B>Arrays</B> above).
4383 <DT><B>a</B>
4384
4385 <DD>
4386 The expansion is a string consisting of flag values representing
4387 <I>parameter</I>'s attributes.
4388 <DT><B>k</B>
4389
4390 <DD>
4391 Like the K transformation, but expands the keys and values of
4392 indexed and associative arrays to separate words after word splitting.
4393
4394 </DL>
4395 <P>
4396
4397 If
4398 <I>parameter</I>
4399
4400 is
4401 <B>@</B>
4402
4403 or
4404 <B>*</B>,
4405
4406 the operation is applied to each positional
4407 parameter in turn, and the expansion is the resultant list.
4408 If
4409 <I>parameter</I>
4410
4411 is an array variable subscripted with
4412 <B>@</B>
4413
4414 or
4415 <B>*</B>,
4416
4417 the operation is applied to each member of the
4418 array in turn, and the expansion is the resultant list.
4419 <P>
4420 The result of the expansion is subject to word splitting and pathname
4421 expansion as described below.
4422 </DL>
4423
4424 </DL>
4425 <A NAME="lbBC">&nbsp;</A>
4426 <H4>Command Substitution</H4>
4427
4428 <I>Command substitution</I> allows the output of a command to replace
4429 the command name. There are two forms:
4430 <DL COMPACT><DT><DD>
4431 <P>
4432
4433 <B>$(</B><I>command</I><B>)</B>
4434 </DL>
4435
4436 or
4437 <DL COMPACT><DT><DD>
4438 <B>`</B><I>command</I><B>`</B>
4439 </DL>
4440
4441 <P>
4442
4443 <B>Bash</B>
4444
4445 performs the expansion by executing <I>command</I> in a subshell environment
4446 and replacing the command substitution with the standard output of the
4447 command, with any trailing newlines deleted.
4448 Embedded newlines are not deleted, but they may be removed during
4449 word splitting.
4450 The command substitution <B>$(cat </B><I>file</I>) can be replaced by
4451 the equivalent but faster <B>$(&lt; </B><I>file</I>).
4452 <P>
4453
4454 When the old-style backquote form of substitution is used,
4455 backslash retains its literal meaning except when followed by
4456 <B>$</B>,
4457
4458 <B>`</B>,
4459
4460 or
4461 <B>\</B>.
4462
4463 The first backquote not preceded by a backslash terminates the
4464 command substitution.
4465 When using the $(<I>command</I>) form, all characters between the
4466 parentheses make up the command; none are treated specially.
4467 <P>
4468
4469 Command substitutions may be nested. To nest when using the backquoted form,
4470 escape the inner backquotes with backslashes.
4471 <P>
4472
4473 If the substitution appears within double quotes, word splitting and
4474 pathname expansion are not performed on the results.
4475 <A NAME="lbBD">&nbsp;</A>
4476 <H4>Arithmetic Expansion</H4>
4477
4478 Arithmetic expansion allows the evaluation of an arithmetic expression
4479 and the substitution of the result. The format for arithmetic expansion is:
4480 <DL COMPACT><DT><DD>
4481 <P>
4482
4483 <B>$((</B><I>expression</I><B>))</B>
4484 </DL>
4485
4486 <P>
4487
4488 The
4489 <I>expression</I>
4490
4491 undergoes the same expansions
4492 as if it were within double quotes,
4493 but double quote characters in <I>expression</I> are not treated specially
4494 and are removed.
4495 All tokens in the expression undergo parameter and variable expansion,
4496 command substitution, and quote removal.
4497 The result is treated as the arithmetic expression to be evaluated.
4498 Arithmetic expansions may be nested.
4499 <P>
4500
4501 The evaluation is performed according to the rules listed below under
4502 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
4503
4504 </FONT>
4505 If
4506 <I>expression</I>
4507
4508 is invalid,
4509 <B>bash</B>
4510
4511 prints a message indicating failure and no substitution occurs.
4512 <A NAME="lbBE">&nbsp;</A>
4513 <H4>Process Substitution</H4>
4514
4515 <I>Process substitution</I> allows a process's input or output to be
4516 referred to using a filename.
4517 It takes the form of
4518 <B>&lt;(</B><I>list</I><B>)</B>
4519 or
4520 <B>&gt;(</B><I>list</I><B>)</B>.
4521 The process <I>list</I> is run asynchronously, and its input or output
4522 appears as a filename.
4523 This filename is
4524 passed as an argument to the current command as the result of the
4525 expansion.
4526 If the <B>&gt;(</B><I>list</I><B>)</B> form is used, writing to
4527 the file will provide input for <I>list</I>. If the
4528 <B>&lt;(</B><I>list</I><B>)</B> form is used, the file passed as an
4529 argument should be read to obtain the output of <I>list</I>.
4530 Process substitution is supported on systems that support named
4531 pipes (<I>FIFOs</I>) or the <B>/dev/fd</B> method of naming open files.
4532 <P>
4533
4534 When available, process substitution is performed
4535 simultaneously with parameter and variable expansion,
4536 command substitution,
4537 and arithmetic expansion.
4538 <A NAME="lbBF">&nbsp;</A>
4539 <H4>Word Splitting</H4>
4540
4541 The shell scans the results of
4542 parameter expansion,
4543 command substitution,
4544 and
4545 arithmetic expansion
4546 that did not occur within double quotes for
4547 <I>word splitting</I>.
4548
4549 <P>
4550
4551 The shell treats each character of
4552 <FONT SIZE=-1><B>IFS</B>
4553
4554 </FONT>
4555 as a delimiter, and splits the results of the other
4556 expansions into words using these characters as field terminators.
4557 If
4558 <FONT SIZE=-1><B>IFS</B>
4559
4560 </FONT>
4561 is unset, or its
4562 value is exactly
4563 <B>&lt;space&gt;&lt;tab&gt;&lt;newline&gt;</B>,
4564
4565 the default, then
4566 sequences of
4567 <B>&lt;space&gt;</B>,
4568
4569 <B>&lt;tab&gt;</B>,
4570
4571 and
4572 <B>&lt;newline&gt;</B>
4573
4574 at the beginning and end of the results of the previous
4575 expansions are ignored, and
4576 any sequence of
4577 <FONT SIZE=-1><B>IFS</B>
4578
4579 </FONT>
4580 characters not at the beginning or end serves to delimit words.
4581 If
4582 <FONT SIZE=-1><B>IFS</B>
4583
4584 </FONT>
4585 has a value other than the default, then sequences of
4586 the whitespace characters
4587 <B>space</B>,
4588
4589 <B>tab</B>,
4590
4591 and
4592 <B>newline</B>
4593
4594 are ignored at the beginning and end of the
4595 word, as long as the whitespace character is in the
4596 value of
4597 <FONT SIZE=-1><B>IFS</B>
4598
4599 </FONT>
4600 (an
4601 <FONT SIZE=-1><B>IFS</B>
4602
4603 </FONT>
4604 whitespace character).
4605 Any character in
4606 <FONT SIZE=-1><B>IFS</B>
4607
4608 </FONT>
4609 that is not
4610 <FONT SIZE=-1><B>IFS</B>
4611
4612 </FONT>
4613 whitespace, along with any adjacent
4614 <FONT SIZE=-1><B>IFS</B>
4615
4616 </FONT>
4617 whitespace characters, delimits a field.
4618 A sequence of
4619 <FONT SIZE=-1><B>IFS</B>
4620
4621 </FONT>
4622 whitespace characters is also treated as a delimiter.
4623 If the value of
4624 <FONT SIZE=-1><B>IFS</B>
4625
4626 </FONT>
4627 is null, no word splitting occurs.
4628 <P>
4629
4630 Explicit null arguments (<B>&quot;&quot;</B> or <B>aqaq</B>) are retained
4631 and passed to commands as empty strings.
4632 Unquoted implicit null arguments, resulting from the expansion of
4633 parameters that have no values, are removed.
4634 If a parameter with no value is expanded within double quotes, a
4635 null argument results and is retained
4636 and passed to a command as an empty string.
4637 When a quoted null argument appears as part of a word whose expansion is
4638 non-null, the null argument is removed.
4639 That is, the word
4640 <TT>-daqaq</TT> becomes <TT>-d</TT> after word splitting and
4641 null argument removal.
4642 <P>
4643
4644 Note that if no expansion occurs, no splitting
4645 is performed.
4646 <A NAME="lbBG">&nbsp;</A>
4647 <H4>Pathname Expansion</H4>
4648
4649 After word splitting,
4650 unless the
4651 <B>-f</B>
4652
4653 option has been set,
4654 <B>bash</B>
4655
4656 scans each word for the characters
4657 <B>*</B>,
4658
4659 <B>?</B>,
4660
4661 and
4662 <B>[</B>.
4663
4664 If one of these characters appears, and is not quoted, then the word is
4665 regarded as a
4666 <I>pattern</I>,
4667
4668 and replaced with an alphabetically sorted list of
4669 filenames matching the pattern
4670 (see
4671 <FONT SIZE=-1><B>Pattern Matching</B>
4672
4673 </FONT>
4674 below).
4675 If no matching filenames are found,
4676 and the shell option
4677 <B>nullglob</B>
4678
4679 is not enabled, the word is left unchanged.
4680 If the
4681 <B>nullglob</B>
4682
4683 option is set, and no matches are found,
4684 the word is removed.
4685 If the
4686 <B>failglob</B>
4687
4688 shell option is set, and no matches are found, an error message
4689 is printed and the command is not executed.
4690 If the shell option
4691 <B>nocaseglob</B>
4692
4693 is enabled, the match is performed without regard to the case
4694 of alphabetic characters.
4695 When a pattern is used for pathname expansion,
4696 the character
4697 <B>``.''</B>
4698
4699 at the start of a name or immediately following a slash
4700 must be matched explicitly, unless the shell option
4701 <B>dotglob</B>
4702
4703 is set.
4704 In order to match the filenames
4705 <B>``.''</B>
4706
4707 and
4708 <B>``..''</B>,
4709
4710 the pattern must begin with ``.'' (for example, ``.?''),
4711 even if
4712 <B>dotglob</B>
4713
4714 is set.
4715 If the
4716 <B>globskipdots</B>
4717
4718 shell option is enabled, the filenames
4719 <B>``.''</B>
4720
4721 and
4722 <B>``..''</B>
4723
4724 are never matched, even if the pattern begins with a
4725 <B>``.''</B>.
4726
4727 When not matching pathnames, the
4728 <B>``.''</B>
4729
4730 character is not treated specially.
4731 When matching a pathname, the slash character must always be
4732 matched explicitly by a slash in the pattern, but in other matching
4733 contexts it can be matched by a special pattern character as described
4734 below under
4735 <FONT SIZE=-1><B>Pattern Matching</B>.
4736
4737 </FONT>
4738 See the description of
4739 <B>shopt</B>
4740
4741 below under
4742 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
4743
4744 </FONT>
4745 for a description of the
4746 <B>nocaseglob</B>,
4747
4748 <B>nullglob</B>,
4749
4750 <B>globskipdots</B>,
4751
4752 <B>failglob</B>,
4753
4754 and
4755 <B>dotglob</B>
4756
4757 shell options.
4758 <P>
4759
4760 The
4761 <FONT SIZE=-1><B>GLOBIGNORE</B>
4762
4763 </FONT>
4764 shell variable may be used to restrict the set of file names matching a
4765 <I>pattern</I>.
4766
4767 If
4768 <FONT SIZE=-1><B>GLOBIGNORE</B>
4769
4770 </FONT>
4771 is set, each matching file name that also matches one of the patterns in
4772 <FONT SIZE=-1><B>GLOBIGNORE</B>
4773
4774 </FONT>
4775 is removed from the list of matches.
4776 If the <B>nocaseglob</B> option is set, the matching against the patterns in
4777 <FONT SIZE=-1><B>GLOBIGNORE</B>
4778
4779 </FONT>
4780 is performed without regard to case.
4781 The filenames
4782 <B>``.''</B>
4783
4784 and
4785 <B>``..''</B>
4786
4787 are always ignored when
4788 <FONT SIZE=-1><B>GLOBIGNORE</B>
4789
4790 </FONT>
4791 is set and not null. However, setting
4792 <FONT SIZE=-1><B>GLOBIGNORE</B>
4793
4794 </FONT>
4795 to a non-null value has the effect of enabling the
4796 <B>dotglob</B>
4797
4798 shell option, so all other filenames beginning with a
4799 <B>``.''</B>
4800
4801 will match.
4802 To get the old behavior of ignoring filenames beginning with a
4803 <B>``.''</B>,
4804
4805 make
4806 <B>``.*''</B>
4807
4808 one of the patterns in
4809 <FONT SIZE=-1><B>GLOBIGNORE</B>.
4810
4811 </FONT>
4812 The
4813 <B>dotglob</B>
4814
4815 option is disabled when
4816 <FONT SIZE=-1><B>GLOBIGNORE</B>
4817
4818 </FONT>
4819 is unset.
4820 The pattern matching honors the setting of the <B>extglob</B> shell
4821 option.
4822 <P>
4823
4824 <B>Pattern Matching</B>
4825 <P>
4826
4827 Any character that appears in a pattern, other than the special pattern
4828 characters described below, matches itself. The NUL character may not
4829 occur in a pattern. A backslash escapes the following character; the
4830 escaping backslash is discarded when matching.
4831 The special pattern characters must be quoted if
4832 they are to be matched literally.
4833 <P>
4834
4835 The special pattern characters have the following meanings:
4836 <P>
4837
4838
4839 <DL COMPACT><DT><DD>
4840 <DL COMPACT>
4841 <DT><B>*</B>
4842
4843 <DD>
4844 Matches any string, including the null string.
4845 When the <B>globstar</B> shell option is enabled, and <B>*</B> is used in
4846 a pathname expansion context, two adjacent <B>*</B>s used as a single
4847 pattern will match all files and zero or more directories and
4848 subdirectories.
4849 If followed by a <B>/</B>, two adjacent <B>*</B>s will match only directories
4850 and subdirectories.
4851 <DT><B>?</B>
4852
4853 <DD>
4854 Matches any single character.
4855 <DT><B>[...]</B>
4856
4857 <DD>
4858 Matches any one of the enclosed characters. A pair of characters
4859 separated by a hyphen denotes a
4860 <I>range expression</I>;
4861 any character that falls between those two characters, inclusive,
4862 using the current locale's collating sequence and character set,
4863 is matched. If the first character following the
4864 <B>[</B>
4865
4866 is a
4867 <B>!</B>
4868
4869 or a
4870 <B>^</B>
4871
4872 then any character not enclosed is matched.
4873 The sorting order of characters in range expressions,
4874 and the characters included in the range,
4875 are determined by
4876 the current locale and the values of the
4877 <FONT SIZE=-1><B>LC_COLLATE</B>
4878
4879 </FONT>
4880 or
4881 <FONT SIZE=-1><B>LC_ALL</B>
4882
4883 </FONT>
4884 shell variables, if set.
4885 To obtain the traditional interpretation of range expressions, where
4886 <B>[a-d]</B>
4887
4888 is equivalent to
4889 <B>[abcd]</B>,
4890
4891 set value of the
4892 <B>LC_ALL</B>
4893
4894 shell variable to
4895 <B>C</B>,
4896
4897 or enable the
4898 <B>globasciiranges</B>
4899
4900 shell option.
4901 A
4902 <B>-</B>
4903
4904 may be matched by including it as the first or last character
4905 in the set.
4906 A
4907 <B>]</B>
4908
4909 may be matched by including it as the first character
4910 in the set.
4911 <BR>
4912
4913 <P>
4914
4915
4916 Within
4917 <B>[</B>
4918
4919 and
4920 <B>]</B>,
4921
4922 <I>character classes</I> can be specified using the syntax
4923 <B>[:</B><I>class</I><B>:]</B>, where <I>class</I> is one of the
4924 following classes defined in the POSIX standard:
4925 </DL>
4926 <P>
4927
4928 <DL COMPACT><DT><DD>
4929 <B>
4930 </B>
4931
4932 alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
4933 <BR>
4934
4935 A character class matches any character belonging to that class.
4936 The <B>word</B> character class matches letters, digits, and the character _.
4937 <BR>
4938
4939 <P>
4940
4941
4942 Within
4943 <B>[</B>
4944
4945 and
4946 <B>]</B>,
4947
4948 an <I>equivalence class</I> can be specified using the syntax
4949 <B>[=</B><I>c</I><B>=]</B>, which matches all characters with the
4950 same collation weight (as defined by the current locale) as
4951 the character <I>c</I>.
4952 <BR>
4953
4954 <P>
4955
4956
4957 Within
4958 <B>[</B>
4959
4960 and
4961 <B>]</B>,
4962
4963 the syntax <B>[.</B><I>symbol</I><B>.]</B> matches the collating symbol
4964 <I>symbol</I>.
4965 </DL>
4966
4967 </DL>
4968
4969
4970 <P>
4971
4972 If the <B>extglob</B> shell option is enabled using the <B>shopt</B>
4973 builtin, the shell recognizes several extended pattern matching operators.
4974 In the following description, a <I>pattern-list</I> is a list of one
4975 or more patterns separated by a <B>|</B>.
4976 Composite patterns may be formed using one or more of the following
4977 sub-patterns:
4978 <P>
4979
4980 <DL COMPACT><DT><DD>
4981 <DL COMPACT>
4982 <DT><B>?(</B><I>pattern-list</I><B>)</B><DD>
4983 Matches zero or one occurrence of the given patterns
4984 <DT><B>*(</B><I>pattern-list</I><B>)</B><DD>
4985 Matches zero or more occurrences of the given patterns
4986 <DT><B>+(</B><I>pattern-list</I><B>)</B><DD>
4987 Matches one or more occurrences of the given patterns
4988 <DT><B>@(</B><I>pattern-list</I><B>)</B><DD>
4989 Matches one of the given patterns
4990 <DT><B>!(</B><I>pattern-list</I><B>)</B><DD>
4991 Matches anything except one of the given patterns
4992 </DL></DL>
4993
4994
4995 <P>
4996
4997 The<B>extglob</B> option changes the behavior of the parser, since the
4998 parentheses are normally treated as operators with syntactic meaning.
4999 To ensure that extended matching patterns are parsed correctly, make sure
5000 that <B>extglob</B> is enabled before parsing constructs containing the
5001 patterns, including shell functions and command substitutions.
5002 <P>
5003
5004 When matching filenames, the <B>dotglob</B> shell option determines
5005 the set of filenames that are tested:
5006 when <B>dotglob</B> is enabled, the set of filenames includes all files
5007 beginning with ``.'', but ``.'' and ``..'' must be matched by a
5008 pattern or sub-pattern that begins with a dot;
5009 when it is disabled, the set does not
5010 include any filenames beginning with ``.'' unless the pattern
5011 or sub-pattern begins with a ``.''.
5012 As above, ``.'' only has a special meaning when matching filenames.
5013 <P>
5014
5015 Complicated extended pattern matching against long strings is slow,
5016 especially when the patterns contain alternations and the strings
5017 contain multiple matches.
5018 Using separate matches against shorter strings, or using arrays of
5019 strings instead of a single long string, may be faster.
5020 <A NAME="lbBH">&nbsp;</A>
5021 <H4>Quote Removal</H4>
5022
5023 After the preceding expansions, all unquoted occurrences of the
5024 characters
5025 <B>\</B>,
5026
5027 <B>aq</B>,
5028
5029 and <B>&quot;</B> that did not result from one of the above
5030 expansions are removed.
5031 <A NAME="lbBI">&nbsp;</A>
5032 <H3>REDIRECTION</H3>
5033
5034 Before a command is executed, its input and output
5035 may be
5036 <I>redirected</I>
5037
5038 using a special notation interpreted by the shell.
5039 <I>Redirection</I> allows commands' file handles to be
5040 duplicated, opened, closed,
5041 made to refer to different files,
5042 and can change the files the command reads from and writes to.
5043 Redirection may also be used to modify file handles in the
5044 current shell execution environment.
5045 The following redirection
5046 operators may precede or appear anywhere within a
5047 <I>simple command</I>
5048
5049 or may follow a
5050 <I>command</I>.
5051
5052 Redirections are processed in the order they appear, from
5053 left to right.
5054 <P>
5055
5056 Each redirection that may be preceded by a file descriptor number
5057 may instead be preceded by a word of the form {<I>varname</I>}.
5058 In this case, for each redirection operator except
5059 &gt;&amp;- and &lt;&amp;-, the shell will allocate a file descriptor greater
5060 than or equal to 10 and assign it to <I>varname</I>.
5061 If &gt;&amp;- or &lt;&amp;- is preceded
5062 by {<I>varname</I>}, the value of <I>varname</I> defines the file
5063 descriptor to close.
5064 If {<I>varname</I>} is supplied, the redirection persists beyond
5065 the scope of the command, allowing the shell programmer to manage
5066 the file descriptor's lifetime manually.
5067 The <B>varredir_close</B> shell option manages this behavior.
5068 <P>
5069
5070 In the following descriptions, if the file descriptor number is
5071 omitted, and the first character of the redirection operator is
5072 <B>&lt;</B>,
5073
5074 the redirection refers to the standard input (file descriptor
5075 0). If the first character of the redirection operator is
5076 <B>&gt;</B>,
5077
5078 the redirection refers to the standard output (file descriptor
5079 1).
5080 <P>
5081
5082 The word following the redirection operator in the following
5083 descriptions, unless otherwise noted, is subjected to
5084 brace expansion, tilde expansion, parameter and variable expansion,
5085 command substitution, arithmetic expansion, quote removal,
5086 pathname expansion, and word splitting.
5087 If it expands to more than one word,
5088 <B>bash</B>
5089
5090 reports an error.
5091 <P>
5092
5093 Note that the order of redirections is significant. For example,
5094 the command
5095 <DL COMPACT><DT><DD>
5096 <P>
5097
5098 ls <B>&gt;</B> dirlist 2<B>&gt;&amp;</B>1
5099 </DL>
5100
5101 <P>
5102
5103 directs both standard output and standard error to the file
5104 <I>dirlist</I>,
5105
5106 while the command
5107 <DL COMPACT><DT><DD>
5108 <P>
5109
5110 ls 2<B>&gt;&amp;</B>1 <B>&gt;</B> dirlist
5111 </DL>
5112
5113 <P>
5114
5115 directs only the standard output to file
5116 <I>dirlist</I>,
5117
5118 because the standard error was duplicated from the standard output
5119 before the standard output was redirected to
5120 <I>dirlist</I>.
5121
5122 <P>
5123
5124 <B>Bash</B> handles several filenames specially when they are used in
5125 redirections, as described in the following table.
5126 If the operating system on which <B>bash</B> is running provides these
5127 special files, bash will use them; otherwise it will emulate them
5128 internally with the behavior described below.
5129 <DL COMPACT><DT><DD>
5130 <P>
5131
5132
5133 <DL COMPACT>
5134 <DT><B>/dev/fd/</B><I>fd</I>
5135
5136 <DD>
5137 If <I>fd</I> is a valid integer, file descriptor <I>fd</I> is duplicated.
5138 <DT><B>/dev/stdin</B>
5139
5140 <DD>
5141 File descriptor 0 is duplicated.
5142 <DT><B>/dev/stdout</B>
5143
5144 <DD>
5145 File descriptor 1 is duplicated.
5146 <DT><B>/dev/stderr</B>
5147
5148 <DD>
5149 File descriptor 2 is duplicated.
5150 <DT><B>/dev/tcp/</B><I>host</I>/<I>port</I>
5151
5152 <DD>
5153 If <I>host</I> is a valid hostname or Internet address, and <I>port</I>
5154 is an integer port number or service name, <B>bash</B> attempts to open
5155 the corresponding TCP socket.
5156 <DT><B>/dev/udp/</B><I>host</I>/<I>port</I>
5157
5158 <DD>
5159 If <I>host</I> is a valid hostname or Internet address, and <I>port</I>
5160 is an integer port number or service name, <B>bash</B> attempts to open
5161 the corresponding UDP socket.
5162
5163 </DL></DL>
5164
5165 <P>
5166
5167 A failure to open or create a file causes the redirection to fail.
5168 <P>
5169
5170 Redirections using file descriptors greater than 9 should be used with
5171 care, as they may conflict with file descriptors the shell uses
5172 internally.
5173 <A NAME="lbBJ">&nbsp;</A>
5174 <H4>Redirecting Input</H4>
5175
5176 Redirection of input causes the file whose name results from
5177 the expansion of
5178 <I>word</I>
5179
5180 to be opened for reading on file descriptor
5181 <I>n</I>,
5182
5183 or the standard input (file descriptor 0) if
5184 <I>n</I>
5185
5186 is not specified.
5187 <P>
5188
5189 The general format for redirecting input is:
5190 <DL COMPACT><DT><DD>
5191 <P>
5192
5193 [<I>n</I>]<B>&lt;</B><I>word</I>
5194 </DL>
5195
5196 <A NAME="lbBK">&nbsp;</A>
5197 <H4>Redirecting Output</H4>
5198
5199 Redirection of output causes the file whose name results from
5200 the expansion of
5201 <I>word</I>
5202
5203 to be opened for writing on file descriptor
5204 <I>n</I>,
5205
5206 or the standard output (file descriptor 1) if
5207 <I>n</I>
5208
5209 is not specified. If the file does not exist it is created;
5210 if it does exist it is truncated to zero size.
5211 <P>
5212
5213 The general format for redirecting output is:
5214 <DL COMPACT><DT><DD>
5215 <P>
5216
5217 [<I>n</I>]<B>&gt;</B><I>word</I>
5218 </DL>
5219
5220 <P>
5221
5222 If the redirection operator is
5223 <B>&gt;</B>,
5224
5225 and the
5226 <B>noclobber</B>
5227
5228 option to the
5229 <B>set</B>
5230
5231 builtin has been enabled, the redirection will fail if the file
5232 whose name results from the expansion of <I>word</I> exists and is
5233 a regular file.
5234 If the redirection operator is
5235 <B>&gt;|</B>,
5236
5237 or the redirection operator is
5238 <B>&gt;</B>
5239
5240 and the
5241 <B>noclobber</B>
5242
5243 option to the
5244 <B>set</B>
5245
5246 builtin command is not enabled, the redirection is attempted even
5247 if the file named by <I>word</I> exists.
5248 <A NAME="lbBL">&nbsp;</A>
5249 <H4>Appending Redirected Output</H4>
5250
5251 Redirection of output in this fashion
5252 causes the file whose name results from
5253 the expansion of
5254 <I>word</I>
5255
5256 to be opened for appending on file descriptor
5257 <I>n</I>,
5258
5259 or the standard output (file descriptor 1) if
5260 <I>n</I>
5261
5262 is not specified. If the file does not exist it is created.
5263 <P>
5264
5265 The general format for appending output is:
5266 <DL COMPACT><DT><DD>
5267 <P>
5268
5269 [<I>n</I>]<B>&gt;&gt;</B><I>word</I>
5270 </DL>
5271
5272 <A NAME="lbBM">&nbsp;</A>
5273 <H4>Redirecting Standard Output and Standard Error</H4>
5274
5275 This construct allows both the
5276 standard output (file descriptor 1) and
5277 the standard error output (file descriptor 2)
5278 to be redirected to the file whose name is the
5279 expansion of
5280 <I>word</I>.
5281
5282 <P>
5283
5284 There are two formats for redirecting standard output and
5285 standard error:
5286 <DL COMPACT><DT><DD>
5287 <P>
5288
5289 <B>&amp;&gt;</B><I>word</I>
5290 </DL>
5291
5292 and
5293 <DL COMPACT><DT><DD>
5294 <B>&gt;&amp;</B><I>word</I>
5295 </DL>
5296
5297 <P>
5298
5299 Of the two forms, the first is preferred.
5300 This is semantically equivalent to
5301 <DL COMPACT><DT><DD>
5302 <P>
5303
5304 <B>&gt;</B><I>word</I> 2<B>&gt;&amp;</B>1
5305 </DL>
5306
5307 <P>
5308
5309 When using the second form, <I>word</I> may not expand to a number or
5310 <B>-</B>. If it does, other redirection operators apply
5311 (see <B>Duplicating File Descriptors</B> below) for compatibility
5312 reasons.
5313 <A NAME="lbBN">&nbsp;</A>
5314 <H4>Appending Standard Output and Standard Error</H4>
5315
5316 This construct allows both the
5317 standard output (file descriptor 1) and
5318 the standard error output (file descriptor 2)
5319 to be appended to the file whose name is the
5320 expansion of
5321 <I>word</I>.
5322
5323 <P>
5324
5325 The format for appending standard output and standard error is:
5326 <DL COMPACT><DT><DD>
5327 <P>
5328
5329 <B>&amp;&gt;&gt;</B><I>word</I>
5330 </DL>
5331
5332 <P>
5333
5334 This is semantically equivalent to
5335 <DL COMPACT><DT><DD>
5336 <P>
5337
5338 <B>&gt;&gt;</B><I>word</I> 2<B>&gt;&amp;</B>1
5339 </DL>
5340
5341 <P>
5342
5343 (see <B>Duplicating File Descriptors</B> below).
5344 <A NAME="lbBO">&nbsp;</A>
5345 <H4>Here Documents</H4>
5346
5347 This type of redirection instructs the shell to read input from the
5348 current source until a line containing only
5349 <I>delimiter</I>
5350
5351 (with no trailing blanks)
5352 is seen. All of
5353 the lines read up to that point are then used as the standard
5354 input (or file descriptor <I>n</I> if <I>n</I> is specified) for a command.
5355 <P>
5356
5357 The format of here-documents is:
5358 <DL COMPACT><DT><DD>
5359 <P>
5360
5361 <PRE>
5362 [<I>n</I>]<B>&lt;&lt;</B>[<B>-</B>]<I>word</I>
5363 <I>here-document</I>
5364 <I>delimiter</I>
5365 </PRE>
5366
5367 </DL>
5368
5369 <P>
5370
5371 No parameter and variable expansion, command substitution,
5372 arithmetic expansion, or pathname expansion is performed on
5373 <I>word</I>.
5374
5375 If any part of
5376 <I>word</I>
5377
5378 is quoted, the
5379 <I>delimiter</I>
5380
5381 is the result of quote removal on
5382 <I>word</I>,
5383
5384 and the lines in the here-document are not expanded.
5385 If <I>word</I> is unquoted,
5386 all lines of the here-document are subjected to
5387 parameter expansion, command substitution, and arithmetic expansion,
5388 the character sequence
5389 <B>\&lt;newline&gt;</B>
5390
5391 is ignored, and
5392 <B>\</B>
5393
5394 must be used to quote the characters
5395 <B>\</B>,
5396
5397 <B>$</B>,
5398
5399 and
5400 <B>`</B>.
5401
5402 <P>
5403
5404 If the redirection operator is
5405 <B>&lt;&lt;-</B>,
5406
5407 then all leading tab characters are stripped from input lines and the
5408 line containing
5409 <I>delimiter</I>.
5410
5411 This allows
5412 here-documents within shell scripts to be indented in a
5413 natural fashion.
5414 <A NAME="lbBP">&nbsp;</A>
5415 <H4>Here Strings</H4>
5416
5417 A variant of here documents, the format is:
5418 <DL COMPACT><DT><DD>
5419 <P>
5420
5421 <PRE>
5422 [<I>n</I>]<B>&lt;&lt;&lt;</B><I>word</I>
5423 </PRE>
5424
5425 </DL>
5426
5427 <P>
5428
5429 The <I>word</I> undergoes
5430 tilde expansion, parameter and variable expansion,
5431 command substitution, arithmetic expansion, and quote removal.
5432 Pathname expansion and word splitting are not performed.
5433 The result is supplied as a single string, with a newline appended,
5434 to the command on its
5435 standard input (or file descriptor <I>n</I> if <I>n</I> is specified).
5436 <A NAME="lbBQ">&nbsp;</A>
5437 <H4>Duplicating File Descriptors</H4>
5438
5439 The redirection operator
5440 <DL COMPACT><DT><DD>
5441 <P>
5442
5443 [<I>n</I>]<B>&lt;&amp;</B><I>word</I>
5444 </DL>
5445
5446 <P>
5447
5448 is used to duplicate input file descriptors.
5449 If
5450 <I>word</I>
5451
5452 expands to one or more digits, the file descriptor denoted by
5453 <I>n</I>
5454
5455 is made to be a copy of that file descriptor.
5456 If the digits in
5457 <I>word</I>
5458
5459 do not specify a file descriptor open for input, a redirection error occurs.
5460 If
5461 <I>word</I>
5462
5463 evaluates to
5464 <B>-</B>,
5465
5466 file descriptor
5467 <I>n</I>
5468
5469 is closed. If
5470 <I>n</I>
5471
5472 is not specified, the standard input (file descriptor 0) is used.
5473 <P>
5474
5475 The operator
5476 <DL COMPACT><DT><DD>
5477 <P>
5478
5479 [<I>n</I>]<B>&gt;&amp;</B><I>word</I>
5480 </DL>
5481
5482 <P>
5483
5484 is used similarly to duplicate output file descriptors. If
5485 <I>n</I>
5486
5487 is not specified, the standard output (file descriptor 1) is used.
5488 If the digits in
5489 <I>word</I>
5490
5491 do not specify a file descriptor open for output, a redirection error occurs.
5492 If
5493 <I>word</I>
5494
5495 evaluates to
5496 <B>-</B>,
5497
5498 file descriptor
5499 <I>n</I>
5500
5501 is closed.
5502 As a special case, if <I>n</I> is omitted, and <I>word</I> does not
5503 expand to one or more digits or <B>-</B>, the standard output and standard
5504 error are redirected as described previously.
5505 <A NAME="lbBR">&nbsp;</A>
5506 <H4>Moving File Descriptors</H4>
5507
5508 The redirection operator
5509 <DL COMPACT><DT><DD>
5510 <P>
5511
5512 [<I>n</I>]<B>&lt;&amp;</B><I>digit</I><B>-</B>
5513 </DL>
5514
5515 <P>
5516
5517 moves the file descriptor <I>digit</I> to file descriptor
5518 <I>n</I>,
5519
5520 or the standard input (file descriptor 0) if <I>n</I> is not specified.
5521 <I>digit</I> is closed after being duplicated to <I>n</I>.
5522 <P>
5523
5524 Similarly, the redirection operator
5525 <DL COMPACT><DT><DD>
5526 <P>
5527
5528 [<I>n</I>]<B>&gt;&amp;</B><I>digit</I><B>-</B>
5529 </DL>
5530
5531 <P>
5532
5533 moves the file descriptor <I>digit</I> to file descriptor
5534 <I>n</I>,
5535
5536 or the standard output (file descriptor 1) if <I>n</I> is not specified.
5537 <A NAME="lbBS">&nbsp;</A>
5538 <H4>Opening File Descriptors for Reading and Writing</H4>
5539
5540 The redirection operator
5541 <DL COMPACT><DT><DD>
5542 <P>
5543
5544 [<I>n</I>]<B>&lt;&gt;</B><I>word</I>
5545 </DL>
5546
5547 <P>
5548
5549 causes the file whose name is the expansion of
5550 <I>word</I>
5551
5552 to be opened for both reading and writing on file descriptor
5553 <I>n</I>,
5554
5555 or on file descriptor 0 if
5556 <I>n</I>
5557
5558 is not specified. If the file does not exist, it is created.
5559 <A NAME="lbBT">&nbsp;</A>
5560 <H3>ALIASES</H3>
5561
5562 <I>Aliases</I> allow a string to be substituted for a word when it is used
5563 as the first word of a simple command.
5564 The shell maintains a list of aliases that may be set and unset with the
5565 <B>alias</B>
5566
5567 and
5568 <B>unalias</B>
5569
5570 builtin commands (see
5571 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
5572
5573 </FONT>
5574 below).
5575 The first word of each simple command, if unquoted,
5576 is checked to see if it has an
5577 alias. If so, that word is replaced by the text of the alias.
5578 The characters <B>/</B>, <B>$</B>, <B>`</B>, and <B>=</B> and
5579 any of the shell <I>metacharacters</I> or quoting characters
5580 listed above may not appear in an alias name.
5581 The replacement text may contain any valid shell input,
5582 including shell metacharacters.
5583 The first word of the replacement text is tested
5584 for aliases, but a word that is identical to an alias being expanded
5585 is not expanded a second time.
5586 This means that one may alias
5587 <B>ls</B>
5588
5589 to
5590 <B>ls -F</B>,
5591
5592 for instance, and
5593 <B>bash</B>
5594
5595 does not try to recursively expand the replacement text.
5596 If the last character of the alias value is a
5597 <I>blank</I>,
5598
5599 then the next command
5600 word following the alias is also checked for alias expansion.
5601 <P>
5602
5603 Aliases are created and listed with the
5604 <B>alias</B>
5605
5606 command, and removed with the
5607 <B>unalias</B>
5608
5609 command.
5610 <P>
5611
5612 There is no mechanism for using arguments in the replacement text.
5613 If arguments are needed, use a shell function (see
5614 <FONT SIZE=-1><B>FUNCTIONS</B>
5615
5616 </FONT>
5617 below).
5618 <P>
5619
5620 Aliases are not expanded when the shell is not interactive, unless
5621 the
5622 <B>expand_aliases</B>
5623
5624 shell option is set using
5625 <B>shopt</B>
5626
5627 (see the description of
5628 <B>shopt</B>
5629
5630 under
5631 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B></FONT>
5632 below).
5633 <P>
5634
5635 The rules concerning the definition and use of aliases are
5636 somewhat confusing.
5637 <B>Bash</B>
5638
5639 always reads at least one complete line of input,
5640 and all lines that make up a compound command,
5641 before executing any of the commands on that line or the compound command.
5642 Aliases are expanded when a
5643 command is read, not when it is executed. Therefore, an
5644 alias definition appearing on the same line as another
5645 command does not take effect until the next line of input is read.
5646 The commands following the alias definition
5647 on that line are not affected by the new alias.
5648 This behavior is also an issue when functions are executed.
5649 Aliases are expanded when a function definition is read,
5650 not when the function is executed, because a function definition
5651 is itself a command. As a consequence, aliases
5652 defined in a function are not available until after that
5653 function is executed. To be safe, always put
5654 alias definitions on a separate line, and do not use
5655 <B>alias</B>
5656
5657 in compound commands.
5658 <P>
5659
5660 For almost every purpose, aliases are superseded by
5661 shell functions.
5662 <A NAME="lbBU">&nbsp;</A>
5663 <H3>FUNCTIONS</H3>
5664
5665 A shell function, defined as described above under
5666 <FONT SIZE=-1><B>SHELL GRAMMAR</B>,
5667
5668 </FONT>
5669 stores a series of commands for later execution.
5670 When the name of a shell function is used as a simple command name,
5671 the list of commands associated with that function name is executed.
5672 Functions are executed in the context of the
5673 current shell; no new process is created to interpret
5674 them (contrast this with the execution of a shell script).
5675 When a function is executed, the arguments to the
5676 function become the positional parameters
5677 during its execution.
5678 The special parameter
5679 <B>#</B>
5680
5681 is updated to reflect the change. Special parameter <B>0</B>
5682 is unchanged.
5683 The first element of the
5684 <FONT SIZE=-1><B>FUNCNAME</B>
5685
5686 </FONT>
5687 variable is set to the name of the function while the function
5688 is executing.
5689 <P>
5690
5691 All other aspects of the shell execution
5692 environment are identical between a function and its caller
5693 with these exceptions: the
5694 <FONT SIZE=-1><B>DEBUG</B>
5695
5696 </FONT>
5697 and
5698 <B>RETURN</B>
5699
5700 traps (see the description of the
5701 <B>trap</B>
5702
5703 builtin under
5704 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
5705
5706 </FONT>
5707 below) are not inherited unless the function has been given the
5708 <B>trace</B> attribute (see the description of the
5709 <FONT SIZE=-1><B>declare</B>
5710
5711 </FONT>
5712 builtin below) or the
5713 <B>-o functrace</B> shell option has been enabled with
5714 the <B>set</B> builtin
5715 (in which case all functions inherit the <B>DEBUG</B> and <B>RETURN</B> traps),
5716 and the
5717 <FONT SIZE=-1><B>ERR</B>
5718
5719 </FONT>
5720 trap is not inherited unless the <B>-o errtrace</B> shell option has
5721 been enabled.
5722 <P>
5723
5724 Variables local to the function may be declared with the
5725 <B>local</B>
5726
5727 builtin command (<I>local variables</I>).
5728 Ordinarily, variables and their values
5729 are shared between the function and its caller.
5730 If a variable is declared <B>local</B>, the variable's visible scope
5731 is restricted to that function and its children (including the functions
5732 it calls).
5733 <P>
5734
5735 In the following description, the <I>current scope</I> is a currently-
5736 executing function.
5737 Previous scopes consist of that function's caller and so on,
5738 back to the &quot;global&quot; scope, where the shell is not executing
5739 any shell function.
5740 Consequently, a local variable at the current scope is a variable
5741 declared using the <B>local</B> or <B>declare</B> builtins in the
5742 function that is currently executing.
5743 <P>
5744
5745 Local variables &quot;shadow&quot; variables with the same name declared at
5746 previous scopes.
5747 For instance, a local variable declared in a function
5748 hides a global variable of the same name: references and assignments
5749 refer to the local variable, leaving the global variable unmodified.
5750 When the function returns, the global variable is once again visible.
5751 <P>
5752
5753 The shell uses <I>dynamic scoping</I> to control a variable's visibility
5754 within functions.
5755 With dynamic scoping, visible variables and their values
5756 are a result of the sequence of function calls that caused execution
5757 to reach the current function.
5758 The value of a variable that a function sees depends
5759 on its value within its caller, if any, whether that caller is
5760 the &quot;global&quot; scope or another shell function.
5761 This is also the value that a local variable
5762 declaration &quot;shadows&quot;, and the value that is restored when the function
5763 returns.
5764 <P>
5765
5766 For example, if a variable <I>var</I> is declared as local in function
5767 <I>func1</I>, and <I>func1</I> calls another function <I>func2</I>,
5768 references to <I>var</I> made from within <I>func2</I> will resolve to the
5769 local variable <I>var</I> from <I>func1</I>, shadowing any global variable
5770 named <I>var</I>.
5771 <P>
5772
5773 The <B>unset</B> builtin also acts using the same dynamic scope: if a
5774 variable is local to the current scope, <B>unset</B> will unset it;
5775 otherwise the unset will refer to the variable found in any calling scope
5776 as described above.
5777 If a variable at the current local scope is unset, it will remain so
5778 (appearing as unset)
5779 until it is reset in that scope or until the function returns.
5780 Once the function returns, any instance of the variable at a previous
5781 scope will become visible.
5782 If the unset acts on a variable at a previous scope, any instance of a
5783 variable with that name that had been shadowed will become visible
5784 (see below how the <B>localvar_unset</B> shell option changes this behavior).
5785 <P>
5786
5787 The <B>FUNCNEST</B> variable, if set to a numeric value greater
5788 than 0, defines a maximum function nesting level. Function
5789 invocations that exceed the limit cause the entire command to
5790 abort.
5791 <P>
5792
5793 If the builtin command
5794 <B>return</B>
5795
5796 is executed in a function, the function completes and
5797 execution resumes with the next command after the function
5798 call.
5799 Any command associated with the <B>RETURN</B> trap is executed
5800 before execution resumes.
5801 When a function completes, the values of the
5802 positional parameters and the special parameter
5803 <B>#</B>
5804
5805 are restored to the values they had prior to the function's
5806 execution.
5807 <P>
5808
5809 Function names and definitions may be listed with the
5810 <B>-f</B>
5811
5812 option to the
5813 <B>declare</B>
5814
5815 or
5816 <B>typeset</B>
5817
5818 builtin commands. The
5819 <B>-F</B>
5820
5821 option to
5822 <B>declare</B>
5823
5824 or
5825 <B>typeset</B>
5826
5827 will list the function names only
5828 (and optionally the source file and line number, if the <B>extdebug</B>
5829 shell option is enabled).
5830 Functions may be exported so that child shell processes
5831 (those created when executing a separate shell invocation)
5832 automatically have them defined with the
5833 <B>-f</B>
5834
5835 option to the
5836 <B>export</B>
5837
5838 builtin.
5839 A function definition may be deleted using the <B>-f</B> option to
5840 the
5841 <B>unset</B>
5842
5843 builtin.
5844 <P>
5845
5846 Functions may be recursive.
5847 The <B>FUNCNEST</B> variable may be used to limit the depth of the
5848 function call stack and restrict the number of function invocations.
5849 By default, no limit is imposed on the number of recursive calls.
5850 <A NAME="lbBV">&nbsp;</A>
5851 <H3>ARITHMETIC EVALUATION</H3>
5852
5853 The shell allows arithmetic expressions to be evaluated, under
5854 certain circumstances (see the <B>let</B> and <B>declare</B> builtin
5855 commands, the <B>((</B> compound command, and <B>Arithmetic Expansion</B>).
5856 Evaluation is done in fixed-width integers with no check for overflow,
5857 though division by 0 is trapped and flagged as an error.
5858 The operators and their precedence, associativity, and values
5859 are the same as in the C language.
5860 The following list of operators is grouped into levels of
5861 equal-precedence operators.
5862 The levels are listed in order of decreasing precedence.
5863 <P>
5864
5865
5866 <DL COMPACT>
5867 <DT><B></B><I>id</I>++ <I>id</I>--
5868
5869 <DD>
5870 variable post-increment and post-decrement
5871 <DT><B>- +</B>
5872
5873 <DD>
5874 unary minus and plus
5875 <DT><B>++</B><I>id</I> --<I>id</I>
5876
5877 <DD>
5878 variable pre-increment and pre-decrement
5879 <DT><B>! ~</B>
5880
5881 <DD>
5882 logical and bitwise negation
5883 <DT><B>**</B>
5884
5885 <DD>
5886 exponentiation
5887 <DT><B>* / %</B>
5888
5889 <DD>
5890 multiplication, division, remainder
5891 <DT><B>+ -</B>
5892
5893 <DD>
5894 addition, subtraction
5895 <DT><B>&lt;&lt; &gt;&gt;</B>
5896
5897 <DD>
5898 left and right bitwise shifts
5899 <DT><B>&lt;= &gt;= &lt; &gt;</B>
5900
5901 <DD>
5902 comparison
5903 <DT><B>== !=</B>
5904
5905 <DD>
5906 equality and inequality
5907 <DT><B>&amp;</B>
5908
5909 <DD>
5910 bitwise AND
5911 <DT><B>^</B>
5912
5913 <DD>
5914 bitwise exclusive OR
5915 <DT><B>|</B>
5916
5917 <DD>
5918 bitwise OR
5919 <DT><B>&amp;&amp;</B>
5920
5921 <DD>
5922 logical AND
5923 <DT><B>||</B>
5924
5925 <DD>
5926 logical OR
5927 <DT><B></B><I>expr</I>?<I>expr</I>:<I>expr</I>
5928
5929 <DD>
5930 conditional operator
5931 <DT><B>= *= /= %= += -= &lt;&lt;= &gt;&gt;= &amp;= ^= |=</B>
5932
5933 <DD>
5934 assignment
5935 <DT><B></B><I>expr1</I> , <I>expr2</I>
5936
5937 <DD>
5938 comma
5939
5940 </DL>
5941 <P>
5942
5943 Shell variables are allowed as operands; parameter expansion is
5944 performed before the expression is evaluated.
5945 Within an expression, shell variables may also be referenced by name
5946 without using the parameter expansion syntax.
5947 A shell variable that is null or unset evaluates to 0 when referenced
5948 by name without using the parameter expansion syntax.
5949 The value of a variable is evaluated as an arithmetic expression
5950 when it is referenced, or when a variable which has been given the
5951 <I>integer</I> attribute using <B>declare -i</B> is assigned a value.
5952 A null value evaluates to 0.
5953 A shell variable need not have its <I>integer</I> attribute
5954 turned on to be used in an expression.
5955 <P>
5956
5957 Integer constants follow the C language definition, without suffixes or
5958 character constants.
5959 Constants with a leading 0 are interpreted as octal numbers.
5960 A leading 0x or 0X denotes hexadecimal.
5961 Otherwise, numbers take the form [<I>base#</I>]n, where the optional <I>base</I>
5962 is a decimal number between 2 and 64 representing the arithmetic
5963 base, and <I>n</I> is a number in that base.
5964 If <I>base#</I> is omitted, then base 10 is used.
5965 When specifying <I>n</I>,
5966 if a non-digit is required,
5967 the digits greater than 9 are represented by the lowercase letters,
5968 the uppercase letters, @, and _, in that order.
5969 If <I>base</I> is less than or equal to 36, lowercase and uppercase
5970 letters may be used interchangeably to represent numbers between 10
5971 and 35.
5972 <P>
5973
5974 Operators are evaluated in order of precedence. Sub-expressions in
5975 parentheses are evaluated first and may override the precedence
5976 rules above.
5977 <A NAME="lbBW">&nbsp;</A>
5978 <H3>CONDITIONAL EXPRESSIONS</H3>
5979
5980 Conditional expressions are used by the <B>[[</B> compound command and
5981 the <B>test</B> and <B>[</B> builtin commands to test file attributes
5982 and perform string and arithmetic comparisons.
5983 The <B>test</B> and <B>[</B> commands determine their behavior based on
5984 the number of arguments; see the descriptions of those commands for any
5985 other command-specific actions.
5986 <P>
5987
5988 Expressions are formed from the following unary or binary primaries.
5989 <B>Bash</B> handles several filenames specially when they are used in
5990 expressions.
5991 If the operating system on which <B>bash</B> is running provides these
5992 special files, bash will use them; otherwise it will emulate them
5993 internally with this behavior:
5994 If any <I>file</I> argument to one of the primaries is of the form
5995 <I>/dev/fd/n</I>, then file descriptor <I>n</I> is checked.
5996 If the <I>file</I> argument to one of the primaries is one of
5997 <I>/dev/stdin</I>, <I>/dev/stdout</I>, or <I>/dev/stderr</I>, file
5998 descriptor 0, 1, or 2, respectively, is checked.
5999 <P>
6000
6001 Unless otherwise specified, primaries that operate on files follow symbolic
6002 links and operate on the target of the link, rather than the link itself.
6003 <P>
6004
6005
6006 When used with <B>[[</B>, the <B>&lt;</B> and <B>&gt;</B> operators sort
6007 lexicographically using the current locale.
6008 The <B>test</B> command sorts using ASCII ordering.
6009 <P>
6010
6011 <DL COMPACT>
6012 <DT><B>-a </B><I>file</I>
6013
6014 <DD>
6015 True if <I>file</I> exists.
6016 <DT><B>-b </B><I>file</I>
6017
6018 <DD>
6019 True if <I>file</I> exists and is a block special file.
6020 <DT><B>-c </B><I>file</I>
6021
6022 <DD>
6023 True if <I>file</I> exists and is a character special file.
6024 <DT><B>-d </B><I>file</I>
6025
6026 <DD>
6027 True if <I>file</I> exists and is a directory.
6028 <DT><B>-e </B><I>file</I>
6029
6030 <DD>
6031 True if <I>file</I> exists.
6032 <DT><B>-f </B><I>file</I>
6033
6034 <DD>
6035 True if <I>file</I> exists and is a regular file.
6036 <DT><B>-g </B><I>file</I>
6037
6038 <DD>
6039 True if <I>file</I> exists and is set-group-id.
6040 <DT><B>-h </B><I>file</I>
6041
6042 <DD>
6043 True if <I>file</I> exists and is a symbolic link.
6044 <DT><B>-k </B><I>file</I>
6045
6046 <DD>
6047 True if <I>file</I> exists and its ``sticky'' bit is set.
6048 <DT><B>-p </B><I>file</I>
6049
6050 <DD>
6051 True if <I>file</I> exists and is a named pipe (FIFO).
6052 <DT><B>-r </B><I>file</I>
6053
6054 <DD>
6055 True if <I>file</I> exists and is readable.
6056 <DT><B>-s </B><I>file</I>
6057
6058 <DD>
6059 True if <I>file</I> exists and has a size greater than zero.
6060 <DT><B>-t </B><I>fd</I>
6061
6062 <DD>
6063 True if file descriptor
6064 <I>fd</I>
6065
6066 is open and refers to a terminal.
6067 <DT><B>-u </B><I>file</I>
6068
6069 <DD>
6070 True if <I>file</I> exists and its set-user-id bit is set.
6071 <DT><B>-w </B><I>file</I>
6072
6073 <DD>
6074 True if <I>file</I> exists and is writable.
6075 <DT><B>-x </B><I>file</I>
6076
6077 <DD>
6078 True if <I>file</I> exists and is executable.
6079 <DT><B>-G </B><I>file</I>
6080
6081 <DD>
6082 True if <I>file</I> exists and is owned by the effective group id.
6083 <DT><B>-L </B><I>file</I>
6084
6085 <DD>
6086 True if <I>file</I> exists and is a symbolic link.
6087 <DT><B>-N </B><I>file</I>
6088
6089 <DD>
6090 True if <I>file</I> exists and has been modified since it was last read.
6091 <DT><B>-O </B><I>file</I>
6092
6093 <DD>
6094 True if <I>file</I> exists and is owned by the effective user id.
6095 <DT><B>-S </B><I>file</I>
6096
6097 <DD>
6098 True if <I>file</I> exists and is a socket.
6099 <DT><I>file1</I> <B>-ef</B> <I>file2</I><DD>
6100 True if <I>file1</I> and <I>file2</I> refer to the same device and
6101 inode numbers.
6102 <DT><I>file1</I> -<B>nt</B> <I>file2</I><DD>
6103 True if <I>file1</I> is newer (according to modification date) than <I>file2</I>,
6104 or if <I>file1</I> exists and file2 does not.
6105 <DT><I>file1</I> -<B>ot</B> <I>file2</I><DD>
6106 True if <I>file1</I> is older than <I>file2</I>, or if <I>file2</I> exists
6107 and <I>file1</I> does not.
6108 <DT><B>-o </B><I>optname</I>
6109
6110 <DD>
6111 True if the shell option
6112 <I>optname</I>
6113
6114 is enabled.
6115 See the list of options under the description of the
6116 <B>-o</B>
6117
6118 option to the
6119 <B>set</B>
6120
6121 builtin below.
6122 <DT><B>-v </B><I>varname</I>
6123
6124 <DD>
6125 True if the shell variable
6126 <I>varname</I>
6127
6128 is set (has been assigned a value).
6129 <DT><B>-R </B><I>varname</I>
6130
6131 <DD>
6132 True if the shell variable
6133 <I>varname</I>
6134
6135 is set and is a name reference.
6136 <DT><B>-z </B><I>string</I>
6137
6138 <DD>
6139 True if the length of <I>string</I> is zero.
6140 <DT><I>string</I><DD>
6141
6142 <DT><B>-n </B><I>string</I>
6143
6144 <DD>
6145
6146 True if the length of
6147 <I>string</I>
6148
6149 is non-zero.
6150 <DT><I>string1</I> <B>==</B> <I>string2</I><DD>
6151
6152 <DT><I>string1</I> <B>=</B> <I>string2</I><DD>
6153
6154 True if the strings are equal. <B>=</B> should be used
6155 with the <B>test</B> command for POSIX conformance.
6156 When used with the <B>[[</B> command, this performs pattern matching as
6157 described above (<B>Compound Commands</B>).
6158 <DT><I>string1</I> <B>!=</B> <I>string2</I><DD>
6159 True if the strings are not equal.
6160 <DT><I>string1</I> <B>&lt;</B> <I>string2</I><DD>
6161 True if <I>string1</I> sorts before <I>string2</I> lexicographically.
6162 <DT><I>string1</I> <B>&gt;</B> <I>string2</I><DD>
6163 True if <I>string1</I> sorts after <I>string2</I> lexicographically.
6164 <DT><I>arg1</I> <B>OP</B> <I>arg2</I>
6165
6166 <DD>
6167 <FONT SIZE=-1><B>OP</B>
6168
6169 </FONT>
6170 is one of
6171 <B>-eq</B>,
6172
6173 <B>-ne</B>,
6174
6175 <B>-lt</B>,
6176
6177 <B>-le</B>,
6178
6179 <B>-gt</B>,
6180
6181 or
6182 <B>-ge</B>.
6183
6184 These arithmetic binary operators return true if <I>arg1</I>
6185 is equal to, not equal to, less than, less than or equal to,
6186 greater than, or greater than or equal to <I>arg2</I>, respectively.
6187 <I>Arg1</I>
6188
6189 and
6190 <I>arg2</I>
6191
6192 may be positive or negative integers.
6193 When used with the <B>[[</B> command,
6194 <I>Arg1</I>
6195
6196 and
6197 <I>Arg2</I>
6198
6199 are evaluated as arithmetic expressions (see
6200 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
6201
6202 </FONT>
6203 above).
6204
6205 </DL>
6206 <A NAME="lbBX">&nbsp;</A>
6207 <H3>SIMPLE COMMAND EXPANSION</H3>
6208
6209 When a simple command is executed, the shell performs the following
6210 expansions, assignments, and redirections, from left to right, in
6211 the following order.
6212 <DL COMPACT>
6213 <DT>1.<DD>
6214 The words that the parser has marked as variable assignments (those
6215 preceding the command name) and redirections are saved for later
6216 processing.
6217 <DT>2.<DD>
6218 The words that are not variable assignments or redirections are
6219 expanded. If any words remain after expansion, the first word
6220 is taken to be the name of the command and the remaining words are
6221 the arguments.
6222 <DT>3.<DD>
6223 Redirections are performed as described above under
6224 <FONT SIZE=-1><B>REDIRECTION</B>.
6225
6226 </FONT>
6227 <DT>4.<DD>
6228 The text after the <B>=</B> in each variable assignment undergoes tilde
6229 expansion, parameter expansion, command substitution, arithmetic expansion,
6230 and quote removal before being assigned to the variable.
6231 </DL>
6232 <P>
6233
6234 If no command name results, the variable assignments affect the current
6235 shell environment.
6236 In the case of such a command (one that consists only of assignment
6237 statements and redirections), assignment statements are performed before
6238 redirections.
6239 Otherwise, the variables are added to the environment
6240 of the executed command and do not affect the current shell environment.
6241 If any of the assignments attempts to assign a value to a readonly variable,
6242 an error occurs, and the command exits with a non-zero status.
6243 <P>
6244
6245 If no command name results, redirections are performed, but do not
6246 affect the current shell environment. A redirection error causes the
6247 command to exit with a non-zero status.
6248 <P>
6249
6250 If there is a command name left after expansion, execution proceeds as
6251 described below. Otherwise, the command exits. If one of the expansions
6252 contained a command substitution, the exit status of the command is
6253 the exit status of the last command substitution performed. If there
6254 were no command substitutions, the command exits with a status of zero.
6255 <A NAME="lbBY">&nbsp;</A>
6256 <H3>COMMAND EXECUTION</H3>
6257
6258 After a command has been split into words, if it results in a
6259 simple command and an optional list of arguments, the following
6260 actions are taken.
6261 <P>
6262
6263 If the command name contains no slashes, the shell attempts to
6264 locate it. If there exists a shell function by that name, that
6265 function is invoked as described above in
6266 <FONT SIZE=-1><B>FUNCTIONS</B>.
6267
6268 </FONT>
6269 If the name does not match a function, the shell searches for
6270 it in the list of shell builtins. If a match is found, that
6271 builtin is invoked.
6272 <P>
6273
6274 If the name is neither a shell function nor a builtin,
6275 and contains no slashes,
6276 <B>bash</B>
6277
6278 searches each element of the
6279 <FONT SIZE=-1><B>PATH</B>
6280
6281 </FONT>
6282 for a directory containing an executable file by that name.
6283 <B>Bash</B>
6284
6285 uses a hash table to remember the full pathnames of executable
6286 files (see
6287 <B>hash</B>
6288
6289 under
6290 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
6291
6292 </FONT>
6293 below).
6294 A full search of the directories in
6295 <FONT SIZE=-1><B>PATH</B>
6296
6297 </FONT>
6298 is performed only if the command is not found in the hash table.
6299 If the search is unsuccessful, the shell searches for a defined shell
6300 function named <B>command_not_found_handle</B>.
6301 If that function exists, it is invoked in a separate execution environment
6302 with the original command and
6303 the original command's arguments as its arguments, and the function's
6304 exit status becomes the exit status of that subshell.
6305 If that function is not defined, the shell prints an error
6306 message and returns an exit status of 127.
6307 <P>
6308
6309 If the search is successful, or if the command name contains
6310 one or more slashes, the shell executes the named program in a
6311 separate execution environment.
6312 Argument 0 is set to the name given, and the remaining arguments
6313 to the command are set to the arguments given, if any.
6314 <P>
6315
6316 If this execution fails because the file is not in executable
6317 format, and the file is not a directory, it is assumed to be
6318 a <I>shell script</I>, a file
6319 containing shell commands, and the shell creates a
6320 new instance of itself
6321 to execute it.
6322 This subshell reinitializes itself, so
6323 that the effect is as if a new shell had been invoked
6324 to handle the script, with the exception that the locations of
6325 commands remembered by the parent (see
6326 <B>hash</B>
6327
6328 below under
6329 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>)</FONT>
6330 are retained by the child.
6331 <P>
6332
6333 If the program is a file beginning with
6334 <B>#!</B>,
6335
6336 the remainder of the first line specifies an interpreter
6337 for the program. The shell executes the
6338 specified interpreter on operating systems that do not
6339 handle this executable format themselves. The arguments to the
6340 interpreter consist of a single optional argument following the
6341 interpreter name on the first line of the program, followed
6342 by the name of the program, followed by the command
6343 arguments, if any.
6344 <A NAME="lbBZ">&nbsp;</A>
6345 <H3>COMMAND EXECUTION ENVIRONMENT</H3>
6346
6347 The shell has an <I>execution environment</I>, which consists of the
6348 following:
6349 <DL COMPACT>
6350 <DT>*<DD>
6351 open files inherited by the shell at invocation, as modified by
6352 redirections supplied to the <B>exec</B> builtin
6353 <DT>*<DD>
6354 the current working directory as set by <B>cd</B>, <B>pushd</B>, or
6355 <B>popd</B>, or inherited by the shell at invocation
6356 <DT>*<DD>
6357 the file creation mode mask as set by <B>umask</B> or inherited from
6358 the shell's parent
6359 <DT>*<DD>
6360 current traps set by <B>trap</B>
6361 <DT>*<DD>
6362 shell parameters that are set by variable assignment or with <B>set</B>
6363 or inherited from the shell's parent in the environment
6364 <DT>*<DD>
6365 shell functions defined during execution or inherited from the shell's
6366 parent in the environment
6367 <DT>*<DD>
6368 options enabled at invocation (either by default or with command-line
6369 arguments) or by <B>set</B>
6370 <DT>*<DD>
6371 options enabled by <B>shopt</B>
6372 <DT>*<DD>
6373 shell aliases defined with <B>alias</B>
6374 <DT>*<DD>
6375 various process IDs, including those of background jobs, the value
6376 of <B>$$</B>, and the value of
6377 <FONT SIZE=-1><B>PPID</B>
6378
6379 </FONT>
6380 </DL>
6381 <P>
6382
6383 When a simple command other than a builtin or shell function
6384 is to be executed, it
6385 is invoked in a separate execution environment that consists of
6386 the following.
6387 Unless otherwise noted, the values are inherited from the shell.
6388
6389 <DL COMPACT>
6390 <DT>*<DD>
6391 the shell's open files, plus any modifications and additions specified
6392 by redirections to the command
6393 <DT>*<DD>
6394 the current working directory
6395 <DT>*<DD>
6396 the file creation mode mask
6397 <DT>*<DD>
6398 shell variables and functions marked for export, along with variables
6399 exported for the command, passed in the environment
6400 <DT>*<DD>
6401 traps caught by the shell are reset to the values inherited from the
6402 shell's parent, and traps ignored by the shell are ignored
6403 </DL>
6404 <P>
6405
6406 A command invoked in this separate environment cannot affect the
6407 shell's execution environment.
6408 <P>
6409
6410 A <I>subshell</I> is a copy of the shell process.
6411 <P>
6412
6413 Command substitution, commands grouped with parentheses,
6414 and asynchronous commands are invoked in a
6415 subshell environment that is a duplicate of the shell environment,
6416 except that traps caught by the shell are reset to the values
6417 that the shell inherited from its parent at invocation. Builtin
6418 commands that are invoked as part of a pipeline are also executed in a
6419 subshell environment. Changes made to the subshell environment
6420 cannot affect the shell's execution environment.
6421 <P>
6422
6423 Subshells spawned to execute command substitutions inherit the value of
6424 the <B>-e</B> option from the parent shell. When not in <I>posix mode</I>,
6425 <B>bash</B> clears the <B>-e</B> option in such subshells.
6426 <P>
6427
6428 If a command is followed by a <B>&amp;</B> and job control is not active, the
6429 default standard input for the command is the empty file <I>/dev/null</I>.
6430 Otherwise, the invoked command inherits the file descriptors of the calling
6431 shell as modified by redirections.
6432 <A NAME="lbCA">&nbsp;</A>
6433 <H3>ENVIRONMENT</H3>
6434
6435 When a program is invoked it is given an array of strings
6436 called the
6437 <I>environment</I>.
6438
6439 This is a list of
6440 <I>name</I>-<I>value</I> pairs, of the form
6441 <I>name</I>=value.
6442
6443 <P>
6444
6445 The shell provides several ways to manipulate the environment.
6446 On invocation, the shell scans its own environment and
6447 creates a parameter for each name found, automatically marking
6448 it for
6449 <I>export</I>
6450
6451 to child processes. Executed commands inherit the environment.
6452 The
6453 <B>export</B>
6454
6455 and
6456 <B>declare -x</B>
6457
6458 commands allow parameters and functions to be added to and
6459 deleted from the environment. If the value of a parameter
6460 in the environment is modified, the new value becomes part
6461 of the environment, replacing the old. The environment
6462 inherited by any executed command consists of the shell's
6463 initial environment, whose values may be modified in the shell,
6464 less any pairs removed by the
6465 <B>unset</B>
6466
6467 command, plus any additions via the
6468 <B>export</B>
6469
6470 and
6471 <B>declare -x</B>
6472
6473 commands.
6474 <P>
6475
6476 The environment for any
6477 <I>simple command</I>
6478
6479 or function may be augmented temporarily by prefixing it with
6480 parameter assignments, as described above in
6481 <FONT SIZE=-1><B>PARAMETERS</B>.
6482
6483 </FONT>
6484 These assignment statements affect only the environment seen
6485 by that command.
6486 <P>
6487
6488 If the
6489 <B>-k</B>
6490
6491 option is set (see the
6492 <B>set</B>
6493
6494 builtin command below), then
6495 <I>all</I>
6496
6497 parameter assignments are placed in the environment for a command,
6498 not just those that precede the command name.
6499 <P>
6500
6501 When
6502 <B>bash</B>
6503
6504 invokes an external command, the variable
6505 <B>_</B>
6506
6507 is set to the full filename of the command and passed to that
6508 command in its environment.
6509 <A NAME="lbCB">&nbsp;</A>
6510 <H3>EXIT STATUS</H3>
6511
6512 The exit status of an executed command is the value returned by the
6513 <I>waitpid</I> system call or equivalent function. Exit statuses
6514 fall between 0 and 255, though, as explained below, the shell may
6515 use values above 125 specially. Exit statuses from shell builtins and
6516 compound commands are also limited to this range. Under certain
6517 circumstances, the shell will use special values to indicate specific
6518 failure modes.
6519 <P>
6520
6521 For the shell's purposes, a command which exits with a
6522 zero exit status has succeeded. An exit status of zero
6523 indicates success. A non-zero exit status indicates failure.
6524 When a command terminates on a fatal signal <I>N</I>, <B>bash</B> uses
6525 the value of 128+<I>N</I> as the exit status.
6526 <P>
6527
6528 If a command is not found, the child process created to
6529 execute it returns a status of 127. If a command is found
6530 but is not executable, the return status is 126.
6531 <P>
6532
6533 If a command fails because of an error during expansion or redirection,
6534 the exit status is greater than zero.
6535 <P>
6536
6537 Shell builtin commands return a status of 0 (<I>true</I>) if
6538 successful, and non-zero (<I>false</I>) if an error occurs
6539 while they execute.
6540 All builtins return an exit status of 2 to indicate incorrect usage,
6541 generally invalid options or missing arguments.
6542 <P>
6543
6544 The exit status of the last command is available in the special
6545 parameter $?.
6546 <P>
6547
6548 <B>Bash</B> itself returns the exit status of the last command
6549 executed, unless a syntax error occurs, in which case it exits
6550 with a non-zero value. See also the <B>exit</B> builtin
6551 command below.
6552 <A NAME="lbCC">&nbsp;</A>
6553 <H3>SIGNALS</H3>
6554
6555 When <B>bash</B> is interactive, in the absence of any traps, it ignores
6556 <FONT SIZE=-1><B>SIGTERM</B>
6557
6558 </FONT>
6559 (so that <B>kill 0</B> does not kill an interactive shell),
6560 and
6561 <FONT SIZE=-1><B>SIGINT</B>
6562
6563 </FONT>
6564 is caught and handled (so that the <B>wait</B> builtin is interruptible).
6565 In all cases, <B>bash</B> ignores
6566 <FONT SIZE=-1><B>SIGQUIT</B>.
6567
6568 </FONT>
6569 If job control is in effect,
6570 <B>bash</B>
6571
6572 ignores
6573 <FONT SIZE=-1><B>SIGTTIN</B>,
6574
6575 </FONT>
6576 <FONT SIZE=-1><B>SIGTTOU</B>,
6577
6578 </FONT>
6579 and
6580 <FONT SIZE=-1><B>SIGTSTP</B>.
6581
6582 </FONT>
6583 <P>
6584
6585 Non-builtin commands run by <B>bash</B> have signal handlers
6586 set to the values inherited by the shell from its parent.
6587 When job control is not in effect, asynchronous commands
6588 ignore
6589 <FONT SIZE=-1><B>SIGINT</B>
6590
6591 </FONT>
6592 and
6593 <FONT SIZE=-1><B>SIGQUIT</B>
6594
6595 </FONT>
6596 in addition to these inherited handlers.
6597 Commands run as a result of command substitution ignore the
6598 keyboard-generated job control signals
6599 <FONT SIZE=-1><B>SIGTTIN</B>,
6600
6601 </FONT>
6602 <FONT SIZE=-1><B>SIGTTOU</B>,
6603
6604 </FONT>
6605 and
6606 <FONT SIZE=-1><B>SIGTSTP</B>.
6607
6608 </FONT>
6609 <P>
6610
6611 The shell exits by default upon receipt of a
6612 <FONT SIZE=-1><B>SIGHUP</B>.
6613
6614 </FONT>
6615 Before exiting, an interactive shell resends the
6616 <FONT SIZE=-1><B>SIGHUP</B>
6617
6618 </FONT>
6619 to all jobs, running or stopped.
6620 Stopped jobs are sent
6621 <FONT SIZE=-1><B>SIGCONT</B>
6622
6623 </FONT>
6624 to ensure that they receive the
6625 <FONT SIZE=-1><B>SIGHUP</B>.
6626
6627 </FONT>
6628 To prevent the shell from
6629 sending the signal to a particular job, it should be removed from the
6630 jobs table with the
6631 <B>disown</B>
6632
6633 builtin (see
6634 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
6635
6636 </FONT>
6637 below) or marked
6638 to not receive
6639 <FONT SIZE=-1><B>SIGHUP</B>
6640
6641 </FONT>
6642 using
6643 <B>disown -h</B>.
6644
6645 <P>
6646
6647 If the
6648 <B>huponexit</B>
6649
6650 shell option has been set with
6651 <B>shopt</B>,
6652
6653 <B>bash</B>
6654
6655 sends a
6656 <FONT SIZE=-1><B>SIGHUP</B>
6657
6658 </FONT>
6659 to all jobs when an interactive login shell exits.
6660 <P>
6661
6662 If <B>bash</B> is waiting for a command to complete and receives a signal
6663 for which a trap has been set, the trap will not be executed until
6664 the command completes.
6665 When <B>bash</B> is waiting for an asynchronous command via the <B>wait</B>
6666 builtin, the reception of a signal for which a trap has been set will
6667 cause the <B>wait</B> builtin to return immediately with an exit status
6668 greater than 128, immediately after which the trap is executed.
6669 <P>
6670
6671 When job control is not enabled, and <B>bash</B> is waiting for a foreground
6672 command to complete, the shell receives keyboard-generated signals
6673 such as
6674 <FONT SIZE=-1><B>SIGINT</B>
6675
6676 </FONT>
6677 (usually generated by <B>^C</B>) that users commonly intend to send
6678 to that command.
6679 This happens because the shell and the command are in the
6680 same process group as the terminal, and <B>^C</B> sends
6681 <FONT SIZE=-1><B>SIGINT</B>
6682
6683 </FONT>
6684 to all processes in that process group.
6685 <P>
6686
6687 When <B>bash</B> is running without job control enabled and receives
6688 <FONT SIZE=-1><B>SIGINT</B>
6689
6690 </FONT>
6691 while waiting for a foreground command, it waits until that foreground
6692 command terminates and then decides what to do about the
6693 <FONT SIZE=-1><B>SIGINT</B>:
6694
6695 </FONT>
6696 <DL COMPACT>
6697 <DT>1.<DD>
6698 If the command terminates due to the
6699 <FONT SIZE=-1><B>SIGINT</B>,
6700
6701 </FONT>
6702 <B>bash</B> concludes
6703 that the user meant to end the entire script, and acts on the
6704 <FONT SIZE=-1><B>SIGINT</B>
6705
6706 </FONT>
6707 (e.g., by running a
6708 <FONT SIZE=-1><B>SIGINT</B>
6709
6710 </FONT>
6711 trap or exiting itself);
6712 <DT>2.<DD>
6713 If the command does not terminate due to
6714 <FONT SIZE=-1><B>SIGINT</B>,
6715
6716 </FONT>
6717 the program handled the
6718 <FONT SIZE=-1><B>SIGINT</B>
6719
6720 </FONT>
6721 itself and did not treat it as a fatal signal.
6722 In that case, <B>bash</B> does not treat
6723 <FONT SIZE=-1><B>SIGINT</B>
6724
6725 </FONT>
6726 as a fatal signal, either, instead assuming that the
6727 <FONT SIZE=-1><B>SIGINT</B>
6728
6729 </FONT>
6730 was used as part of the program's normal operation
6731 (e.g., emacs uses it to abort editing
6732 commands) or deliberately discarded.
6733 However, <B>bash</B> will run any
6734 trap set on
6735 <FONT SIZE=-1><B>SIGINT</B>,
6736
6737 </FONT>
6738 as it does with any other trapped signal it
6739 receives while it is waiting for the foreground command to
6740 complete, for compatibility.
6741 </DL>
6742 <A NAME="lbCD">&nbsp;</A>
6743 <H3>JOB CONTROL</H3>
6744
6745 <I>Job control</I>
6746
6747 refers to the ability to selectively stop (<I>suspend</I>)
6748 the execution of processes and continue (<I>resume</I>)
6749 their execution at a later point. A user typically employs
6750 this facility via an interactive interface supplied jointly
6751 by the operating system kernel's terminal driver and
6752 <B>bash</B>.
6753
6754 <P>
6755
6756 The shell associates a
6757 <I>job</I>
6758
6759 with each pipeline. It keeps a table of currently executing
6760 jobs, which may be listed with the
6761 <B>jobs</B>
6762
6763 command. When
6764 <B>bash</B>
6765
6766 starts a job asynchronously (in the
6767 <I>background</I>),
6768
6769 it prints a line that looks like:
6770 <DL COMPACT><DT><DD>
6771 <P>
6772
6773 [1] 25647
6774 </DL>
6775
6776 <P>
6777
6778 indicating that this job is job number 1 and that the process ID
6779 of the last process in the pipeline associated with this job is 25647.
6780 All of the processes in a single pipeline are members of the same job.
6781 <B>Bash</B>
6782
6783 uses the
6784 <I>job</I>
6785
6786 abstraction as the basis for job control.
6787 <P>
6788
6789 To facilitate the implementation of the user interface to job
6790 control, the operating system maintains the notion of a <I>current terminal
6791 process group ID</I>. Members of this process group (processes whose
6792 process group ID is equal to the current terminal process group ID)
6793 receive keyboard-generated signals such as
6794 <FONT SIZE=-1><B>SIGINT</B>.
6795
6796 </FONT>
6797 These processes are said to be in the
6798 <I>foreground</I>.
6799
6800 <I>Background</I>
6801
6802 processes are those whose process group ID differs from the terminal's;
6803 such processes are immune to keyboard-generated signals.
6804 Only foreground processes are allowed to read from or, if the
6805 user so specifies with <TT>stty tostop</TT>, write to the
6806 terminal.
6807 Background processes which attempt to read from (write to when
6808 <TT>stty tostop</TT> is in effect) the
6809 terminal are sent a
6810 <FONT SIZE=-1><B>SIGTTIN (SIGTTOU)</B>
6811
6812 </FONT>
6813 signal by the kernel's terminal driver,
6814 which, unless caught, suspends the process.
6815 <P>
6816
6817 If the operating system on which
6818 <B>bash</B>
6819
6820 is running supports
6821 job control,
6822 <B>bash</B>
6823
6824 contains facilities to use it.
6825 Typing the
6826 <I>suspend</I>
6827
6828 character (typically
6829 <B>^Z</B>,
6830
6831 Control-Z) while a process is running
6832 causes that process to be stopped and returns control to
6833 <B>bash</B>.
6834
6835 Typing the
6836 <I>delayed suspend</I>
6837
6838 character (typically
6839 <B>^Y</B>,
6840
6841 Control-Y) causes the process to be stopped when it
6842 attempts to read input from the terminal, and control to
6843 be returned to
6844 <B>bash</B>.
6845
6846 The user may then manipulate the state of this job, using the
6847 <B>bg</B>
6848
6849 command to continue it in the background, the
6850 <B>fg</B>
6851
6852 command to continue it in the foreground, or
6853 the
6854 <B>kill</B>
6855
6856 command to kill it. A <B>^Z</B> takes effect immediately,
6857 and has the additional side effect of causing pending output
6858 and typeahead to be discarded.
6859 <P>
6860
6861 There are a number of ways to refer to a job in the shell.
6862 The character
6863 <B>%</B>
6864
6865 introduces a job specification (<I>jobspec</I>). Job number
6866 <I>n</I>
6867
6868 may be referred to as
6869 <B>%n</B>.
6870
6871 A job may also be referred to using a prefix of the name used to
6872 start it, or using a substring that appears in its command line.
6873 For example,
6874 <B>%ce</B>
6875
6876 refers to a stopped
6877 job whose command name begins with
6878 <B>ce</B>.
6879
6880 If a prefix matches more than one job,
6881 <B>bash</B>
6882
6883 reports an error. Using
6884 <B>%?ce</B>,
6885
6886 on the other hand, refers to any job containing the string
6887 <B>ce</B>
6888
6889 in its command line. If the substring matches more than one job,
6890 <B>bash</B>
6891
6892 reports an error. The symbols
6893 <B>%%</B>
6894
6895 and
6896 <B>%+</B>
6897
6898 refer to the shell's notion of the
6899 <I>current job</I>,
6900
6901 which is the last job stopped while it was in
6902 the foreground or started in the background.
6903 The
6904 <I>previous job</I>
6905
6906 may be referenced using
6907 <B>%-</B>.
6908
6909 If there is only a single job, <B>%+</B> and <B>%-</B> can both be used
6910 to refer to that job.
6911 In output pertaining to jobs (e.g., the output of the
6912 <B>jobs</B>
6913
6914 command), the current job is always flagged with a
6915 <B>+</B>,
6916
6917 and the previous job with a
6918 <B>-</B>.
6919
6920 A single % (with no accompanying job specification) also refers to the
6921 current job.
6922 <P>
6923
6924 Simply naming a job can be used to bring it into the
6925 foreground:
6926 <B>%1</B>
6927
6928 is a synonym for
6929 <B>``fg %1''</B>,
6930 bringing job 1 from the background into the foreground.
6931 Similarly,
6932 <B>``%1 &amp;''</B>
6933
6934 resumes job 1 in the background, equivalent to
6935 <B>``bg %1''</B>.
6936 <P>
6937
6938 The shell learns immediately whenever a job changes state.
6939 Normally,
6940 <B>bash</B>
6941
6942 waits until it is about to print a prompt before reporting
6943 changes in a job's status so as to not interrupt
6944 any other output. If the
6945 <B>-b</B>
6946
6947 option to the
6948 <B>set</B>
6949
6950 builtin command
6951 is enabled,
6952 <B>bash</B>
6953
6954 reports such changes immediately.
6955 Any trap on
6956 <FONT SIZE=-1><B>SIGCHLD</B>
6957
6958 </FONT>
6959 is executed for each child that exits.
6960 <P>
6961
6962 If an attempt to exit
6963 <B>bash</B>
6964
6965 is made while jobs are stopped (or, if the <B>checkjobs</B> shell option has
6966 been enabled using the <B>shopt</B> builtin, running), the shell prints a
6967 warning message, and, if the <B>checkjobs</B> option is enabled, lists the
6968 jobs and their statuses.
6969 The
6970 <B>jobs</B>
6971
6972 command may then be used to inspect their status.
6973 If a second attempt to exit is made without an intervening command,
6974 the shell does not print another warning, and any stopped
6975 jobs are terminated.
6976 <P>
6977
6978 When the shell is waiting for a job or process using the <B>wait</B>
6979 builtin, and job control is enabled, <B>wait</B> will return when the
6980 job changes state. The <B>-f</B> option causes <B>wait</B> to wait
6981 until the job or process terminates before returning.
6982 <A NAME="lbCE">&nbsp;</A>
6983 <H3>PROMPTING</H3>
6984
6985 When executing interactively,
6986 <B>bash</B>
6987
6988 displays the primary prompt
6989 <FONT SIZE=-1><B>PS1</B>
6990
6991 </FONT>
6992 when it is ready to read a command, and the secondary prompt
6993 <FONT SIZE=-1><B>PS2</B>
6994
6995 </FONT>
6996 when it needs more input to complete a command.
6997 <B>Bash</B>
6998
6999 displays
7000 <FONT SIZE=-1><B>PS0</B>
7001
7002 </FONT>
7003 after it reads a command but before executing it.
7004 <B>Bash</B>
7005
7006 displays
7007 <FONT SIZE=-1><B>PS4</B>
7008
7009 </FONT>
7010 as described above
7011 before tracing each command when the <B>-x</B> option is enabled.
7012 <B>Bash</B>
7013
7014 allows these prompt strings to be customized by inserting a number of
7015 backslash-escaped special characters that are decoded as follows:
7016 <DL COMPACT><DT><DD>
7017
7018 <DL COMPACT>
7019 <DT><B>\a</B>
7020
7021 <DD>
7022 an ASCII bell character (07)
7023 <DT><B>\d</B>
7024
7025 <DD>
7026 the date in &quot;Weekday Month Date&quot; format (e.g., &quot;Tue May 26&quot;)
7027 <DT><B>\D{</B><I>format</I>}
7028
7029 <DD>
7030 the <I>format</I> is passed to <I>strftime</I>(3) and the result is inserted
7031 into the prompt string; an empty <I>format</I> results in a locale-specific
7032 time representation. The braces are required
7033 <DT><B>\e</B>
7034
7035 <DD>
7036 an ASCII escape character (033)
7037 <DT><B>\h</B>
7038
7039 <DD>
7040 the hostname up to the first `.'
7041 <DT><B>\H</B>
7042
7043 <DD>
7044 the hostname
7045 <DT><B>\j</B>
7046
7047 <DD>
7048 the number of jobs currently managed by the shell
7049 <DT><B>\l</B>
7050
7051 <DD>
7052 the basename of the shell's terminal device name
7053 <DT><B>\n</B>
7054
7055 <DD>
7056 newline
7057 <DT><B>\r</B>
7058
7059 <DD>
7060 carriage return
7061 <DT><B>\s</B>
7062
7063 <DD>
7064 the name of the shell, the basename of
7065 <B>$0</B>
7066
7067 (the portion following the final slash)
7068 <DT><B>\t</B>
7069
7070 <DD>
7071 the current time in 24-hour HH:MM:SS format
7072 <DT><B>\T</B>
7073
7074 <DD>
7075 the current time in 12-hour HH:MM:SS format
7076 <DT><B>\@</B>
7077
7078 <DD>
7079 the current time in 12-hour am/pm format
7080 <DT><B>\A</B>
7081
7082 <DD>
7083 the current time in 24-hour HH:MM format
7084 <DT><B>\u</B>
7085
7086 <DD>
7087 the username of the current user
7088 <DT><B>\v</B>
7089
7090 <DD>
7091 the version of <B>bash</B> (e.g., 2.00)
7092 <DT><B>\V</B>
7093
7094 <DD>
7095 the release of <B>bash</B>, version + patch level (e.g., 2.00.0)
7096 <DT><B>\w</B>
7097
7098 <DD>
7099 the value of the <B>PWD</B> shell variable (<B>$PWD</B>),
7100 with
7101 <FONT SIZE=-1><B>$HOME</B>
7102
7103 </FONT>
7104 abbreviated with a tilde
7105 (uses the value of the
7106 <FONT SIZE=-1><B>PROMPT_DIRTRIM</B>
7107
7108 </FONT>
7109 variable)
7110 <DT><B>\W</B>
7111
7112 <DD>
7113 the basename of <B>$PWD</B>,
7114 with
7115 <FONT SIZE=-1><B>$HOME</B>
7116
7117 </FONT>
7118 abbreviated with a tilde
7119 <DT><B>\!</B>
7120
7121 <DD>
7122 the history number of this command
7123 <DT><B>\#</B>
7124
7125 <DD>
7126 the command number of this command
7127 <DT><B>\$</B>
7128
7129 <DD>
7130 if the effective UID is 0, a
7131 <B>#</B>,
7132
7133 otherwise a
7134 <B>$</B>
7135
7136 <DT><B>\</B><I>nnn</I>
7137
7138 <DD>
7139 the character corresponding to the octal number <I>nnn</I>
7140 <DT><B>\\</B>
7141
7142 <DD>
7143 a backslash
7144 <DT><B>\[</B>
7145
7146 <DD>
7147 begin a sequence of non-printing characters, which could be used to
7148 embed a terminal control sequence into the prompt
7149 <DT><B>\]</B>
7150
7151 <DD>
7152 end a sequence of non-printing characters
7153
7154 </DL></DL>
7155
7156 <P>
7157
7158 The command number and the history number are usually different:
7159 the history number of a command is its position in the history
7160 list, which may include commands restored from the history file
7161 (see
7162 <FONT SIZE=-1><B>HISTORY</B>
7163
7164 </FONT>
7165 below), while the command number is the position in the sequence
7166 of commands executed during the current shell session.
7167 After the string is decoded, it is expanded via
7168 parameter expansion, command substitution, arithmetic
7169 expansion, and quote removal, subject to the value of the
7170 <B>promptvars</B>
7171
7172 shell option (see the description of the
7173 <B>shopt</B>
7174
7175 command under
7176 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
7177
7178 </FONT>
7179 below).
7180 This can have unwanted side effects if escaped portions of the string
7181 appear within command substitution or contain characters special to
7182 word expansion.
7183 <A NAME="lbCF">&nbsp;</A>
7184 <H3>READLINE</H3>
7185
7186 This is the library that handles reading input when using an interactive
7187 shell, unless the
7188 <B>--noediting</B>
7189
7190 option is given at shell invocation.
7191 Line editing is also used when using the <B>-e</B> option to the
7192 <B>read</B> builtin.
7193 By default, the line editing commands are similar to those of Emacs.
7194 A vi-style line editing interface is also available.
7195 Line editing can be enabled at any time using the
7196 <B>-o emacs</B>
7197
7198 or
7199 <B>-o vi</B>
7200
7201 options to the
7202 <B>set</B>
7203
7204 builtin (see
7205 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
7206
7207 </FONT>
7208 below).
7209 To turn off line editing after the shell is running, use the
7210 <B>+o emacs</B>
7211
7212 or
7213 <B>+o vi</B>
7214
7215 options to the
7216 <B>set</B>
7217
7218 builtin.
7219 <A NAME="lbCG">&nbsp;</A>
7220 <H4>Readline Notation</H4>
7221
7222 In this section, the Emacs-style notation is used to denote
7223 keystrokes. Control keys are denoted by C-<I>key</I>, e.g., C-n
7224 means Control-N. Similarly,
7225 <I>meta</I>
7226
7227 keys are denoted by M-<I>key</I>, so M-x means Meta-X. (On keyboards
7228 without a
7229 <I>meta</I>
7230
7231 key, M-<I>x</I> means ESC <I>x</I>, i.e., press the Escape key
7232 then the
7233 <I>x</I>
7234
7235 key. This makes ESC the <I>meta prefix</I>.
7236 The combination M-C-<I>x</I> means ESC-Control-<I>x</I>,
7237 or press the Escape key
7238 then hold the Control key while pressing the
7239 <I>x</I>
7240
7241 key.)
7242 <P>
7243
7244 Readline commands may be given numeric
7245 <I>arguments</I>,
7246
7247 which normally act as a repeat count.
7248 Sometimes, however, it is the sign of the argument that is significant.
7249 Passing a negative argument to a command that acts in the forward
7250 direction (e.g., <B>kill-line</B>) causes that command to act in a
7251 backward direction.
7252 Commands whose behavior with arguments deviates from this are noted
7253 below.
7254 <P>
7255
7256 When a command is described as <I>killing</I> text, the text
7257 deleted is saved for possible future retrieval
7258 (<I>yanking</I>). The killed text is saved in a
7259 <I>kill ring</I>. Consecutive kills cause the text to be
7260 accumulated into one unit, which can be yanked all at once.
7261 Commands which do not kill text separate the chunks of text
7262 on the kill ring.
7263 <A NAME="lbCH">&nbsp;</A>
7264 <H4>Readline Initialization</H4>
7265
7266 Readline is customized by putting commands in an initialization
7267 file (the <I>inputrc</I> file).
7268 The name of this file is taken from the value of the
7269 <FONT SIZE=-1><B>INPUTRC</B>
7270
7271 </FONT>
7272 variable. If that variable is unset, the default is
7273 <A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>.
7274
7275 If that file does not exist or cannot be read, the ultimate default is
7276 <A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>.
7277
7278 When a program which uses the readline library starts up, the
7279 initialization file is read, and the key bindings and variables
7280 are set.
7281 There are only a few basic constructs allowed in the
7282 readline initialization file.
7283 Blank lines are ignored.
7284 Lines beginning with a <B>#</B> are comments.
7285 Lines beginning with a <B>$</B> indicate conditional constructs.
7286 Other lines denote key bindings and variable settings.
7287 <P>
7288
7289 The default key-bindings may be changed with an
7290 <I>inputrc</I>
7291
7292 file.
7293 Other programs that use this library may add their own commands
7294 and bindings.
7295 <P>
7296
7297 For example, placing
7298 <DL COMPACT><DT><DD>
7299 <P>
7300
7301 M-Control-u: universal-argument
7302 </DL>
7303
7304 or
7305 <DL COMPACT><DT><DD>
7306 C-Meta-u: universal-argument
7307 </DL>
7308
7309 into the
7310 <I>inputrc</I>
7311
7312 would make M-C-u execute the readline command
7313 <I>universal-argument</I>.
7314
7315 <P>
7316
7317 The following symbolic character names are recognized:
7318 <I>RUBOUT</I>,
7319
7320 <I>DEL</I>,
7321
7322 <I>ESC</I>,
7323
7324 <I>LFD</I>,
7325
7326 <I>NEWLINE</I>,
7327
7328 <I>RET</I>,
7329
7330 <I>RETURN</I>,
7331
7332 <I>SPC</I>,
7333
7334 <I>SPACE</I>,
7335
7336 and
7337 <I>TAB</I>.
7338
7339 <P>
7340
7341 In addition to command names, readline allows keys to be bound
7342 to a string that is inserted when the key is pressed (a <I>macro</I>).
7343 <A NAME="lbCI">&nbsp;</A>
7344 <H4>Readline Key Bindings</H4>
7345
7346 The syntax for controlling key bindings in the
7347 <I>inputrc</I>
7348
7349 file is simple. All that is required is the name of the
7350 command or the text of a macro and a key sequence to which
7351 it should be bound. The name may be specified in one of two ways:
7352 as a symbolic key name, possibly with <I>Meta-</I> or <I>Control-</I>
7353 prefixes, or as a key sequence.
7354 <P>
7355
7356 When using the form <B>keyname</B>:<I>function-name</I> or <I>macro</I>,
7357 <I>keyname</I>
7358
7359 is the name of a key spelled out in English. For example:
7360 <P>
7361 <DL COMPACT><DT><DD>
7362 Control-u: universal-argument
7363 <BR>
7364
7365 Meta-Rubout: backward-kill-word
7366 <BR>
7367
7368 Control-o: &quot;&gt; output&quot;
7369 </DL>
7370
7371 <P>
7372
7373 In the above example,
7374 <I>C-u</I>
7375
7376 is bound to the function
7377 <B>universal-argument</B>,
7378
7379 <I>M-DEL</I>
7380
7381 is bound to the function
7382 <B>backward-kill-word</B>,
7383
7384 and
7385 <I>C-o</I>
7386
7387 is bound to run the macro
7388 expressed on the right hand side (that is, to insert the text
7389 <TT>&gt; output</TT>
7390
7391 into the line).
7392 <P>
7393
7394 In the second form, <B>&quot;keyseq&quot;</B>:<I>function-name</I> or <I>macro</I>,
7395 <B>keyseq</B>
7396
7397 differs from
7398 <B>keyname</B>
7399
7400 above in that strings denoting
7401 an entire key sequence may be specified by placing the sequence
7402 within double quotes. Some GNU Emacs style key escapes can be
7403 used, as in the following example, but the symbolic character names
7404 are not recognized.
7405 <P>
7406 <DL COMPACT><DT><DD>
7407 &quot;\C-u&quot;: universal-argument
7408 <BR>
7409
7410 &quot;\C-x\C-r&quot;: re-read-init-file
7411 <BR>
7412
7413 &quot;\e[11~&quot;: &quot;Function Key 1&quot;
7414 </DL>
7415
7416 <P>
7417
7418 In this example,
7419 <I>C-u</I>
7420
7421 is again bound to the function
7422 <B>universal-argument</B>.
7423
7424 <I>C-x C-r</I>
7425
7426 is bound to the function
7427 <B>re-read-init-file</B>,
7428
7429 and
7430 <I>ESC [ 1 1 ~</I>
7431
7432 is bound to insert the text
7433 <TT>Function Key 1</TT>.
7434
7435 <P>
7436
7437 The full set of GNU Emacs style escape sequences is
7438 <DL COMPACT><DT><DD>
7439
7440 <DL COMPACT>
7441 <DT><B>\C-</B>
7442
7443 <DD>
7444 control prefix
7445 <DT><B>\M-</B>
7446
7447 <DD>
7448 meta prefix
7449 <DT><B>\e</B>
7450
7451 <DD>
7452 an escape character
7453 <DT><B>\\</B>
7454
7455 <DD>
7456 backslash
7457 <DT><B>\</B>
7458
7459 <DD>
7460 literal &quot;
7461 <DT><B>\aq</B>
7462
7463 <DD>
7464 literal aq
7465 </DL></DL>
7466
7467
7468 <P>
7469
7470 In addition to the GNU Emacs style escape sequences, a second
7471 set of backslash escapes is available:
7472 <DL COMPACT><DT><DD>
7473
7474 <DL COMPACT>
7475 <DT><B>\a</B>
7476
7477 <DD>
7478 alert (bell)
7479 <DT><B>\b</B>
7480
7481 <DD>
7482 backspace
7483 <DT><B>\d</B>
7484
7485 <DD>
7486 delete
7487 <DT><B>\f</B>
7488
7489 <DD>
7490 form feed
7491 <DT><B>\n</B>
7492
7493 <DD>
7494 newline
7495 <DT><B>\r</B>
7496
7497 <DD>
7498 carriage return
7499 <DT><B>\t</B>
7500
7501 <DD>
7502 horizontal tab
7503 <DT><B>\v</B>
7504
7505 <DD>
7506 vertical tab
7507 <DT><B>\</B><I>nnn</I>
7508
7509 <DD>
7510 the eight-bit character whose value is the octal value <I>nnn</I>
7511 (one to three digits)
7512 <DT><B>\x</B><I>HH</I>
7513
7514 <DD>
7515 the eight-bit character whose value is the hexadecimal value <I>HH</I>
7516 (one or two hex digits)
7517 </DL></DL>
7518
7519
7520 <P>
7521
7522 When entering the text of a macro, single or double quotes must
7523 be used to indicate a macro definition.
7524 Unquoted text is assumed to be a function name.
7525 In the macro body, the backslash escapes described above are expanded.
7526 Backslash will quote any other character in the macro text,
7527 including &quot; and aq.
7528 <P>
7529
7530 <B>Bash</B>
7531
7532 allows the current readline key bindings to be displayed or modified
7533 with the
7534 <B>bind</B>
7535
7536 builtin command. The editing mode may be switched during interactive
7537 use by using the
7538 <B>-o</B>
7539
7540 option to the
7541 <B>set</B>
7542
7543 builtin command (see
7544 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
7545
7546 </FONT>
7547 below).
7548 <A NAME="lbCJ">&nbsp;</A>
7549 <H4>Readline Variables</H4>
7550
7551 Readline has variables that can be used to further customize its
7552 behavior. A variable may be set in the
7553 <I>inputrc</I>
7554
7555 file with a statement of the form
7556 <DL COMPACT><DT><DD>
7557 <P>
7558
7559 <B>set</B> <I>variable-name</I> <I>value</I>
7560 </DL>
7561
7562 or using the <B>bind</B> builtin command (see
7563 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
7564
7565 </FONT>
7566 below).
7567 <P>
7568
7569 Except where noted, readline variables can take the values
7570 <B>On</B>
7571
7572 or
7573 <B>Off</B>
7574
7575 (without regard to case).
7576 Unrecognized variable names are ignored.
7577 When a variable value is read, empty or null values, &quot;on&quot; (case-insensitive),
7578 and &quot;1&quot; are equivalent to <B>On</B>. All other values are equivalent to
7579 <B>Off</B>.
7580 The variables and their default values are:
7581 <P>
7582
7583
7584 <DL COMPACT>
7585 <DT><B>active-region-start-color </B>
7586
7587 <DD>
7588 A string variable that controls the text color and background when displaying
7589 the text in the active region (see the description of
7590 <B>enable-active-region</B> below).
7591 This string must not take up any physical character positions on the display,
7592 so it should consist only of terminal escape sequences.
7593 It is output to the terminal before displaying the text in the active region.
7594 This variable is reset to the default value whenever the terminal type changes.
7595 The default value is the string that puts the terminal in standout mode,
7596 as obtained from the terminal's terminfo description.
7597 A sample value might be <TT>&quot;\e[01;33m&quot;</TT>.
7598 <DT><B>active-region-end-color </B>
7599
7600 <DD>
7601 A string variable that &quot;undoes&quot; the effects of <B>active-region-start-color</B>
7602 and restores &quot;normal&quot; terminal display appearance after displaying text
7603 in the active region.
7604 This string must not take up any physical character positions on the display,
7605 so it should consist only of terminal escape sequences.
7606 It is output to the terminal after displaying the text in the active region.
7607 This variable is reset to the default value whenever the terminal type changes.
7608 The default value is the string that restores the terminal from standout mode,
7609 as obtained from the terminal's terminfo description.
7610 A sample value might be <TT>&quot;\e[0m&quot;</TT>.
7611 <DT><B>bell-style (audible)</B>
7612
7613 <DD>
7614 Controls what happens when readline wants to ring the terminal bell.
7615 If set to <B>none</B>, readline never rings the bell. If set to
7616 <B>visible</B>, readline uses a visible bell if one is available.
7617 If set to <B>audible</B>, readline attempts to ring the terminal's bell.
7618 <DT><B>bind-tty-special-chars (On)</B>
7619
7620 <DD>
7621 If set to <B>On</B>, readline attempts to bind the control characters
7622 treated specially by the kernel's terminal driver to their readline
7623 equivalents.
7624 <DT><B>blink-matching-paren (Off)</B>
7625
7626 <DD>
7627 If set to <B>On</B>, readline attempts to briefly move the cursor to an
7628 opening parenthesis when a closing parenthesis is inserted.
7629 <DT><B>colored-completion-prefix (Off)</B>
7630
7631 <DD>
7632 If set to <B>On</B>, when listing completions, readline displays the
7633 common prefix of the set of possible completions using a different color.
7634 The color definitions are taken from the value of the <B>LS_COLORS</B>
7635 environment variable.
7636 If there is a color definition in <B>$LS_COLORS</B> for the custom suffix
7637 &quot;readline-colored-completion-prefix&quot;, readline uses this color for
7638 the common prefix instead of its default.
7639 <DT><B>colored-stats (Off)</B>
7640
7641 <DD>
7642 If set to <B>On</B>, readline displays possible completions using different
7643 colors to indicate their file type.
7644 The color definitions are taken from the value of the <B>LS_COLORS</B>
7645 environment variable.
7646 <DT><B>comment-begin (``#'')</B>
7647
7648 <DD>
7649 The string that is inserted when the readline
7650 <B>insert-comment</B>
7651
7652 command is executed.
7653 This command is bound to
7654 <B>M-#</B>
7655
7656 in emacs mode and to
7657 <B>#</B>
7658
7659 in vi command mode.
7660 <DT><B>completion-display-width (-1)</B>
7661
7662 <DD>
7663 The number of screen columns used to display possible matches
7664 when performing completion.
7665 The value is ignored if it is less than 0 or greater than the terminal
7666 screen width.
7667 A value of 0 will cause matches to be displayed one per line.
7668 The default value is -1.
7669 <DT><B>completion-ignore-case (Off)</B>
7670
7671 <DD>
7672 If set to <B>On</B>, readline performs filename matching and completion
7673 in a case-insensitive fashion.
7674 <DT><B>completion-map-case (Off)</B>
7675
7676 <DD>
7677 If set to <B>On</B>, and <B>completion-ignore-case</B> is enabled, readline
7678 treats hyphens (<I>-</I>) and underscores (<I>_</I>) as equivalent when
7679 performing case-insensitive filename matching and completion.
7680 <DT><B>completion-prefix-display-length (0)</B>
7681
7682 <DD>
7683 The length in characters of the common prefix of a list of possible
7684 completions that is displayed without modification. When set to a
7685 value greater than zero, common prefixes longer than this value are
7686 replaced with an ellipsis when displaying possible completions.
7687 <DT><B>completion-query-items (100)</B>
7688
7689 <DD>
7690 This determines when the user is queried about viewing
7691 the number of possible completions
7692 generated by the <B>possible-completions</B> command.
7693 It may be set to any integer value greater than or equal to zero.
7694 If the number of possible completions is greater than
7695 or equal to the value of this variable,
7696 readline will ask whether or not the user wishes to view them;
7697 otherwise they are simply listed on the terminal.
7698 A zero value means readline should never ask; negative values are
7699 treated as zero.
7700 <DT><B>convert-meta (On)</B>
7701
7702 <DD>
7703 If set to <B>On</B>, readline will convert characters with the
7704 eighth bit set to an ASCII key sequence
7705 by stripping the eighth bit and prefixing an
7706 escape character (in effect, using escape as the <I>meta prefix</I>).
7707 The default is <I>On</I>, but readline will set it to <I>Off</I> if the
7708 locale contains eight-bit characters.
7709 This variable is dependent on the <B>LC_CTYPE</B> locale category, and
7710 may change if the locale is changed.
7711 <DT><B>disable-completion (Off)</B>
7712
7713 <DD>
7714 If set to <B>On</B>, readline will inhibit word completion. Completion
7715 characters will be inserted into the line as if they had been
7716 mapped to <B>self-insert</B>.
7717 <DT><B>echo-control-characters (On)</B>
7718
7719 <DD>
7720 When set to <B>On</B>, on operating systems that indicate they support it,
7721 readline echoes a character corresponding to a signal generated from the
7722 keyboard.
7723 <DT><B>editing-mode (emacs)</B>
7724
7725 <DD>
7726 Controls whether readline begins with a set of key bindings similar
7727 to <I>Emacs</I> or <I>vi</I>.
7728 <B>editing-mode</B>
7729
7730 can be set to either
7731 <B>emacs</B>
7732
7733 or
7734 <B>vi</B>.
7735
7736 <DT><B>emacs-mode-string (@)</B>
7737
7738 <DD>
7739 If the <I>show-mode-in-prompt</I> variable is enabled,
7740 this string is displayed immediately before the last line of the primary
7741 prompt when emacs editing mode is active. The value is expanded like a
7742 key binding, so the standard set of meta- and control prefixes and
7743 backslash escape sequences is available.
7744 Use the \1 and \2 escapes to begin and end sequences of
7745 non-printing characters, which can be used to embed a terminal control
7746 sequence into the mode string.
7747 <DT><B>enable-active-region (On)</B>
7748
7749 <DD>
7750 The <I>point</I> is the current cursor position, and <I>mark</I> refers
7751 to a saved cursor position.
7752 The text between the point and mark is referred to as the <I>region</I>.
7753 When this variable is set to <I>On</I>, readline allows certain commands
7754 to designate the region as <I>active</I>.
7755 When the region is active, readline highlights the text in the region using
7756 the value of the <B>active-region-start-color</B>, which defaults to the
7757 string that enables
7758 the terminal's standout mode.
7759 The active region shows the text inserted by bracketed-paste and any
7760 matching text found by incremental and non-incremental history searches.
7761 <DT><B>enable-bracketed-paste (On)</B>
7762
7763 <DD>
7764 When set to <B>On</B>, readline configures the terminal to insert each
7765 paste into the editing buffer as a single string of characters, instead
7766 of treating each character as if it had been read from the keyboard.
7767 This prevents readline from executing any editing commands bound to key
7768 sequences appearing in the pasted text.
7769 <DT><B>enable-keypad (Off)</B>
7770
7771 <DD>
7772 When set to <B>On</B>, readline will try to enable the application
7773 keypad when it is called. Some systems need this to enable the
7774 arrow keys.
7775 <DT><B>enable-meta-key (On)</B>
7776
7777 <DD>
7778 When set to <B>On</B>, readline will try to enable any meta modifier
7779 key the terminal claims to support when it is called. On many terminals,
7780 the meta key is used to send eight-bit characters.
7781 <DT><B>expand-tilde (Off)</B>
7782
7783 <DD>
7784 If set to <B>On</B>, tilde expansion is performed when readline
7785 attempts word completion.
7786 <DT><B>history-preserve-point (Off)</B>
7787
7788 <DD>
7789 If set to <B>On</B>, the history code attempts to place point at the
7790 same location on each history line retrieved with <B>previous-history</B>
7791 or <B>next-history</B>.
7792 <DT><B>history-size (unset)</B>
7793
7794 <DD>
7795 Set the maximum number of history entries saved in the history list.
7796 If set to zero, any existing history entries are deleted and no new entries
7797 are saved.
7798 If set to a value less than zero, the number of history entries is not
7799 limited.
7800 By default, the number of history entries is set to the value of the
7801 <B>HISTSIZE</B> shell variable.
7802 If an attempt is made to set <I>history-size</I> to a non-numeric value,
7803 the maximum number of history entries will be set to 500.
7804 <DT><B>horizontal-scroll-mode (Off)</B>
7805
7806 <DD>
7807 When set to <B>On</B>, makes readline use a single line for display,
7808 scrolling the input horizontally on a single screen line when it
7809 becomes longer than the screen width rather than wrapping to a new line.
7810 This setting is automatically enabled for terminals of height 1.
7811 <DT><B>input-meta (Off)</B>
7812
7813 <DD>
7814 If set to <B>On</B>, readline will enable eight-bit input (that is,
7815 it will not strip the eighth bit from the characters it reads),
7816 regardless of what the terminal claims it can support. The name
7817 <B>meta-flag</B>
7818
7819 is a synonym for this variable.
7820 The default is <I>Off</I>, but readline will set it to <I>On</I> if the
7821 locale contains eight-bit characters.
7822 This variable is dependent on the <B>LC_CTYPE</B> locale category, and
7823 may change if the locale is changed.
7824 <DT><B>isearch-terminators (``C-[C-J'')</B>
7825
7826 <DD>
7827 The string of characters that should terminate an incremental
7828 search without subsequently executing the character as a command.
7829 If this variable has not been given a value, the characters
7830 <I>ESC</I> and <I>C-J</I> will terminate an incremental search.
7831 <DT><B>keymap (emacs)</B>
7832
7833 <DD>
7834 Set the current readline keymap. The set of valid keymap names is
7835 <I>emacs, emacs-standard, emacs-meta, emacs-ctlx, vi,
7836 vi-command</I>, and
7837 <I>vi-insert</I>.
7838
7839 <I>vi</I> is equivalent to <I>vi-command</I>; <I>emacs</I> is
7840 equivalent to <I>emacs-standard</I>. The default value is
7841 <I>emacs</I>;
7842
7843 the value of
7844 <B>editing-mode</B>
7845
7846 also affects the default keymap.
7847 <DT><B>keyseq-timeout (500)</B>
7848
7849 <DD>
7850 Specifies the duration <I>readline</I> will wait for a character when reading an
7851 ambiguous key sequence (one that can form a complete key sequence using
7852 the input read so far, or can take additional input to complete a longer
7853 key sequence).
7854 If no input is received within the timeout, <I>readline</I> will use the shorter
7855 but complete key sequence.
7856 The value is specified in milliseconds, so a value of 1000 means that
7857 <I>readline</I> will wait one second for additional input.
7858 If this variable is set to a value less than or equal to zero, or to a
7859 non-numeric value, <I>readline</I> will wait until another key is pressed to
7860 decide which key sequence to complete.
7861 <DT><B>mark-directories (On)</B>
7862
7863 <DD>
7864 If set to <B>On</B>, completed directory names have a slash
7865 appended.
7866 <DT><B>mark-modified-lines (Off)</B>
7867
7868 <DD>
7869 If set to <B>On</B>, history lines that have been modified are displayed
7870 with a preceding asterisk (<B>*</B>).
7871 <DT><B>mark-symlinked-directories (Off)</B>
7872
7873 <DD>
7874 If set to <B>On</B>, completed names which are symbolic links to directories
7875 have a slash appended (subject to the value of
7876 <B>mark-directories</B>).
7877 <DT><B>match-hidden-files (On)</B>
7878
7879 <DD>
7880 This variable, when set to <B>On</B>, causes readline to match files whose
7881 names begin with a `.' (hidden files) when performing filename
7882 completion.
7883 If set to <B>Off</B>, the leading `.' must be
7884 supplied by the user in the filename to be completed.
7885 <DT><B>menu-complete-display-prefix (Off)</B>
7886
7887 <DD>
7888 If set to <B>On</B>, menu completion displays the common prefix of the
7889 list of possible completions (which may be empty) before cycling through
7890 the list.
7891 <DT><B>output-meta (Off)</B>
7892
7893 <DD>
7894 If set to <B>On</B>, readline will display characters with the
7895 eighth bit set directly rather than as a meta-prefixed escape
7896 sequence.
7897 The default is <I>Off</I>, but readline will set it to <I>On</I> if the
7898 locale contains eight-bit characters.
7899 This variable is dependent on the <B>LC_CTYPE</B> locale category, and
7900 may change if the locale is changed.
7901 <DT><B>page-completions (On)</B>
7902
7903 <DD>
7904 If set to <B>On</B>, readline uses an internal <I>more</I>-like pager
7905 to display a screenful of possible completions at a time.
7906 <DT><B>print-completions-horizontally (Off)</B>
7907
7908 <DD>
7909 If set to <B>On</B>, readline will display completions with matches
7910 sorted horizontally in alphabetical order, rather than down the screen.
7911 <DT><B>revert-all-at-newline (Off)</B>
7912
7913 <DD>
7914 If set to <B>On</B>, readline will undo all changes to history lines
7915 before returning when <B>accept-line</B> is executed. By default,
7916 history lines may be modified and retain individual undo lists across
7917 calls to <B>readline</B>.
7918 <DT><B>show-all-if-ambiguous (Off)</B>
7919
7920 <DD>
7921 This alters the default behavior of the completion functions. If
7922 set to
7923 <B>On</B>,
7924
7925 words which have more than one possible completion cause the
7926 matches to be listed immediately instead of ringing the bell.
7927 <DT><B>show-all-if-unmodified (Off)</B>
7928
7929 <DD>
7930 This alters the default behavior of the completion functions in
7931 a fashion similar to <B>show-all-if-ambiguous</B>.
7932 If set to
7933 <B>On</B>,
7934
7935 words which have more than one possible completion without any
7936 possible partial completion (the possible completions don't share
7937 a common prefix) cause the matches to be listed immediately instead
7938 of ringing the bell.
7939 <DT><B>show-mode-in-prompt (Off)</B>
7940
7941 <DD>
7942 If set to <B>On</B>, add a string to the beginning of the prompt
7943 indicating the editing mode: emacs, vi command, or vi insertion.
7944 The mode strings are user-settable (e.g., <I>emacs-mode-string</I>).
7945 <DT><B>skip-completed-text (Off)</B>
7946
7947 <DD>
7948 If set to <B>On</B>, this alters the default completion behavior when
7949 inserting a single match into the line. It's only active when
7950 performing completion in the middle of a word. If enabled, readline
7951 does not insert characters from the completion that match characters
7952 after point in the word being completed, so portions of the word
7953 following the cursor are not duplicated.
7954 <DT><B>vi-cmd-mode-string ((cmd))</B>
7955
7956 <DD>
7957 If the <I>show-mode-in-prompt</I> variable is enabled,
7958 this string is displayed immediately before the last line of the primary
7959 prompt when vi editing mode is active and in command mode.
7960 The value is expanded like a
7961 key binding, so the standard set of meta- and control prefixes and
7962 backslash escape sequences is available.
7963 Use the \1 and \2 escapes to begin and end sequences of
7964 non-printing characters, which can be used to embed a terminal control
7965 sequence into the mode string.
7966 <DT><B>vi-ins-mode-string ((ins))</B>
7967
7968 <DD>
7969 If the <I>show-mode-in-prompt</I> variable is enabled,
7970 this string is displayed immediately before the last line of the primary
7971 prompt when vi editing mode is active and in insertion mode.
7972 The value is expanded like a
7973 key binding, so the standard set of meta- and control prefixes and
7974 backslash escape sequences is available.
7975 Use the \1 and \2 escapes to begin and end sequences of
7976 non-printing characters, which can be used to embed a terminal control
7977 sequence into the mode string.
7978 <DT><B>visible-stats (Off)</B>
7979
7980 <DD>
7981 If set to <B>On</B>, a character denoting a file's type as reported
7982 by <I>stat</I>(2) is appended to the filename when listing possible
7983 completions.
7984
7985 </DL>
7986 <A NAME="lbCK">&nbsp;</A>
7987 <H4>Readline Conditional Constructs</H4>
7988
7989 Readline implements a facility similar in spirit to the conditional
7990 compilation features of the C preprocessor which allows key
7991 bindings and variable settings to be performed as the result
7992 of tests. There are four parser directives used.
7993 <DL COMPACT>
7994 <DT><B>$if</B><DD>
7995 The
7996 <B>$if</B>
7997
7998 construct allows bindings to be made based on the
7999 editing mode, the terminal being used, or the application using
8000 readline. The text of the test, after any comparison operator,
8001 <BR>&nbsp;extends&nbsp;to&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;line;
8002 unless otherwise noted, no characters are required to isolate it.
8003 <DL COMPACT><DT><DD>
8004 <DL COMPACT>
8005 <DT><B>mode</B><DD>
8006 The <B>mode=</B> form of the <B>$if</B> directive is used to test
8007 whether readline is in emacs or vi mode.
8008 This may be used in conjunction
8009 with the <B>set keymap</B> command, for instance, to set bindings in
8010 the <I>emacs-standard</I> and <I>emacs-ctlx</I> keymaps only if
8011 readline is starting out in emacs mode.
8012 <DT><B>term</B><DD>
8013 The <B>term=</B> form may be used to include terminal-specific
8014 key bindings, perhaps to bind the key sequences output by the
8015 terminal's function keys. The word on the right side of the
8016 <B>=</B>
8017
8018 is tested against both the full name of the terminal and the portion
8019 of the terminal name before the first <B>-</B>. This allows
8020 <I>sun</I>
8021
8022 to match both
8023 <I>sun</I>
8024
8025 and
8026 <I>sun-cmd</I>,
8027
8028 for instance.
8029 <DT><B>version</B><DD>
8030 The <B>version</B> test may be used to perform comparisons against
8031 specific readline versions.
8032 The <B>version</B> expands to the current readline version.
8033 The set of comparison operators includes
8034 <B>=</B>,
8035
8036 (and
8037 <B>==</B>),
8038
8039 <B>!=</B>,
8040
8041 <B>&lt;=</B>,
8042
8043 <B>&gt;=</B>,
8044
8045 <B>&lt;</B>,
8046
8047 and
8048 <B>&gt;</B>.
8049
8050 The version number supplied on the right side of the operator consists
8051 of a major version number, an optional decimal point, and an optional
8052 minor version (e.g., <B>7.1</B>). If the minor version is omitted, it
8053 is assumed to be <B>0</B>.
8054 The operator may be separated from the string <B>version</B>
8055 and from the version number argument by whitespace.
8056 <DT><B>application</B><DD>
8057 The <B>application</B> construct is used to include
8058 application-specific settings. Each program using the readline
8059 library sets the <I>application name</I>, and an initialization
8060 file can test for a particular value.
8061 This could be used to bind key sequences to functions useful for
8062 a specific program. For instance, the following command adds a
8063 key sequence that quotes the current or previous word in <B>bash</B>:
8064 <P>
8065 <DL COMPACT><DT><DD>
8066 <PRE>
8067 <B>$if</B> Bash
8068 # Quote the current or previous word
8069 &quot;\C-xq&quot;: &quot;\eb\&quot;\ef\&quot;&quot;
8070 <B>$endif</B>
8071 </PRE>
8072
8073 </DL>
8074
8075 <DT><I>variable</I><DD>
8076 The <I>variable</I> construct provides simple equality tests for readline
8077 variables and values.
8078 The permitted comparison operators are <I>=</I>, <I>==</I>, and <I>!=</I>.
8079 The variable name must be separated from the comparison operator by
8080 whitespace; the operator may be separated from the value on the right hand
8081 side by whitespace.
8082 Both string and boolean variables may be tested. Boolean variables must be
8083 tested against the values <I>on</I> and <I>off</I>.
8084 </DL></DL>
8085
8086 <DT><B>$endif</B><DD>
8087 This command, as seen in the previous example, terminates an
8088 <B>$if</B> command.
8089 <DT><B>$else</B><DD>
8090 Commands in this branch of the <B>$if</B> directive are executed if
8091 the test fails.
8092 <DT><B>$include</B><DD>
8093 This directive takes a single filename as an argument and reads commands
8094 and bindings from that file. For example, the following directive
8095 would read <A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>:
8096 <P>
8097 <DL COMPACT><DT><DD>
8098 <PRE>
8099 <B>$include</B> <A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>
8100 </PRE>
8101
8102 </DL>
8103
8104 </DL>
8105 <A NAME="lbCL">&nbsp;</A>
8106 <H4>Searching</H4>
8107
8108 Readline provides commands for searching through the command history
8109 (see
8110 <FONT SIZE=-1><B>HISTORY</B>
8111
8112 </FONT>
8113 below) for lines containing a specified string.
8114 There are two search modes:
8115 <I>incremental</I>
8116
8117 and
8118 <I>non-incremental</I>.
8119
8120 <P>
8121
8122 Incremental searches begin before the user has finished typing the
8123 search string.
8124 As each character of the search string is typed, readline displays
8125 the next entry from the history matching the string typed so far.
8126 An incremental search requires only as many characters as needed to
8127 find the desired history entry.
8128 The characters present in the value of the <B>isearch-terminators</B>
8129 variable are used to terminate an incremental search.
8130 If that variable has not been assigned a value the Escape and
8131 Control-J characters will terminate an incremental search.
8132 Control-G will abort an incremental search and restore the original
8133 line.
8134 When the search is terminated, the history entry containing the
8135 search string becomes the current line.
8136 <P>
8137
8138 To find other matching entries in the history list, type Control-S or
8139 Control-R as appropriate.
8140 This will search backward or forward in the history for the next
8141 entry matching the search string typed so far.
8142 Any other key sequence bound to a readline command will terminate
8143 the search and execute that command.
8144 For instance, a <I>newline</I> will terminate the search and accept
8145 the line, thereby executing the command from the history list.
8146 <P>
8147
8148 Readline remembers the last incremental search string. If two
8149 Control-Rs are typed without any intervening characters defining a
8150 new search string, any remembered search string is used.
8151 <P>
8152
8153 Non-incremental searches read the entire search string before starting
8154 to search for matching history lines. The search string may be
8155 typed by the user or be part of the contents of the current line.
8156 <A NAME="lbCM">&nbsp;</A>
8157 <H4>Readline Command Names</H4>
8158
8159 The following is a list of the names of the commands and the default
8160 key sequences to which they are bound.
8161 Command names without an accompanying key sequence are unbound by default.
8162 In the following descriptions, <I>point</I> refers to the current cursor
8163 position, and <I>mark</I> refers to a cursor position saved by the
8164 <B>set-mark</B> command.
8165 The text between the point and mark is referred to as the <I>region</I>.
8166 <A NAME="lbCN">&nbsp;</A>
8167 <H4>Commands for Moving</H4>
8168
8169
8170 <DL COMPACT>
8171 <DT><B>beginning-of-line (C-a)</B>
8172
8173 <DD>
8174 Move to the start of the current line.
8175 <DT><B>end-of-line (C-e)</B>
8176
8177 <DD>
8178 Move to the end of the line.
8179 <DT><B>forward-char (C-f)</B>
8180
8181 <DD>
8182 Move forward a character.
8183 <DT><B>backward-char (C-b)</B>
8184
8185 <DD>
8186 Move back a character.
8187 <DT><B>forward-word (M-f)</B>
8188
8189 <DD>
8190 Move forward to the end of the next word. Words are composed of
8191 alphanumeric characters (letters and digits).
8192 <DT><B>backward-word (M-b)</B>
8193
8194 <DD>
8195 Move back to the start of the current or previous word.
8196 Words are composed of alphanumeric characters (letters and digits).
8197 <DT><B>shell-forward-word</B>
8198
8199 <DD>
8200 Move forward to the end of the next word.
8201 Words are delimited by non-quoted shell metacharacters.
8202 <DT><B>shell-backward-word</B>
8203
8204 <DD>
8205 Move back to the start of the current or previous word.
8206 Words are delimited by non-quoted shell metacharacters.
8207 <DT><B>previous-screen-line</B>
8208
8209 <DD>
8210 Attempt to move point to the same physical screen column on the previous
8211 physical screen line. This will not have the desired effect if the current
8212 readline line does not take up more than one physical line or if point is not
8213 greater than the length of the prompt plus the screen width.
8214 <DT><B>next-screen-line</B>
8215
8216 <DD>
8217 Attempt to move point to the same physical screen column on the next
8218 physical screen line. This will not have the desired effect if the current
8219 readline line does not take up more than one physical line or if the length
8220 of the current readline line is not greater than the length of the prompt
8221 plus the screen width.
8222 <DT><B>clear-display (M-C-l)</B>
8223
8224 <DD>
8225 Clear the screen and, if possible, the terminal's scrollback buffer,
8226 then redraw the current line,
8227 leaving the current line at the top of the screen.
8228 <DT><B>clear-screen (C-l)</B>
8229
8230 <DD>
8231 Clear the screen,
8232 then redraw the current line,
8233 leaving the current line at the top of the screen.
8234 With an argument, refresh the current line without clearing the
8235 screen.
8236 <DT><B>redraw-current-line</B>
8237
8238 <DD>
8239 Refresh the current line.
8240
8241 </DL>
8242 <A NAME="lbCO">&nbsp;</A>
8243 <H4>Commands for Manipulating the History</H4>
8244
8245
8246 <DL COMPACT>
8247 <DT><B>accept-line (Newline, Return)</B>
8248
8249 <DD>
8250 Accept the line regardless of where the cursor is. If this line is
8251 non-empty, add it to the history list according to the state of the
8252 <FONT SIZE=-1><B>HISTCONTROL</B>
8253
8254 </FONT>
8255 variable. If the line is a modified history
8256 line, then restore the history line to its original state.
8257 <DT><B>previous-history (C-p)</B>
8258
8259 <DD>
8260 Fetch the previous command from the history list, moving back in
8261 the list.
8262 <DT><B>next-history (C-n)</B>
8263
8264 <DD>
8265 Fetch the next command from the history list, moving forward in the
8266 list.
8267 <DT><B>beginning-of-history (M-&lt;)</B>
8268
8269 <DD>
8270 Move to the first line in the history.
8271 <DT><B>end-of-history (M-&gt;)</B>
8272
8273 <DD>
8274 Move to the end of the input history, i.e., the line currently being
8275 entered.
8276 <DT><B>operate-and-get-next (C-o)</B>
8277
8278 <DD>
8279 Accept the current line for execution and fetch the next line
8280 relative to the current line from the history for editing.
8281 A numeric argument, if supplied, specifies the history entry to use instead
8282 of the current line.
8283 <DT><B>fetch-history</B>
8284
8285 <DD>
8286 With a numeric argument, fetch that entry from the history list
8287 and make it the current line.
8288 Without an argument, move back to the first entry in the history list.
8289 <DT><B>reverse-search-history (C-r)</B>
8290
8291 <DD>
8292 Search backward starting at the current line and moving `up' through
8293 the history as necessary. This is an incremental search.
8294 <DT><B>forward-search-history (C-s)</B>
8295
8296 <DD>
8297 Search forward starting at the current line and moving `down' through
8298 the history as necessary. This is an incremental search.
8299 <DT><B>non-incremental-reverse-search-history (M-p)</B>
8300
8301 <DD>
8302 Search backward through the history starting at the current line
8303 using a non-incremental search for a string supplied by the user.
8304 <DT><B>non-incremental-forward-search-history (M-n)</B>
8305
8306 <DD>
8307 Search forward through the history using a non-incremental search for
8308 a string supplied by the user.
8309 <DT><B>history-search-forward</B>
8310
8311 <DD>
8312 Search forward through the history for the string of characters
8313 between the start of the current line and the point.
8314 This is a non-incremental search.
8315 <DT><B>history-search-backward</B>
8316
8317 <DD>
8318 Search backward through the history for the string of characters
8319 between the start of the current line and the point.
8320 This is a non-incremental search.
8321 <DT><B>history-substring-search-backward</B>
8322
8323 <DD>
8324 Search backward through the history for the string of characters
8325 between the start of the current line and the current cursor
8326 position (the <I>point</I>).
8327 The search string may match anywhere in a history line.
8328 This is a non-incremental search.
8329 <DT><B>history-substring-search-forward</B>
8330
8331 <DD>
8332 Search forward through the history for the string of characters
8333 between the start of the current line and the point.
8334 The search string may match anywhere in a history line.
8335 This is a non-incremental search.
8336 <DT><B>yank-nth-arg (M-C-y)</B>
8337
8338 <DD>
8339 Insert the first argument to the previous command (usually
8340 the second word on the previous line) at point.
8341 With an argument
8342 <I>n</I>,
8343
8344 insert the <I>n</I>th word from the previous command (the words
8345 in the previous command begin with word 0). A negative argument
8346 inserts the <I>n</I>th word from the end of the previous command.
8347 Once the argument <I>n</I> is computed, the argument is extracted
8348 as if the &quot;!<I>n</I>&quot; history expansion had been specified.
8349 <DT><B>yank-last-arg (M-., M-_)</B>
8350
8351 <DD>
8352 Insert the last argument to the previous command (the last word of
8353 the previous history entry).
8354 With a numeric argument, behave exactly like <B>yank-nth-arg</B>.
8355 Successive calls to <B>yank-last-arg</B> move back through the history
8356 list, inserting the last word (or the word specified by the argument to
8357 the first call) of each line in turn.
8358 Any numeric argument supplied to these successive calls determines
8359 the direction to move through the history. A negative argument switches
8360 the direction through the history (back or forward).
8361 The history expansion facilities are used to extract the last word,
8362 as if the &quot;!$&quot; history expansion had been specified.
8363 <DT><B>shell-expand-line (M-C-e)</B>
8364
8365 <DD>
8366 Expand the line as the shell does. This
8367 performs alias and history expansion as well as all of the shell
8368 word expansions. See
8369 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
8370
8371 </FONT>
8372 below for a description of history expansion.
8373 <DT><B>history-expand-line (M-^)</B>
8374
8375 <DD>
8376 Perform history expansion on the current line.
8377 See
8378 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
8379
8380 </FONT>
8381 below for a description of history expansion.
8382 <DT><B>magic-space</B>
8383
8384 <DD>
8385 Perform history expansion on the current line and insert a space.
8386 See
8387 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
8388
8389 </FONT>
8390 below for a description of history expansion.
8391 <DT><B>alias-expand-line</B>
8392
8393 <DD>
8394 Perform alias expansion on the current line.
8395 See
8396 <FONT SIZE=-1><B>ALIASES</B>
8397
8398 </FONT>
8399 above for a description of alias expansion.
8400 <DT><B>history-and-alias-expand-line</B>
8401
8402 <DD>
8403 Perform history and alias expansion on the current line.
8404 <DT><B>insert-last-argument (M-., M-_)</B>
8405
8406 <DD>
8407 A synonym for <B>yank-last-arg</B>.
8408 <DT><B>edit-and-execute-command (C-x C-e)</B>
8409
8410 <DD>
8411 Invoke an editor on the current command line, and execute the result as shell
8412 commands.
8413 <B>Bash</B> attempts to invoke
8414 <FONT SIZE=-1><B>$VISUAL</B>,
8415
8416 </FONT>
8417 <FONT SIZE=-1><B>$EDITOR</B>,
8418
8419 </FONT>
8420 and <I>emacs</I> as the editor, in that order.
8421
8422 </DL>
8423 <A NAME="lbCP">&nbsp;</A>
8424 <H4>Commands for Changing Text</H4>
8425
8426
8427 <DL COMPACT>
8428 <DT><B></B><I>end-of-file</I> (usually C-d)
8429
8430 <DD>
8431 The character indicating end-of-file as set, for example, by
8432 <TT>stty</TT>.
8433
8434 If this character is read when there are no characters
8435 on the line, and point is at the beginning of the line, readline
8436 interprets it as the end of input and returns
8437 <FONT SIZE=-1><B>EOF</B>.
8438
8439 </FONT>
8440 <DT><B>delete-char (C-d)</B>
8441
8442 <DD>
8443 Delete the character at point.
8444 If this function is bound to the
8445 same character as the tty <B>EOF</B> character, as <B>C-d</B>
8446 commonly is, see above for the effects.
8447 <DT><B>backward-delete-char (Rubout)</B>
8448
8449 <DD>
8450 Delete the character behind the cursor. When given a numeric argument,
8451 save the deleted text on the kill ring.
8452 <DT><B>forward-backward-delete-char</B>
8453
8454 <DD>
8455 Delete the character under the cursor, unless the cursor is at the
8456 end of the line, in which case the character behind the cursor is
8457 deleted.
8458 <DT><B>quoted-insert (C-q, C-v)</B>
8459
8460 <DD>
8461 Add the next character typed to the line verbatim. This is
8462 how to insert characters like <B>C-q</B>, for example.
8463 <DT><B>tab-insert (C-v TAB)</B>
8464
8465 <DD>
8466 Insert a tab character.
8467 <DT><B>self-insert (a,&nbsp;b,&nbsp;A,&nbsp;1,&nbsp;!,&nbsp;...)</B>
8468
8469 <DD>
8470 Insert the character typed.
8471 <DT><B>transpose-chars (C-t)</B>
8472
8473 <DD>
8474 Drag the character before point forward over the character at point,
8475 moving point forward as well.
8476 If point is at the end of the line, then this transposes
8477 the two characters before point.
8478 Negative arguments have no effect.
8479 <DT><B>transpose-words (M-t)</B>
8480
8481 <DD>
8482 Drag the word before point past the word after point,
8483 moving point over that word as well.
8484 If point is at the end of the line, this transposes
8485 the last two words on the line.
8486 <DT><B>upcase-word (M-u)</B>
8487
8488 <DD>
8489 Uppercase the current (or following) word. With a negative argument,
8490 uppercase the previous word, but do not move point.
8491 <DT><B>downcase-word (M-l)</B>
8492
8493 <DD>
8494 Lowercase the current (or following) word. With a negative argument,
8495 lowercase the previous word, but do not move point.
8496 <DT><B>capitalize-word (M-c)</B>
8497
8498 <DD>
8499 Capitalize the current (or following) word. With a negative argument,
8500 capitalize the previous word, but do not move point.
8501 <DT><B>overwrite-mode</B>
8502
8503 <DD>
8504 Toggle overwrite mode. With an explicit positive numeric argument,
8505 switches to overwrite mode. With an explicit non-positive numeric
8506 argument, switches to insert mode. This command affects only
8507 <B>emacs</B> mode; <B>vi</B> mode does overwrite differently.
8508 Each call to <I>readline()</I> starts in insert mode.
8509 In overwrite mode, characters bound to <B>self-insert</B> replace
8510 the text at point rather than pushing the text to the right.
8511 Characters bound to <B>backward-delete-char</B> replace the character
8512 before point with a space. By default, this command is unbound.
8513
8514 </DL>
8515 <A NAME="lbCQ">&nbsp;</A>
8516 <H4>Killing and Yanking</H4>
8517
8518
8519 <DL COMPACT>
8520 <DT><B>kill-line (C-k)</B>
8521
8522 <DD>
8523 Kill the text from point to the end of the line.
8524 <DT><B>backward-kill-line (C-x Rubout)</B>
8525
8526 <DD>
8527 Kill backward to the beginning of the line.
8528 <DT><B>unix-line-discard (C-u)</B>
8529
8530 <DD>
8531 Kill backward from point to the beginning of the line.
8532 The killed text is saved on the kill-ring.
8533
8534 <DT><B>kill-whole-line</B>
8535
8536 <DD>
8537 Kill all characters on the current line, no matter where point is.
8538 <DT><B>kill-word (M-d)</B>
8539
8540 <DD>
8541 Kill from point to the end of the current word, or if between
8542 words, to the end of the next word.
8543 Word boundaries are the same as those used by <B>forward-word</B>.
8544 <DT><B>backward-kill-word (M-Rubout)</B>
8545
8546 <DD>
8547 Kill the word behind point.
8548 Word boundaries are the same as those used by <B>backward-word</B>.
8549 <DT><B>shell-kill-word</B>
8550
8551 <DD>
8552 Kill from point to the end of the current word, or if between
8553 words, to the end of the next word.
8554 Word boundaries are the same as those used by <B>shell-forward-word</B>.
8555 <DT><B>shell-backward-kill-word</B>
8556
8557 <DD>
8558 Kill the word behind point.
8559 Word boundaries are the same as those used by <B>shell-backward-word</B>.
8560 <DT><B>unix-word-rubout (C-w)</B>
8561
8562 <DD>
8563 Kill the word behind point, using white space as a word boundary.
8564 The killed text is saved on the kill-ring.
8565 <DT><B>unix-filename-rubout</B>
8566
8567 <DD>
8568 Kill the word behind point, using white space and the slash character
8569 as the word boundaries.
8570 The killed text is saved on the kill-ring.
8571 <DT><B>delete-horizontal-space (M-\)</B>
8572
8573 <DD>
8574 Delete all spaces and tabs around point.
8575 <DT><B>kill-region</B>
8576
8577 <DD>
8578 Kill the text in the current region.
8579 <DT><B>copy-region-as-kill</B>
8580
8581 <DD>
8582 Copy the text in the region to the kill buffer.
8583 <DT><B>copy-backward-word</B>
8584
8585 <DD>
8586 Copy the word before point to the kill buffer.
8587 The word boundaries are the same as <B>backward-word</B>.
8588 <DT><B>copy-forward-word</B>
8589
8590 <DD>
8591 Copy the word following point to the kill buffer.
8592 The word boundaries are the same as <B>forward-word</B>.
8593 <DT><B>yank (C-y)</B>
8594
8595 <DD>
8596 Yank the top of the kill ring into the buffer at point.
8597 <DT><B>yank-pop (M-y)</B>
8598
8599 <DD>
8600 Rotate the kill ring, and yank the new top. Only works following
8601 <B>yank</B>
8602
8603 or
8604 <B>yank-pop</B>.
8605
8606
8607 </DL>
8608 <A NAME="lbCR">&nbsp;</A>
8609 <H4>Numeric Arguments</H4>
8610
8611
8612 <DL COMPACT>
8613 <DT><B>digit-argument (M-0, M-1, ..., M--)</B>
8614
8615 <DD>
8616 Add this digit to the argument already accumulating, or start a new
8617 argument. M-- starts a negative argument.
8618 <DT><B>universal-argument</B>
8619
8620 <DD>
8621 This is another way to specify an argument.
8622 If this command is followed by one or more digits, optionally with a
8623 leading minus sign, those digits define the argument.
8624 If the command is followed by digits, executing
8625 <B>universal-argument</B>
8626
8627 again ends the numeric argument, but is otherwise ignored.
8628 As a special case, if this command is immediately followed by a
8629 character that is neither a digit nor minus sign, the argument count
8630 for the next command is multiplied by four.
8631 The argument count is initially one, so executing this function the
8632 first time makes the argument count four, a second time makes the
8633 argument count sixteen, and so on.
8634
8635 </DL>
8636 <A NAME="lbCS">&nbsp;</A>
8637 <H4>Completing</H4>
8638
8639
8640 <DL COMPACT>
8641 <DT><B>complete (TAB)</B>
8642
8643 <DD>
8644 Attempt to perform completion on the text before point.
8645 <B>Bash</B>
8646
8647 attempts completion treating the text as a variable (if the
8648 text begins with <B>$</B>), username (if the text begins with
8649 <B>~</B>), hostname (if the text begins with <B>@</B>), or
8650 command (including aliases and functions) in turn. If none
8651 of these produces a match, filename completion is attempted.
8652 <DT><B>possible-completions (M-?)</B>
8653
8654 <DD>
8655 List the possible completions of the text before point.
8656 <DT><B>insert-completions (M-*)</B>
8657
8658 <DD>
8659 Insert all completions of the text before point
8660 that would have been generated by
8661 <B>possible-completions</B>.
8662 <DT><B>menu-complete</B>
8663
8664 <DD>
8665 Similar to <B>complete</B>, but replaces the word to be completed
8666 with a single match from the list of possible completions.
8667 Repeated execution of <B>menu-complete</B> steps through the list
8668 of possible completions, inserting each match in turn.
8669 At the end of the list of completions, the bell is rung
8670 (subject to the setting of <B>bell-style</B>)
8671 and the original text is restored.
8672 An argument of <I>n</I> moves <I>n</I> positions forward in the list
8673 of matches; a negative argument may be used to move backward
8674 through the list.
8675 This command is intended to be bound to <B>TAB</B>, but is unbound
8676 by default.
8677 <DT><B>menu-complete-backward</B>
8678
8679 <DD>
8680 Identical to <B>menu-complete</B>, but moves backward through the list
8681 of possible completions, as if <B>menu-complete</B> had been given a
8682 negative argument. This command is unbound by default.
8683 <DT><B>delete-char-or-list</B>
8684
8685 <DD>
8686 Deletes the character under the cursor if not at the beginning or
8687 end of the line (like <B>delete-char</B>).
8688 If at the end of the line, behaves identically to
8689 <B>possible-completions</B>.
8690 This command is unbound by default.
8691 <DT><B>complete-filename (M-/)</B>
8692
8693 <DD>
8694 Attempt filename completion on the text before point.
8695 <DT><B>possible-filename-completions (C-x /)</B>
8696
8697 <DD>
8698 List the possible completions of the text before point,
8699 treating it as a filename.
8700 <DT><B>complete-username (M-~)</B>
8701
8702 <DD>
8703 Attempt completion on the text before point, treating
8704 it as a username.
8705 <DT><B>possible-username-completions (C-x ~)</B>
8706
8707 <DD>
8708 List the possible completions of the text before point,
8709 treating it as a username.
8710 <DT><B>complete-variable (M-$)</B>
8711
8712 <DD>
8713 Attempt completion on the text before point, treating
8714 it as a shell variable.
8715 <DT><B>possible-variable-completions (C-x $)</B>
8716
8717 <DD>
8718 List the possible completions of the text before point,
8719 treating it as a shell variable.
8720 <DT><B>complete-hostname (M-@)</B>
8721
8722 <DD>
8723 Attempt completion on the text before point, treating
8724 it as a hostname.
8725 <DT><B>possible-hostname-completions (C-x @)</B>
8726
8727 <DD>
8728 List the possible completions of the text before point,
8729 treating it as a hostname.
8730 <DT><B>complete-command (M-!)</B>
8731
8732 <DD>
8733 Attempt completion on the text before point, treating
8734 it as a command name. Command completion attempts to
8735 match the text against aliases, reserved words, shell
8736 functions, shell builtins, and finally executable filenames,
8737 in that order.
8738 <DT><B>possible-command-completions (C-x !)</B>
8739
8740 <DD>
8741 List the possible completions of the text before point,
8742 treating it as a command name.
8743 <DT><B>dynamic-complete-history (M-TAB)</B>
8744
8745 <DD>
8746 Attempt completion on the text before point, comparing
8747 the text against lines from the history list for possible
8748 completion matches.
8749 <DT><B>dabbrev-expand</B>
8750
8751 <DD>
8752 Attempt menu completion on the text before point, comparing
8753 the text against lines from the history list for possible
8754 completion matches.
8755 <DT><B>complete-into-braces (M-{)</B>
8756
8757 <DD>
8758 Perform filename completion and insert the list of possible completions
8759 enclosed within braces so the list is available to the shell (see
8760 <B>Brace Expansion</B>
8761
8762 above).
8763
8764 </DL>
8765 <A NAME="lbCT">&nbsp;</A>
8766 <H4>Keyboard Macros</H4>
8767
8768
8769 <DL COMPACT>
8770 <DT><B>start-kbd-macro (C-x ()</B>
8771
8772 <DD>
8773 Begin saving the characters typed into the current keyboard macro.
8774 <DT><B>end-kbd-macro (C-x ))</B>
8775
8776 <DD>
8777 Stop saving the characters typed into the current keyboard macro
8778 and store the definition.
8779 <DT><B>call-last-kbd-macro (C-x e)</B>
8780
8781 <DD>
8782 Re-execute the last keyboard macro defined, by making the characters
8783 in the macro appear as if typed at the keyboard.
8784 <DT><B>print-last-kbd-macro ()</B>
8785
8786 <DD>
8787 Print the last keyboard macro defined in a format suitable for the
8788 <I>inputrc</I> file.
8789
8790 </DL>
8791 <A NAME="lbCU">&nbsp;</A>
8792 <H4>Miscellaneous</H4>
8793
8794
8795 <DL COMPACT>
8796 <DT><B>re-read-init-file (C-x C-r)</B>
8797
8798 <DD>
8799 Read in the contents of the <I>inputrc</I> file, and incorporate
8800 any bindings or variable assignments found there.
8801 <DT><B>abort (C-g)</B>
8802
8803 <DD>
8804 Abort the current editing command and
8805 ring the terminal's bell (subject to the setting of
8806 <B>bell-style</B>).
8807
8808 <DT><B>do-lowercase-version (M-A, M-B, M-</B><I>x</I>, ...)
8809
8810 <DD>
8811 If the metafied character <I>x</I> is uppercase, run the command
8812 that is bound to the corresponding metafied lowercase character.
8813 The behavior is undefined if <I>x</I> is already lowercase.
8814 <DT><B>prefix-meta (ESC)</B>
8815
8816 <DD>
8817 Metafy the next character typed.
8818 <FONT SIZE=-1><B>ESC</B>
8819
8820 </FONT>
8821 <B>f</B>
8822
8823 is equivalent to
8824 <B>Meta-f</B>.
8825
8826 <DT><B>undo (C-_, C-x C-u)</B>
8827
8828 <DD>
8829 Incremental undo, separately remembered for each line.
8830 <DT><B>revert-line (M-r)</B>
8831
8832 <DD>
8833 Undo all changes made to this line. This is like executing the
8834 <B>undo</B>
8835
8836 command enough times to return the line to its initial state.
8837 <DT><B>tilde-expand (M-&amp;)</B>
8838
8839 <DD>
8840 Perform tilde expansion on the current word.
8841 <DT><B>set-mark (C-@, M-&lt;space&gt;)</B>
8842
8843 <DD>
8844 Set the mark to the point. If a
8845 numeric argument is supplied, the mark is set to that position.
8846 <DT><B>exchange-point-and-mark (C-x C-x)</B>
8847
8848 <DD>
8849 Swap the point with the mark. The current cursor position is set to
8850 the saved position, and the old cursor position is saved as the mark.
8851 <DT><B>character-search (C-])</B>
8852
8853 <DD>
8854 A character is read and point is moved to the next occurrence of that
8855 character. A negative argument searches for previous occurrences.
8856 <DT><B>character-search-backward (M-C-])</B>
8857
8858 <DD>
8859 A character is read and point is moved to the previous occurrence of that
8860 character. A negative argument searches for subsequent occurrences.
8861 <DT><B>skip-csi-sequence</B>
8862
8863 <DD>
8864 Read enough characters to consume a multi-key sequence such as those
8865 defined for keys like Home and End. Such sequences begin with a
8866 Control Sequence Indicator (CSI), usually ESC-[. If this sequence is
8867 bound to &quot;\[&quot;, keys producing such sequences will have no effect
8868 unless explicitly bound to a readline command, instead of inserting
8869 stray characters into the editing buffer. This is unbound by default,
8870 but usually bound to ESC-[.
8871 <DT><B>insert-comment (M-#)</B>
8872
8873 <DD>
8874 Without a numeric argument, the value of the readline
8875 <B>comment-begin</B>
8876
8877 variable is inserted at the beginning of the current line.
8878 If a numeric argument is supplied, this command acts as a toggle: if
8879 the characters at the beginning of the line do not match the value
8880 of <B>comment-begin</B>, the value is inserted, otherwise
8881 the characters in <B>comment-begin</B> are deleted from the beginning of
8882 the line.
8883 In either case, the line is accepted as if a newline had been typed.
8884 The default value of
8885 <B>comment-begin</B> causes this command to make the current line
8886 a shell comment.
8887 If a numeric argument causes the comment character to be removed, the line
8888 will be executed by the shell.
8889 <DT><B>spell-correct-word (C-x s)</B>
8890
8891 <DD>
8892 Perform spelling correction on the current word, treating it as a directory
8893 or filename, in the same way as the <B>cdspell</B> shell option.
8894 Word boundaries are the same as those used by <B>shell-forward-word</B>.
8895 <DT><B>glob-complete-word (M-g)</B>
8896
8897 <DD>
8898 The word before point is treated as a pattern for pathname expansion,
8899 with an asterisk implicitly appended. This pattern is used to
8900 generate a list of matching filenames for possible completions.
8901 <DT><B>glob-expand-word (C-x *)</B>
8902
8903 <DD>
8904 The word before point is treated as a pattern for pathname expansion,
8905 and the list of matching filenames is inserted, replacing the word.
8906 If a numeric argument is supplied, an asterisk is appended before
8907 pathname expansion.
8908 <DT><B>glob-list-expansions (C-x g)</B>
8909
8910 <DD>
8911 The list of expansions that would have been generated by
8912 <B>glob-expand-word</B>
8913
8914 is displayed, and the line is redrawn.
8915 If a numeric argument is supplied, an asterisk is appended before
8916 pathname expansion.
8917 <DT><B>dump-functions</B>
8918
8919 <DD>
8920 Print all of the functions and their key bindings to the
8921 readline output stream. If a numeric argument is supplied,
8922 the output is formatted in such a way that it can be made part
8923 of an <I>inputrc</I> file.
8924 <DT><B>dump-variables</B>
8925
8926 <DD>
8927 Print all of the settable readline variables and their values to the
8928 readline output stream. If a numeric argument is supplied,
8929 the output is formatted in such a way that it can be made part
8930 of an <I>inputrc</I> file.
8931 <DT><B>dump-macros</B>
8932
8933 <DD>
8934 Print all of the readline key sequences bound to macros and the
8935 strings they output. If a numeric argument is supplied,
8936 the output is formatted in such a way that it can be made part
8937 of an <I>inputrc</I> file.
8938 <DT><B>display-shell-version (C-x C-v)</B>
8939
8940 <DD>
8941 Display version information about the current instance of
8942 <B>bash</B>.
8943
8944
8945 </DL>
8946 <A NAME="lbCV">&nbsp;</A>
8947 <H4>Programmable Completion</H4>
8948
8949 When word completion is attempted for an argument to a command for
8950 which a completion specification (a <I>compspec</I>) has been defined
8951 using the <B>complete</B> builtin (see
8952 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
8953
8954 </FONT>
8955 below), the programmable completion facilities are invoked.
8956 <P>
8957
8958 First, the command name is identified.
8959 If the command word is the empty string (completion attempted at the
8960 beginning of an empty line), any compspec defined with
8961 the <B>-E</B> option to <B>complete</B> is used.
8962 If a compspec has been defined for that command, the
8963 compspec is used to generate the list of possible completions for the word.
8964 If the command word is a full pathname, a compspec for the full
8965 pathname is searched for first.
8966 If no compspec is found for the full pathname, an attempt is made to
8967 find a compspec for the portion following the final slash.
8968 If those searches do not result in a compspec, any compspec defined with
8969 the <B>-D</B> option to <B>complete</B> is used as the default.
8970 If there is no default compspec, <B>bash</B> attempts alias expansion
8971 on the command word as a final resort, and attempts to find a compspec
8972 for the command word from any successful expansion.
8973 <P>
8974
8975 Once a compspec has been found, it is used to generate the list of
8976 matching words.
8977 If a compspec is not found, the default <B>bash</B> completion as
8978 described above under <B>Completing</B> is performed.
8979 <P>
8980
8981 First, the actions specified by the compspec are used.
8982 Only matches which are prefixed by the word being completed are
8983 returned.
8984 When the
8985 <B>-f</B>
8986
8987 or
8988 <B>-d</B>
8989
8990 option is used for filename or directory name completion, the shell
8991 variable
8992 <FONT SIZE=-1><B>FIGNORE</B>
8993
8994 </FONT>
8995 is used to filter the matches.
8996 <P>
8997
8998 Any completions specified by a pathname expansion pattern to the
8999 <B>-G</B> option are generated next.
9000 The words generated by the pattern need not match the word
9001 being completed.
9002 The
9003 <FONT SIZE=-1><B>GLOBIGNORE</B>
9004
9005 </FONT>
9006 shell variable is not used to filter the matches, but the
9007 <FONT SIZE=-1><B>FIGNORE</B>
9008
9009 </FONT>
9010 variable is used.
9011 <P>
9012
9013 Next, the string specified as the argument to the <B>-W</B> option
9014 is considered.
9015 The string is first split using the characters in the
9016 <FONT SIZE=-1><B>IFS</B>
9017
9018 </FONT>
9019 special variable as delimiters.
9020 Shell quoting is honored.
9021 Each word is then expanded using
9022 brace expansion, tilde expansion, parameter and variable expansion,
9023 command substitution, and arithmetic expansion,
9024 as described above under
9025 <FONT SIZE=-1><B>EXPANSION</B>.
9026
9027 </FONT>
9028 The results are split using the rules described above under
9029 <B>Word Splitting</B>.
9030 The results of the expansion are prefix-matched against the word being
9031 completed, and the matching words become the possible completions.
9032 <P>
9033
9034 After these matches have been generated, any shell function or command
9035 specified with the <B>-F</B> and <B>-C</B> options is invoked.
9036 When the command or function is invoked, the
9037 <FONT SIZE=-1><B>COMP_LINE</B>,
9038
9039 </FONT>
9040 <FONT SIZE=-1><B>COMP_POINT</B>,
9041
9042 </FONT>
9043 <FONT SIZE=-1><B>COMP_KEY</B>,
9044
9045 </FONT>
9046 and
9047 <FONT SIZE=-1><B>COMP_TYPE</B>
9048
9049 </FONT>
9050 variables are assigned values as described above under
9051 <B>Shell Variables</B>.
9052 If a shell function is being invoked, the
9053 <FONT SIZE=-1><B>COMP_WORDS</B>
9054
9055 </FONT>
9056 and
9057 <FONT SIZE=-1><B>COMP_CWORD</B>
9058
9059 </FONT>
9060 variables are also set.
9061 When the function or command is invoked,
9062 the first argument (<B>$1</B>) is the name of the command whose arguments are
9063 being completed,
9064 the second argument (<B>$2</B>) is the word being completed,
9065 and the third argument (<B>$3</B>) is the word preceding the word being
9066 completed on the current command line.
9067 No filtering of the generated completions against the word being completed
9068 is performed; the function or command has complete freedom in generating
9069 the matches.
9070 <P>
9071
9072 Any function specified with <B>-F</B> is invoked first.
9073 The function may use any of the shell facilities, including the
9074 <B>compgen</B> builtin described below, to generate the matches.
9075 It must put the possible completions in the
9076 <FONT SIZE=-1><B>COMPREPLY</B>
9077
9078 </FONT>
9079 array variable, one per array element.
9080 <P>
9081
9082 Next, any command specified with the <B>-C</B> option is invoked
9083 in an environment equivalent to command substitution.
9084 It should print a list of completions, one per line, to the
9085 standard output.
9086 Backslash may be used to escape a newline, if necessary.
9087 <P>
9088
9089 After all of the possible completions are generated, any filter
9090 specified with the <B>-X</B> option is applied to the list.
9091 The filter is a pattern as used for pathname expansion; a <B>&amp;</B>
9092 in the pattern is replaced with the text of the word being completed.
9093 A literal <B>&amp;</B> may be escaped with a backslash; the backslash
9094 is removed before attempting a match.
9095 Any completion that matches the pattern will be removed from the list.
9096 A leading <B>!</B> negates the pattern; in this case any completion
9097 not matching the pattern will be removed.
9098 If the
9099 <B>nocasematch</B>
9100
9101 shell option is enabled, the match is performed without regard to the case
9102 of alphabetic characters.
9103 <P>
9104
9105 Finally, any prefix and suffix specified with the <B>-P</B> and <B>-S</B>
9106 options are added to each member of the completion list, and the result is
9107 returned to the readline completion code as the list of possible
9108 completions.
9109 <P>
9110
9111 If the previously-applied actions do not generate any matches, and the
9112 <B>-o dirnames</B> option was supplied to <B>complete</B> when the
9113 compspec was defined, directory name completion is attempted.
9114 <P>
9115
9116 If the <B>-o plusdirs</B> option was supplied to <B>complete</B> when the
9117 compspec was defined, directory name completion is attempted and any
9118 matches are added to the results of the other actions.
9119 <P>
9120
9121 By default, if a compspec is found, whatever it generates is returned
9122 to the completion code as the full set of possible completions.
9123 The default <B>bash</B> completions are not attempted, and the readline
9124 default of filename completion is disabled.
9125 If the <B>-o bashdefault</B> option was supplied to <B>complete</B> when
9126 the compspec was defined, the <B>bash</B> default completions are attempted
9127 if the compspec generates no matches.
9128 If the <B>-o default</B> option was supplied to <B>complete</B> when the
9129 compspec was defined, readline's default completion will be performed
9130 if the compspec (and, if attempted, the default <B>bash</B> completions)
9131 generate no matches.
9132 <P>
9133
9134 When a compspec indicates that directory name completion is desired,
9135 the programmable completion functions force readline to append a slash
9136 to completed names which are symbolic links to directories, subject to
9137 the value of the <B>mark-directories</B> readline variable, regardless
9138 of the setting of the <B>mark-symlinked-directories</B> readline variable.
9139 <P>
9140
9141 There is some support for dynamically modifying completions. This is
9142 most useful when used in combination with a default completion specified
9143 with <B>complete -D</B>.
9144 It's possible for shell functions executed as completion
9145 handlers to indicate that completion should be retried by returning an
9146 exit status of 124. If a shell function returns 124, and changes
9147 the compspec associated with the command on which completion is being
9148 attempted (supplied as the first argument when the function is executed),
9149 programmable completion restarts from the beginning, with an
9150 attempt to find a new compspec for that command. This allows a set of
9151 completions to be built dynamically as completion is attempted, rather than
9152 being loaded all at once.
9153 <P>
9154
9155 For instance, assuming that there is a library of compspecs, each kept in a
9156 file corresponding to the name of the command, the following default
9157 completion function would load completions dynamically:
9158 <P>
9159
9160 <TT>_completion_loader()
9161 <BR>
9162
9163 {
9164 <BR>
9165
9166 <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>
9167 <BR>
9168
9169 }
9170 <BR>
9171
9172 complete -D -F _completion_loader -o bashdefault -o default
9173 <BR>
9174
9175 </TT>
9176 <A NAME="lbCW">&nbsp;</A>
9177 <H3>HISTORY</H3>
9178
9179 When the
9180 <B>-o history</B>
9181
9182 option to the
9183 <B>set</B>
9184
9185 builtin is enabled, the shell provides access to the
9186 <I>command history</I>,
9187 the list of commands previously typed.
9188 The value of the
9189 <FONT SIZE=-1><B>HISTSIZE</B>
9190
9191 </FONT>
9192 variable is used as the
9193 number of commands to save in a history list.
9194 The text of the last
9195 <FONT SIZE=-1><B>HISTSIZE</B>
9196
9197 </FONT>
9198 commands (default 500) is saved. The shell
9199 stores each command in the history list prior to parameter and
9200 variable expansion (see
9201 <FONT SIZE=-1><B>EXPANSION</B>
9202
9203 </FONT>
9204 above) but after history expansion is performed, subject to the
9205 values of the shell variables
9206 <FONT SIZE=-1><B>HISTIGNORE</B>
9207
9208 </FONT>
9209 and
9210 <FONT SIZE=-1><B>HISTCONTROL</B>.
9211
9212 </FONT>
9213 <P>
9214
9215 On startup, the history is initialized from the file named by
9216 the variable
9217 <FONT SIZE=-1><B>HISTFILE</B>
9218
9219 </FONT>
9220 (default <A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>).
9221 The file named by the value of
9222 <FONT SIZE=-1><B>HISTFILE</B>
9223
9224 </FONT>
9225 is truncated, if necessary, to contain no more than
9226 the number of lines specified by the value of
9227 <FONT SIZE=-1><B>HISTFILESIZE</B>.
9228
9229 </FONT>
9230 If <B>HISTFILESIZE</B> is unset, or set to null, a non-numeric value,
9231 or a numeric value less than zero, the history file is not truncated.
9232 When the history file is read,
9233 lines beginning with the history comment character followed immediately
9234 by a digit are interpreted as timestamps for the following history line.
9235 These timestamps are optionally displayed depending on the value of the
9236 <FONT SIZE=-1><B>HISTTIMEFORMAT</B>
9237
9238 </FONT>
9239 variable.
9240 When a shell with history enabled exits, the last
9241 <FONT SIZE=-1><B>$HISTSIZE</B>
9242
9243 </FONT>
9244 lines are copied from the history list to
9245 <FONT SIZE=-1><B>$HISTFILE</B>.
9246
9247 </FONT>
9248 If the
9249 <B>histappend</B>
9250
9251 shell option is enabled
9252 (see the description of
9253 <B>shopt</B>
9254
9255 under
9256 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
9257
9258 </FONT>
9259 below), the lines are appended to the history file,
9260 otherwise the history file is overwritten.
9261 If
9262 <FONT SIZE=-1><B>HISTFILE</B>
9263
9264 </FONT>
9265 is unset, or if the history file is unwritable, the history is
9266 not saved.
9267 If the
9268 <FONT SIZE=-1><B>HISTTIMEFORMAT</B>
9269
9270 </FONT>
9271 variable is set, time stamps are written to the history file, marked
9272 with the history comment character, so
9273 they may be preserved across shell sessions.
9274 This uses the history comment character to distinguish timestamps from
9275 other history lines.
9276 After saving the history, the history file is truncated
9277 to contain no more than
9278 <FONT SIZE=-1><B>HISTFILESIZE</B>
9279
9280 </FONT>
9281 lines. If
9282 <FONT SIZE=-1><B>HISTFILESIZE</B>
9283
9284 </FONT>
9285 is unset, or set to null, a non-numeric value,
9286 or a numeric value less than zero, the history file is not truncated.
9287 <P>
9288
9289 The builtin command
9290 <B>fc</B>
9291
9292 (see
9293 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
9294
9295 </FONT>
9296 below) may be used to list or edit and re-execute a portion of
9297 the history list.
9298 The
9299 <B>history</B>
9300
9301 builtin may be used to display or modify the history list and
9302 manipulate the history file.
9303 When using command-line editing, search commands
9304 are available in each editing mode that provide access to the
9305 history list.
9306 <P>
9307
9308 The shell allows control over which commands are saved on the history
9309 list. The
9310 <FONT SIZE=-1><B>HISTCONTROL</B>
9311
9312 </FONT>
9313 and
9314 <FONT SIZE=-1><B>HISTIGNORE</B>
9315
9316 </FONT>
9317 variables may be set to cause the shell to save only a subset of the
9318 commands entered.
9319 The
9320 <B>cmdhist</B>
9321
9322 shell option, if enabled, causes the shell to attempt to save each
9323 line of a multi-line command in the same history entry, adding
9324 semicolons where necessary to preserve syntactic correctness.
9325 The
9326 <B>lithist</B>
9327
9328 shell option causes the shell to save the command with embedded newlines
9329 instead of semicolons. See the description of the
9330 <B>shopt</B>
9331
9332 builtin below under
9333 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
9334
9335 </FONT>
9336 for information on setting and unsetting shell options.
9337 <A NAME="lbCX">&nbsp;</A>
9338 <H3>HISTORY EXPANSION</H3>
9339
9340 The shell supports a history expansion feature that
9341 is similar to the history expansion in
9342 <B>csh</B>.
9343
9344 This section describes what syntax features are available. This
9345 feature is enabled by default for interactive shells, and can be
9346 disabled using the
9347 <B>+H</B>
9348
9349 option to the
9350 <B>set</B>
9351
9352 builtin command (see
9353 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
9354
9355 </FONT>
9356 below). Non-interactive shells do not perform history expansion
9357 by default.
9358 <P>
9359
9360 History expansions introduce words from the history list into
9361 the input stream, making it easy to repeat commands, insert the
9362 arguments to a previous command into the current input line, or
9363 fix errors in previous commands quickly.
9364 <P>
9365
9366 History expansion is performed immediately after a complete line
9367 is read, before the shell breaks it into words, and is performed
9368 on each line individually without taking quoting on previous lines into
9369 account.
9370 It takes place in two parts.
9371 The first is to determine which line from the history list
9372 to use during substitution.
9373 The second is to select portions of that line for inclusion into
9374 the current one.
9375 The line selected from the history is the <I>event</I>,
9376 and the portions of that line that are acted upon are <I>words</I>.
9377 Various <I>modifiers</I> are available to manipulate the selected words.
9378 The line is broken into words in the same fashion as when reading input,
9379 so that several <I>metacharacter</I>-separated words surrounded by
9380 quotes are considered one word.
9381 History expansions are introduced by the appearance of the
9382 history expansion character, which is <B>!</B> by default.
9383 Only backslash (<B>\</B>) and single quotes can quote
9384 the history expansion character, but the history expansion character is
9385 also treated as quoted if it immediately precedes the closing double quote
9386 in a double-quoted string.
9387 <P>
9388
9389 Several characters inhibit history expansion if found immediately
9390 following the history expansion character, even if it is unquoted:
9391 space, tab, newline, carriage return, and <B>=</B>.
9392 If the <B>extglob</B> shell option is enabled, <B>(</B> will also
9393 inhibit expansion.
9394 <P>
9395
9396 Several shell options settable with the
9397 <B>shopt</B>
9398
9399 builtin may be used to tailor the behavior of history expansion.
9400 If the
9401 <B>histverify</B>
9402
9403 shell option is enabled (see the description of the
9404 <B>shopt</B>
9405
9406 builtin below), and
9407 <B>readline</B>
9408
9409 is being used, history substitutions are not immediately passed to
9410 the shell parser.
9411 Instead, the expanded line is reloaded into the
9412 <B>readline</B>
9413
9414 editing buffer for further modification.
9415 If
9416 <B>readline</B>
9417
9418 is being used, and the
9419 <B>histreedit</B>
9420
9421 shell option is enabled, a failed history substitution will be reloaded
9422 into the
9423 <B>readline</B>
9424
9425 editing buffer for correction.
9426 The
9427 <B>-p</B>
9428
9429 option to the
9430 <B>history</B>
9431
9432 builtin command may be used to see what a history expansion will
9433 do before using it.
9434 The
9435 <B>-s</B>
9436
9437 option to the
9438 <B>history</B>
9439
9440 builtin may be used to add commands to the end of the history list
9441 without actually executing them, so that they are available for
9442 subsequent recall.
9443 <P>
9444
9445 The shell allows control of the various characters used by the
9446 history expansion mechanism (see the description of
9447 <B>histchars</B>
9448
9449 above under
9450 <B>Shell Variables</B>).
9451
9452 The shell uses
9453 the history comment character to mark history timestamps when
9454 writing the history file.
9455 <A NAME="lbCY">&nbsp;</A>
9456 <H4>Event Designators</H4>
9457
9458 An event designator is a reference to a command line entry in the
9459 history list.
9460 Unless the reference is absolute, events are relative to the current
9461 position in the history list.
9462 <P>
9463
9464
9465 <DL COMPACT>
9466 <DT><B>!</B>
9467
9468 <DD>
9469 Start a history substitution, except when followed by a
9470 <B>blank</B>,
9471
9472 newline, carriage return, =
9473 or ( (when the <B>extglob</B> shell option is enabled using
9474 the <B>shopt</B> builtin).
9475 <DT><B>!</B><I>n</I>
9476
9477 <DD>
9478 Refer to command line
9479 <I>n</I>.
9480
9481 <DT><B>!-</B><I>n</I>
9482
9483 <DD>
9484 Refer to the current command minus
9485 <I>n</I>.
9486
9487 <DT><B>!!</B>
9488
9489 <DD>
9490 Refer to the previous command. This is a synonym for `!-1'.
9491 <DT><B>!</B><I>string</I>
9492
9493 <DD>
9494 Refer to the most recent command preceding the current position in the
9495 history list starting with
9496 <I>string</I>.
9497
9498 <DT><B>!?</B><I>string</I><B>[?]</B>
9499
9500 <DD>
9501 Refer to the most recent command preceding the current position in the
9502 history list containing
9503 <I>string</I>.
9504
9505 The trailing <B>?</B> may be omitted if
9506 <I>string</I>
9507
9508 is followed immediately by a newline.
9509 If <I>string</I> is missing, the string from the most recent search is used;
9510 it is an error if there is no previous search string.
9511 <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>
9512
9513 <DD>
9514 Quick substitution. Repeat the previous command, replacing
9515 <I>string1</I>
9516
9517 with
9518 <I>string2</I>.
9519
9520 Equivalent to
9521 ``!!:s<FONT SIZE=+2>^</FONT><I>string1</I><FONT SIZE=+2>^</FONT><I>string2</I><FONT SIZE=+2>^</FONT>''
9522 (see <B>Modifiers</B> below).
9523 <DT><B>!#</B>
9524
9525 <DD>
9526 The entire command line typed so far.
9527
9528 </DL>
9529 <A NAME="lbCZ">&nbsp;</A>
9530 <H4>Word Designators</H4>
9531
9532 Word designators are used to select desired words from the event.
9533 A
9534 <B>:</B>
9535
9536 separates the event specification from the word designator.
9537 It may be omitted if the word designator begins with a
9538 <B>^</B>,
9539
9540 <B>$</B>,
9541
9542 <B>*</B>,
9543
9544 <B>-</B>,
9545
9546 or
9547 <B>%</B>.
9548
9549 Words are numbered from the beginning of the line,
9550 with the first word being denoted by 0 (zero).
9551 Words are inserted into the current line separated by single spaces.
9552 <P>
9553
9554
9555 <DL COMPACT>
9556 <DT><B>0 (zero)</B>
9557
9558 <DD>
9559 The zeroth word. For the shell, this is the command
9560 word.
9561 <DT><I>n</I>
9562
9563 <DD>
9564 The <I>n</I>th word.
9565 <DT><B>^</B>
9566
9567 <DD>
9568 The first argument. That is, word 1.
9569 <DT><B>$</B>
9570
9571 <DD>
9572 The last word. This is usually the last argument, but will expand to the
9573 zeroth word if there is only one word in the line.
9574 <DT><B>%</B>
9575
9576 <DD>
9577 The first word matched by the most recent `?<I>string</I>?' search,
9578 if the search string begins with a character that is part of a word.
9579 <DT><I>x</I><B>-</B>y
9580
9581 <DD>
9582 A range of words; `-<I>y</I>' abbreviates `0-<I>y</I>'.
9583 <DT><B>*</B>
9584
9585 <DD>
9586 All of the words but the zeroth. This is a synonym
9587 for `<I>1-$</I>'. It is not an error to use
9588 <B>*</B>
9589
9590 if there is just one
9591 word in the event; the empty string is returned in that case.
9592 <DT><B>x*</B>
9593
9594 <DD>
9595 Abbreviates <I>x-$</I>.
9596 <DT><B>x-</B>
9597
9598 <DD>
9599 Abbreviates <I>x-$</I> like <B>x*</B>, but omits the last word.
9600 If <B>x</B> is missing, it defaults to 0.
9601
9602 </DL>
9603 <P>
9604
9605 If a word designator is supplied without an event specification, the
9606 previous command is used as the event.
9607 <A NAME="lbDA">&nbsp;</A>
9608 <H4>Modifiers</H4>
9609
9610 After the optional word designator, there may appear a sequence of
9611 one or more of the following modifiers, each preceded by a `:'.
9612 These modify, or edit, the word or words selected from the history event.
9613 <P>
9614
9615
9616 <DL COMPACT>
9617 <DT><B>h</B>
9618
9619 <DD>
9620 Remove a trailing filename component, leaving only the head.
9621 <DT><B>t</B>
9622
9623 <DD>
9624 Remove all leading filename components, leaving the tail.
9625 <DT><B>r</B>
9626
9627 <DD>
9628 Remove a trailing suffix of the form <I>.xxx</I>, leaving the
9629 basename.
9630 <DT><B>e</B>
9631
9632 <DD>
9633 Remove all but the trailing suffix.
9634 <DT><B>p</B>
9635
9636 <DD>
9637 Print the new command but do not execute it.
9638 <DT><B>q</B>
9639
9640 <DD>
9641 Quote the substituted words, escaping further substitutions.
9642 <DT><B>x</B>
9643
9644 <DD>
9645 Quote the substituted words as with
9646 <B>q</B>,
9647
9648 but break into words at
9649 <B>blanks</B>
9650
9651 and newlines.
9652 The <B>q</B> and <B>x</B> modifiers are mutually exclusive; the last one
9653 supplied is used.
9654 <DT><B>s/</B><I>old</I>/<I>new</I>/
9655
9656 <DD>
9657 Substitute
9658 <I>new</I>
9659
9660 for the first occurrence of
9661 <I>old</I>
9662
9663 in the event line.
9664 Any character may be used as the delimiter in place of /.
9665 The final delimiter is optional if it is the last character of the
9666 event line.
9667 The delimiter may be quoted in
9668 <I>old</I>
9669
9670 and
9671 <I>new</I>
9672
9673 with a single backslash. If &amp; appears in
9674 <I>new</I>,
9675
9676 it is replaced by
9677 <I>old</I>.
9678
9679 A single backslash will quote the &amp;.
9680 If
9681 <I>old</I>
9682
9683 is null, it is set to the last
9684 <I>old</I>
9685
9686 substituted, or, if no previous history substitutions took place,
9687 the last
9688 <I>string</I>
9689
9690 in a
9691 <B>!?</B><I>string</I><B>[?]</B>
9692
9693 search.
9694 If
9695 <I>new</I>
9696
9697 is null, each matching
9698 <I>old</I>
9699
9700 is deleted.
9701 <DT><B>&amp;</B>
9702
9703 <DD>
9704 Repeat the previous substitution.
9705 <DT><B>g</B>
9706
9707 <DD>
9708 Cause changes to be applied over the entire event line. This is
9709 used in conjunction with `<B>:s</B>' (e.g., `<B>:gs/</B><I>old</I>/<I>new</I>/')
9710 or `<B>:&amp;</B>'. If used with
9711 `<B>:s</B>', any delimiter can be used
9712 in place of /, and the final delimiter is optional
9713 if it is the last character of the event line.
9714 An <B>a</B> may be used as a synonym for <B>g</B>.
9715 <DT><B>G</B>
9716
9717 <DD>
9718 Apply the following `<B>s</B>' or `<B>&amp;</B>' modifier once to each word
9719 in the event line.
9720
9721 </DL>
9722 <A NAME="lbDB">&nbsp;</A>
9723 <H3>SHELL BUILTIN COMMANDS</H3>
9724
9725
9726
9727 <P>
9728
9729 Unless otherwise noted, each builtin command documented in this
9730 section as accepting options preceded by
9731 <B>-</B>
9732
9733 accepts
9734 <B>--</B>
9735
9736 to signify the end of the options.
9737 The <B>:</B>, <B>true</B>, <B>false</B>, and <B>test</B>/<B>[</B> builtins
9738 do not accept options and do not treat <B>--</B> specially.
9739 The <B>exit</B>, <B>logout</B>, <B>return</B>,
9740 <B>break</B>, <B>continue</B>, <B>let</B>,
9741 and <B>shift</B> builtins accept and process arguments beginning with
9742 <B>-</B> without requiring <B>--</B>.
9743 Other builtins that accept arguments but are not specified as accepting
9744 options interpret arguments beginning with <B>-</B> as invalid options and
9745 require <B>--</B> to prevent this interpretation.
9746 <P>
9747
9748 <DL COMPACT>
9749 <DT><B>:</B> [<I>arguments</I>]<DD>
9750
9751 No effect; the command does nothing beyond expanding
9752 <I>arguments</I>
9753
9754 and performing any specified
9755 redirections.
9756 The return status is zero.
9757 <DT><B> . </B> <I>filename</I> [<I>arguments</I>]<DD>
9758
9759 <DT><B>source</B> <I>filename</I> [<I>arguments</I>]<DD>
9760
9761 Read and execute commands from
9762 <I>filename</I>
9763
9764 in the current
9765 shell environment and return the exit status of the last command
9766 executed from
9767 <I>filename</I>.
9768
9769 If
9770 <I>filename</I>
9771
9772 does not contain a slash, filenames in
9773 <FONT SIZE=-1><B>PATH</B>
9774
9775 </FONT>
9776 are used to find the directory containing
9777 <I>filename</I>,
9778
9779 but <I>filename</I> does not need to be executable.
9780 The file searched for in
9781 <FONT SIZE=-1><B>PATH</B>
9782
9783 </FONT>
9784 need not be executable.
9785 When <B>bash</B> is not in <I>posix mode</I>, it searches
9786 the current directory if no file is found in
9787 <FONT SIZE=-1><B>PATH</B>.
9788
9789 </FONT>
9790 If the
9791 <B>sourcepath</B>
9792
9793 option to the
9794 <B>shopt</B>
9795
9796 builtin command is turned off, the
9797 <FONT SIZE=-1><B>PATH</B>
9798
9799 </FONT>
9800 is not searched.
9801 If any <I>arguments</I> are supplied, they become the positional
9802 parameters when <I>filename</I> is executed. Otherwise the positional
9803 parameters are unchanged.
9804 If the <B>-T</B> option is enabled, <B>.</B> inherits any trap on
9805 <B>DEBUG</B>; if it is not, any <B>DEBUG</B> trap string is saved and
9806 restored around the call to <B>.</B>, and <B>.</B> unsets the
9807 <B>DEBUG</B> trap while it executes.
9808 If <B>-T</B> is not set, and the sourced file changes
9809 the <B>DEBUG</B> trap, the new value is retained when <B>.</B> completes.
9810 The return status is the status of the last command exited within
9811 the script (0 if no commands are executed), and false if
9812 <I>filename</I>
9813
9814 is not found or cannot be read.
9815 <DT><B>alias</B> [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
9816 <B>Alias</B> with no arguments or with the
9817 <B>-p</B>
9818
9819 option prints the list of aliases in the form
9820 <B>alias</B> <I>name</I>=<I>value</I> on standard output.
9821 When arguments are supplied, an alias is defined for
9822 each <I>name</I> whose <I>value</I> is given.
9823 A trailing space in <I>value</I> causes the next word to be
9824 checked for alias substitution when the alias is expanded.
9825 For each <I>name</I> in the argument list for which no <I>value</I>
9826 is supplied, the name and value of the alias is printed.
9827 <B>Alias</B> returns true unless a <I>name</I> is given for which
9828 no alias has been defined.
9829 <DT><B>bg</B> [<I>jobspec</I> ...]<DD>
9830 Resume each suspended job <I>jobspec</I> in the background, as if it
9831 had been started with
9832 <B>&amp;</B>.
9833
9834 If
9835 <I>jobspec</I>
9836
9837 is not present, the shell's notion of the <I>current job</I> is used.
9838 <B>bg</B>
9839
9840 <I>jobspec</I>
9841
9842 returns 0 unless run when job control is disabled or, when run with
9843 job control enabled, any specified <I>jobspec</I> was not found
9844 or was started without job control.
9845 <DT><B>bind</B> [<B>-m</B> <I>keymap</I>] [<B>-lpsvPSVX</B>]<DD>
9846
9847 <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>
9848 <DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <B>-f</B> <I>filename</I><DD>
9849 <DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <B>-x</B> <I>keyseq</I>:<I>shell-command</I><DD>
9850 <DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <I>keyseq</I>:<I>function-name</I><DD>
9851 <DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <I>keyseq</I>:<I>readline-command</I><DD>
9852 <DT><B>bind</B> <I>readline-command-line</I><DD>
9853
9854 Display current
9855 <B>readline</B>
9856
9857 key and function bindings, bind a key sequence to a
9858 <B>readline</B>
9859
9860 function or macro, or set a
9861 <B>readline</B>
9862
9863 variable.
9864 Each non-option argument is a command as it would appear in a
9865 <B>readline</B>
9866
9867 initialization file such as
9868 <I>.inputrc</I>,
9869
9870 but each binding or command must be passed as a separate argument;
9871 e.g., '&quot;\C-x\C-r&quot;: re-read-init-file'.
9872 Options, if supplied, have the following meanings:
9873 <DL COMPACT><DT><DD>
9874
9875 <DL COMPACT>
9876 <DT><B>-m </B><I>keymap</I>
9877
9878 <DD>
9879 Use
9880 <I>keymap</I>
9881
9882 as the keymap to be affected by the subsequent bindings.
9883 Acceptable
9884 <I>keymap</I>
9885
9886 names are
9887 <I>emacs, emacs-standard, emacs-meta, emacs-ctlx, vi,
9888 vi-move, vi-command</I>, and
9889 <I>vi-insert</I>.
9890
9891 <I>vi</I> is equivalent to <I>vi-command</I> (<I>vi-move</I> is also
9892 a synonym); <I>emacs</I> is
9893 equivalent to <I>emacs-standard</I>.
9894 <DT><B>-l</B>
9895
9896 <DD>
9897 List the names of all <B>readline</B> functions.
9898 <DT><B>-p</B>
9899
9900 <DD>
9901 Display <B>readline</B> function names and bindings in such a way
9902 that they can be re-read.
9903 <DT><B>-P</B>
9904
9905 <DD>
9906 List current <B>readline</B> function names and bindings.
9907 <DT><B>-s</B>
9908
9909 <DD>
9910 Display <B>readline</B> key sequences bound to macros and the strings
9911 they output in such a way that they can be re-read.
9912 <DT><B>-S</B>
9913
9914 <DD>
9915 Display <B>readline</B> key sequences bound to macros and the strings
9916 they output.
9917 <DT><B>-v</B>
9918
9919 <DD>
9920 Display <B>readline</B> variable names and values in such a way that they
9921 can be re-read.
9922 <DT><B>-V</B>
9923
9924 <DD>
9925 List current <B>readline</B> variable names and values.
9926 <DT><B>-f </B><I>filename</I>
9927
9928 <DD>
9929 Read key bindings from <I>filename</I>.
9930 <DT><B>-q </B><I>function</I>
9931
9932 <DD>
9933 Query about which keys invoke the named <I>function</I>.
9934 <DT><B>-u </B><I>function</I>
9935
9936 <DD>
9937 Unbind all keys bound to the named <I>function</I>.
9938 <DT><B>-r </B><I>keyseq</I>
9939
9940 <DD>
9941 Remove any current binding for <I>keyseq</I>.
9942 <DT><B>-x </B><I>keyseq</I>:<I>shell-command</I>
9943
9944 <DD>
9945 Cause <I>shell-command</I> to be executed whenever <I>keyseq</I> is
9946 entered.
9947 When <I>shell-command</I> is executed, the shell sets the
9948 <FONT SIZE=-1><B>READLINE_LINE</B>
9949
9950 </FONT>
9951 variable to the contents of the <B>readline</B> line buffer and the
9952 <FONT SIZE=-1><B>READLINE_POINT</B>
9953
9954 </FONT>
9955 and
9956 <FONT SIZE=-1><B>READLINE_MARK</B>
9957
9958 </FONT>
9959 variables to the current location of the insertion point and the saved
9960 insertion point (the mark), respectively.
9961 The shell assigns any numeric argument the user supplied to the
9962 <FONT SIZE=-1><B>READLINE_ARGUMENT</B>
9963
9964 </FONT>
9965 variable.
9966 If there was no argument, that variable is not set.
9967 If the executed command changes the value of any of
9968 <FONT SIZE=-1><B>READLINE_LINE</B>,
9969
9970 </FONT>
9971 <FONT SIZE=-1><B>READLINE_POINT</B>,
9972
9973 </FONT>
9974 or
9975 <FONT SIZE=-1><B>READLINE_MARK</B>,
9976
9977 </FONT>
9978 those new values will be reflected in the editing state.
9979 <DT><B>-X</B>
9980
9981 <DD>
9982 List all key sequences bound to shell commands and the associated commands
9983 in a format that can be reused as input.
9984
9985 </DL>
9986 <P>
9987
9988 The return value is 0 unless an unrecognized option is given or an
9989 error occurred.
9990 </DL>
9991
9992 <DT><B>break</B> [<I>n</I>]<DD>
9993 Exit from within a
9994 <B>for</B>,
9995
9996 <B>while</B>,
9997
9998 <B>until</B>,
9999
10000 or
10001 <B>select</B>
10002
10003 loop. If <I>n</I> is specified, break <I>n</I> levels.
10004 <I>n</I>
10005
10006 must be >= 1. If
10007 <I>n</I>
10008
10009 is greater than the number of enclosing loops, all enclosing loops
10010 are exited.
10011 The return value is 0 unless <I>n</I> is not greater than or equal to 1.
10012 <DT><B>builtin</B> <I>shell-builtin</I> [<I>arguments</I>]<DD>
10013 Execute the specified shell builtin, passing it
10014 <I>arguments</I>,
10015
10016 and return its exit status.
10017 This is useful when defining a
10018 function whose name is the same as a shell builtin,
10019 retaining the functionality of the builtin within the function.
10020 The <B>cd</B> builtin is commonly redefined this way.
10021 The return status is false if
10022 <I>shell-builtin</I>
10023
10024 is not a shell builtin command.
10025 <DT><B>caller</B> [<I>expr</I>]<DD>
10026 Returns the context of any active subroutine call (a shell function or
10027 a script executed with the <B>.</B> or <B>source</B> builtins).
10028 Without <I>expr</I>, <B>caller</B> displays the line number and source
10029 filename of the current subroutine call.
10030 If a non-negative integer is supplied as <I>expr</I>, <B>caller</B>
10031 displays the line number, subroutine name, and source file corresponding
10032 to that position in the current execution call stack. This extra
10033 information may be used, for example, to print a stack trace. The
10034 current frame is frame 0.
10035 The return value is 0 unless the shell is not executing a subroutine
10036 call or <I>expr</I> does not correspond to a valid position in the
10037 call stack.
10038 <DT><B>cd</B> [<B>-L</B>|[<B>-P</B> [<B>-e</B>]] [-@]] [<I>dir</I>]<DD>
10039 Change the current directory to <I>dir</I>.
10040 if <I>dir</I> is not supplied, the value of the
10041 <FONT SIZE=-1><B>HOME</B>
10042
10043 </FONT>
10044 shell variable is the default.
10045 The variable
10046 <FONT SIZE=-1><B>CDPATH</B>
10047
10048 </FONT>
10049 defines the search path for the directory containing
10050 <I>dir</I>:
10051
10052 each directory name in
10053 <FONT SIZE=-1><B>CDPATH</B>
10054
10055 </FONT>
10056 is searched for <I>dir</I>.
10057 Alternative directory names in
10058 <FONT SIZE=-1><B>CDPATH</B>
10059
10060 </FONT>
10061 are separated by a colon (:). A null directory name in
10062 <FONT SIZE=-1><B>CDPATH</B>
10063
10064 </FONT>
10065 is the same as the current directory, i.e., ``<B>.</B>''. If
10066 <I>dir</I>
10067
10068 begins with a slash (/),
10069 then
10070 <FONT SIZE=-1><B>CDPATH</B>
10071
10072 </FONT>
10073 is not used. The
10074 <B>-P</B>
10075
10076 option causes <B>cd</B> to use the physical directory structure
10077 by resolving symbolic links while traversing <I>dir</I> and
10078 before processing instances of <I>..</I> in <I>dir</I> (see also the
10079 <B>-P</B>
10080
10081 option to the
10082 <B>set</B>
10083
10084 builtin command); the
10085 <B>-L</B>
10086
10087 option forces symbolic links to be followed by resolving the link
10088 after processing instances of <I>..</I> in <I>dir</I>.
10089 If <I>..</I> appears in <I>dir</I>, it is processed by removing the
10090 immediately previous pathname component from <I>dir</I>, back to a slash
10091 or the beginning of <I>dir</I>.
10092 If the
10093 <B>-e</B>
10094
10095 option is supplied with
10096 <B>-P</B>,
10097
10098 and the current working directory cannot be successfully determined
10099 after a successful directory change, <B>cd</B> will return an unsuccessful
10100 status.
10101 On systems that support it, the <B>-@</B> option presents the extended
10102 attributes associated with a file as a directory.
10103 An argument of
10104 <B>-</B>
10105
10106 is converted to
10107 <FONT SIZE=-1><B>$OLDPWD</B>
10108
10109 </FONT>
10110 before the directory change is attempted.
10111 If a non-empty directory name from
10112 <FONT SIZE=-1><B>CDPATH</B>
10113
10114 </FONT>
10115 is used, or if
10116 <B>-</B> is the first argument, and the directory change is
10117 successful, the absolute pathname of the new working directory is
10118 written to the standard output.
10119 If the directory change is successful, <B>cd</B> sets the value of the
10120 <B>PWD</B> environment variable to the new directory name, and sets the
10121 <B>OLDPWD</B> environment variable to the value of the current working
10122 directory before the change.
10123 The return value is true if the directory was successfully changed;
10124 false otherwise.
10125 <DT><B>command</B> [<B>-pVv</B>] <I>command</I> [<I>arg</I> ...]<DD>
10126 Run
10127 <I>command</I>
10128
10129 with
10130 <I>args</I>
10131
10132 suppressing the normal shell function lookup.
10133 Only builtin commands or commands found in the
10134 <FONT SIZE=-1><B>PATH</B>
10135
10136 </FONT>
10137 are executed. If the
10138 <B>-p</B>
10139
10140 option is given, the search for
10141 <I>command</I>
10142
10143 is performed using a default value for
10144 <FONT SIZE=-1><B>PATH</B>
10145
10146 </FONT>
10147 that is guaranteed to find all of the standard utilities.
10148 If either the
10149 <B>-V</B>
10150
10151 or
10152 <B>-v</B>
10153
10154 option is supplied, a description of
10155 <I>command</I>
10156
10157 is printed. The
10158 <B>-v</B>
10159
10160 option causes a single word indicating the command or filename
10161 used to invoke
10162 <I>command</I>
10163
10164 to be displayed; the
10165 <B>-V</B>
10166
10167 option produces a more verbose description.
10168 If the
10169 <B>-V</B>
10170
10171 or
10172 <B>-v</B>
10173
10174 option is supplied, the exit status is 0 if
10175 <I>command</I>
10176
10177 was found, and 1 if not. If neither option is supplied and
10178 an error occurred or
10179 <I>command</I>
10180
10181 cannot be found, the exit status is 127. Otherwise, the exit status of the
10182 <B>command</B>
10183
10184 builtin is the exit status of
10185 <I>command</I>.
10186
10187 <DT><B>compgen</B> [<I>option</I>] [<I>word</I>]<DD>
10188 Generate possible completion matches for <I>word</I> according to
10189 the <I>option</I>s, which may be any option accepted by the
10190 <B>complete</B>
10191
10192 builtin with the exception of <B>-p</B> and <B>-r</B>, and write
10193 the matches to the standard output.
10194 When using the <B>-F</B> or <B>-C</B> options, the various shell variables
10195 set by the programmable completion facilities, while available, will not
10196 have useful values.
10197 <P>
10198 The matches will be generated in the same way as if the programmable
10199 completion code had generated them directly from a completion specification
10200 with the same flags.
10201 If <I>word</I> is specified, only those completions matching <I>word</I>
10202 will be displayed.
10203 <P>
10204 The return value is true unless an invalid option is supplied, or no
10205 matches were generated.
10206 <DT><B>complete</B> [<B>-abcdefgjksuv</B>] [<B>-o</B> <I>comp-option</I>] [<B>-DEI</B>] [<B>-A</B> <I>action</I>] [<B>-G</B> <I>globpat</I>] [<B>-W</B> <I>wordlist</I>]<DD>
10207 <BR>
10208
10209 [<B>-F</B> <I>function</I>] [<B>-C</B> <I>command</I>] [<B>-X</B> <I>filterpat</I>] [<B>-P</B> <I>prefix</I>] [<B>-S</B> <I>suffix</I>] <I>name</I> [<I>name ...</I>]
10210
10211 <DT><B>complete</B> <B>-pr</B> [<B>-DEI</B>] [<I>name</I> ...]<DD>
10212
10213 Specify how arguments to each <I>name</I> should be completed.
10214 If the <B>-p</B> option is supplied, or if no options are supplied,
10215 existing completion specifications are printed in a way that allows
10216 them to be reused as input.
10217 The <B>-r</B> option removes a completion specification for
10218 each <I>name</I>, or, if no <I>name</I>s are supplied, all
10219 completion specifications.
10220 The <B>-D</B> option indicates that other supplied options and actions should
10221 apply to the ``default'' command completion; that is, completion attempted
10222 on a command for which no completion has previously been defined.
10223 The <B>-E</B> option indicates that other supplied options and actions should
10224 apply to ``empty'' command completion; that is, completion attempted on a
10225 blank line.
10226 The <B>-I</B> option indicates that other supplied options and actions should
10227 apply to completion on the initial non-assignment word on the line, or after
10228 a command delimiter such as <B>;</B> or <B>|</B>, which is usually command
10229 name completion.
10230 If multiple options are supplied, the <B>-D</B> option takes precedence
10231 over <B>-E</B>, and both take precedence over <B>-I</B>.
10232 If any of <B>-D</B>, <B>-E</B>, or <B>-I</B> are supplied, any other
10233 <I>name</I> arguments are ignored; these completions only apply to the case
10234 specified by the option.
10235 <P>
10236 The process of applying these completion specifications when word completion
10237 is attempted is described
10238
10239 above under <B>Programmable Completion</B>.
10240 <P>
10241 Other options, if specified, have the following meanings.
10242 The arguments to the <B>-G</B>, <B>-W</B>, and <B>-X</B> options
10243 (and, if necessary, the <B>-P</B> and <B>-S</B> options)
10244 should be quoted to protect them from expansion before the
10245 <B>complete</B>
10246
10247 builtin is invoked.
10248 <DL COMPACT><DT><DD>
10249
10250 <DL COMPACT>
10251 <DT><B>-o</B> <I>comp-option</I><DD>
10252 The <I>comp-option</I> controls several aspects of the compspec's behavior
10253 beyond the simple generation of completions.
10254 <I>comp-option</I> may be one of:
10255 <DL COMPACT><DT><DD>
10256 <DL COMPACT>
10257 <DT><B>bashdefault</B>
10258
10259 <DD>
10260 Perform the rest of the default <B>bash</B> completions if the compspec
10261 generates no matches.
10262 <DT><B>default</B>
10263
10264 <DD>
10265 Use readline's default filename completion if the compspec generates
10266 no matches.
10267 <DT><B>dirnames</B>
10268
10269 <DD>
10270 Perform directory name completion if the compspec generates no matches.
10271 <DT><B>filenames</B>
10272
10273 <DD>
10274 Tell readline that the compspec generates filenames, so it can perform any
10275 filename-specific processing (like adding a slash to directory names,
10276 quoting special characters, or suppressing trailing spaces).
10277 Intended to be used with shell functions.
10278 <DT><B>noquote</B>
10279
10280 <DD>
10281 Tell readline not to quote the completed words if they are filenames
10282 (quoting filenames is the default).
10283 <DT><B>nosort</B>
10284
10285 <DD>
10286 Tell readline not to sort the list of possible completions alphabetically.
10287 <DT><B>nospace</B>
10288
10289 <DD>
10290 Tell readline not to append a space (the default) to words completed at
10291 the end of the line.
10292 <DT><B>plusdirs</B>
10293
10294 <DD>
10295 After any matches defined by the compspec are generated,
10296 directory name completion is attempted and any
10297 matches are added to the results of the other actions.
10298 </DL></DL>
10299
10300 <DT><B>-A</B> <I>action</I><DD>
10301 The <I>action</I> may be one of the following to generate a list of possible
10302 completions:
10303 <DL COMPACT><DT><DD>
10304 <DL COMPACT>
10305 <DT><B>alias</B>
10306
10307 <DD>
10308 Alias names. May also be specified as <B>-a</B>.
10309 <DT><B>arrayvar</B>
10310
10311 <DD>
10312 Array variable names.
10313 <DT><B>binding</B>
10314
10315 <DD>
10316 <B>Readline</B> key binding names.
10317 <DT><B>builtin</B>
10318
10319 <DD>
10320 Names of shell builtin commands. May also be specified as <B>-b</B>.
10321 <DT><B>command</B>
10322
10323 <DD>
10324 Command names. May also be specified as <B>-c</B>.
10325 <DT><B>directory</B>
10326
10327 <DD>
10328 Directory names. May also be specified as <B>-d</B>.
10329 <DT><B>disabled</B>
10330
10331 <DD>
10332 Names of disabled shell builtins.
10333 <DT><B>enabled</B>
10334
10335 <DD>
10336 Names of enabled shell builtins.
10337 <DT><B>export</B>
10338
10339 <DD>
10340 Names of exported shell variables. May also be specified as <B>-e</B>.
10341 <DT><B>file</B>
10342
10343 <DD>
10344 File names. May also be specified as <B>-f</B>.
10345 <DT><B>function</B>
10346
10347 <DD>
10348 Names of shell functions.
10349 <DT><B>group</B>
10350
10351 <DD>
10352 Group names. May also be specified as <B>-g</B>.
10353 <DT><B>helptopic</B>
10354
10355 <DD>
10356 Help topics as accepted by the <B>help</B> builtin.
10357 <DT><B>hostname</B>
10358
10359 <DD>
10360 Hostnames, as taken from the file specified by the
10361 <FONT SIZE=-1><B>HOSTFILE</B>
10362
10363 </FONT>
10364 shell variable.
10365 <DT><B>job</B>
10366
10367 <DD>
10368 Job names, if job control is active. May also be specified as <B>-j</B>.
10369 <DT><B>keyword</B>
10370
10371 <DD>
10372 Shell reserved words. May also be specified as <B>-k</B>.
10373 <DT><B>running</B>
10374
10375 <DD>
10376 Names of running jobs, if job control is active.
10377 <DT><B>service</B>
10378
10379 <DD>
10380 Service names. May also be specified as <B>-s</B>.
10381 <DT><B>setopt</B>
10382
10383 <DD>
10384 Valid arguments for the <B>-o</B> option to the <B>set</B> builtin.
10385 <DT><B>shopt</B>
10386
10387 <DD>
10388 Shell option names as accepted by the <B>shopt</B> builtin.
10389 <DT><B>signal</B>
10390
10391 <DD>
10392 Signal names.
10393 <DT><B>stopped</B>
10394
10395 <DD>
10396 Names of stopped jobs, if job control is active.
10397 <DT><B>user</B>
10398
10399 <DD>
10400 User names. May also be specified as <B>-u</B>.
10401 <DT><B>variable</B>
10402
10403 <DD>
10404 Names of all shell variables. May also be specified as <B>-v</B>.
10405 </DL></DL>
10406
10407 <DT><B>-C</B> <I>command</I><DD>
10408 <I>command</I> is executed in a subshell environment, and its output is
10409 used as the possible completions.
10410 Arguments are passed as with the <B>-F</B> option.
10411 <DT><B>-F</B> <I>function</I><DD>
10412 The shell function <I>function</I> is executed in the current shell
10413 environment.
10414 When the function is executed,
10415 the first argument (<B>$1</B>) is the name of the command whose arguments are
10416 being completed,
10417 the second argument (<B>$2</B>) is the word being completed,
10418 and the third argument (<B>$3</B>) is the word preceding the word being
10419 completed on the current command line.
10420 When it finishes, the possible completions are retrieved from the value
10421 of the
10422 <FONT SIZE=-1><B>COMPREPLY</B>
10423
10424 </FONT>
10425 array variable.
10426 <DT><B>-G</B> <I>globpat</I><DD>
10427 The pathname expansion pattern <I>globpat</I> is expanded to generate
10428 the possible completions.
10429 <DT><B>-P</B> <I>prefix</I><DD>
10430 <I>prefix</I> is added at the beginning of each possible completion
10431 after all other options have been applied.
10432 <DT><B>-S</B> <I>suffix</I><DD>
10433 <I>suffix</I> is appended to each possible completion
10434 after all other options have been applied.
10435 <DT><B>-W</B> <I>wordlist</I><DD>
10436 The <I>wordlist</I> is split using the characters in the
10437 <FONT SIZE=-1><B>IFS</B>
10438
10439 </FONT>
10440 special variable as delimiters, and each resultant word is expanded.
10441 Shell quoting is honored within <I>wordlist</I>,
10442 in order to provide a
10443 mechanism for the words to contain shell metacharacters or characters
10444 in the value of
10445 <FONT SIZE=-1><B>IFS</B>.
10446
10447 </FONT>
10448 The possible completions are the members of the resultant list which
10449 match the word being completed.
10450 <DT><B>-X</B> <I>filterpat</I><DD>
10451 <I>filterpat</I> is a pattern as used for pathname expansion.
10452 It is applied to the list of possible completions generated by the
10453 preceding options and arguments, and each completion matching
10454 <I>filterpat</I> is removed from the list.
10455 A leading <B>!</B> in <I>filterpat</I> negates the pattern; in this
10456 case, any completion not matching <I>filterpat</I> is removed.
10457
10458 </DL>
10459 <P>
10460
10461 The return value is true unless an invalid option is supplied, an option
10462 other than <B>-p</B> or <B>-r</B> is supplied without a <I>name</I>
10463 argument, an attempt is made to remove a completion specification for
10464 a <I>name</I> for which no specification exists, or
10465 an error occurs adding a completion specification.
10466 </DL>
10467
10468 <DT><B>compopt</B> [<B>-o</B> <I>option</I>] [<B>-DEI</B>] [<B>+o</B> <I>option</I>] [<I>name</I>]<DD>
10469 Modify completion options for each <I>name</I> according to the
10470 <I>option</I>s, or for the
10471 currently-executing completion if no <I>name</I>s are supplied.
10472 If no <I>option</I>s are given, display the completion options for each
10473 <I>name</I> or the current completion.
10474 The possible values of <I>option</I> are those valid for the <B>complete</B>
10475 builtin described above.
10476 The <B>-D</B> option indicates that other supplied options should
10477 apply to the ``default'' command completion; that is, completion attempted
10478 on a command for which no completion has previously been defined.
10479 The <B>-E</B> option indicates that other supplied options should
10480 apply to ``empty'' command completion; that is, completion attempted on a
10481 blank line.
10482 The <B>-I</B> option indicates that other supplied options should
10483 apply to completion on the initial non-assignment word on the line,
10484 or after a command delimiter such as <B>;</B> or <B>|</B>, which is usually
10485 command name completion.
10486 <P>
10487 The return value is true unless an invalid option is supplied, an attempt
10488 is made to modify the options for a <I>name</I> for which no completion
10489 specification exists, or an output error occurs.
10490 <DT><B>continue</B> [<I>n</I>]<DD>
10491 Resume the next iteration of the enclosing
10492 <B>for</B>,
10493
10494 <B>while</B>,
10495
10496 <B>until</B>,
10497
10498 or
10499 <B>select</B>
10500
10501 loop.
10502 If
10503 <I>n</I>
10504
10505 is specified, resume at the <I>n</I>th enclosing loop.
10506 <I>n</I>
10507
10508 must be >= 1. If
10509 <I>n</I>
10510
10511 is greater than the number of enclosing loops, the last enclosing loop
10512 (the ``top-level'' loop) is resumed.
10513 The return value is 0 unless <I>n</I> is not greater than or equal to 1.
10514 <DT><B>declare</B> [<B>-aAfFgiIlnrtux</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
10515
10516 <DT><B>typeset</B> [<B>-aAfFgiIlnrtux</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
10517
10518 Declare variables and/or give them attributes.
10519 If no <I>name</I>s are given then display the values of variables.
10520 The
10521 <B>-p</B>
10522
10523 option will display the attributes and values of each
10524 <I>name</I>.
10525
10526 When
10527 <B>-p</B>
10528
10529 is used with <I>name</I> arguments, additional options,
10530 other than <B>-f</B> and <B>-F</B>, are ignored.
10531 When
10532 <B>-p</B>
10533
10534 is supplied without <I>name</I> arguments, it will display the attributes
10535 and values of all variables having the attributes specified by the
10536 additional options.
10537 If no other options are supplied with <B>-p</B>, <B>declare</B> will display
10538 the attributes and values of all shell variables. The <B>-f</B> option
10539 will restrict the display to shell functions.
10540 The
10541 <B>-F</B>
10542
10543 option inhibits the display of function definitions; only the
10544 function name and attributes are printed.
10545 If the <B>extdebug</B> shell option is enabled using <B>shopt</B>,
10546 the source file name and line number where each <I>name</I>
10547 is defined are displayed as well. The
10548 <B>-F</B>
10549
10550 option implies
10551 <B>-f</B>.
10552
10553 The
10554 <B>-g</B>
10555
10556 option forces variables to be created or modified at the global scope,
10557 even when <B>declare</B> is executed in a shell function.
10558 It is ignored in all other cases.
10559 The
10560 <B>-I</B>
10561
10562 option causes local variables to inherit the attributes
10563 (except the <I>nameref</I> attribute)
10564 and value of any existing variable with the same
10565 <I>name</I> at a surrounding scope.
10566 If there is no existing variable, the local variable is initially unset.
10567 The following options can
10568 be used to restrict output to variables with the specified attribute or
10569 to give variables attributes:
10570 <DL COMPACT><DT><DD>
10571
10572 <DL COMPACT>
10573 <DT><B>-a</B>
10574
10575 <DD>
10576 Each <I>name</I> is an indexed array variable (see
10577 <B>Arrays</B>
10578
10579
10580 above).
10581 <DT><B>-A</B>
10582
10583 <DD>
10584 Each <I>name</I> is an associative array variable (see
10585 <B>Arrays</B>
10586
10587
10588 above).
10589 <DT><B>-f</B>
10590
10591 <DD>
10592 Use function names only.
10593 <DT><B>-i</B>
10594
10595 <DD>
10596 The variable is treated as an integer; arithmetic evaluation (see
10597 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
10598
10599 </FONT>
10600
10601 above)
10602 is performed when the variable is assigned a value.
10603 <DT><B>-l</B>
10604
10605 <DD>
10606 When the variable is assigned a value, all upper-case characters are
10607 converted to lower-case.
10608 The upper-case attribute is disabled.
10609 <DT><B>-n</B>
10610
10611 <DD>
10612 Give each <I>name</I> the <I>nameref</I> attribute, making
10613 it a name reference to another variable.
10614 That other variable is defined by the value of <I>name</I>.
10615 All references, assignments, and attribute modifications
10616 to <I>name</I>, except those using or changing the
10617 <B>-n</B> attribute itself, are performed on the variable referenced by
10618 <I>name</I>'s value.
10619 The nameref attribute cannot be applied to array variables.
10620 <DT><B>-r</B>
10621
10622 <DD>
10623 Make <I>name</I>s readonly. These names cannot then be assigned values
10624 by subsequent assignment statements or unset.
10625 <DT><B>-t</B>
10626
10627 <DD>
10628 Give each <I>name</I> the <I>trace</I> attribute.
10629 Traced functions inherit the <B>DEBUG</B> and <B>RETURN</B> traps from
10630 the calling shell.
10631 The trace attribute has no special meaning for variables.
10632 <DT><B>-u</B>
10633
10634 <DD>
10635 When the variable is assigned a value, all lower-case characters are
10636 converted to upper-case.
10637 The lower-case attribute is disabled.
10638 <DT><B>-x</B>
10639
10640 <DD>
10641 Mark <I>name</I>s for export to subsequent commands via the environment.
10642
10643 </DL>
10644 <P>
10645
10646 Using `+' instead of `-'
10647 turns off the attribute instead,
10648 with the exceptions that <B>+a</B> and <B>+A</B>
10649 may not be used to destroy array variables and <B>+r</B> will not
10650 remove the readonly attribute.
10651 When used in a function,
10652 <B>declare</B>
10653
10654 and
10655 <B>typeset</B>
10656
10657 make each
10658 <I>name</I> local, as with the
10659 <B>local</B>
10660
10661 command,
10662 unless the <B>-g</B> option is supplied.
10663 If a variable name is followed by =<I>value</I>, the value of
10664 the variable is set to <I>value</I>.
10665 When using <B>-a</B> or <B>-A</B> and the compound assignment syntax to
10666 create array variables, additional attributes do not take effect until
10667 subsequent assignments.
10668 The return value is 0 unless an invalid option is encountered,
10669 an attempt is made to define a function using
10670
10671 <TT>-f foo=bar</TT>,
10672 an attempt is made to assign a value to a readonly variable,
10673 an attempt is made to assign a value to an array variable without
10674 using the compound assignment syntax (see
10675 <B>Arrays</B>
10676
10677
10678 above),
10679 one of the <I>names</I> is not a valid shell variable name,
10680 an attempt is made to turn off readonly status for a readonly variable,
10681 an attempt is made to turn off array status for an array variable,
10682 or an attempt is made to display a non-existent function with <B>-f</B>.
10683 </DL>
10684
10685 <DT><B>dirs [-clpv</B>] [+<I>n</I>] [-<I>n</I>]
10686
10687 <DD>
10688 Without options, displays the list of currently remembered directories.
10689 The default display is on a single line with directory names separated
10690 by spaces.
10691 Directories are added to the list with the
10692 <B>pushd</B>
10693
10694 command; the
10695 <B>popd</B>
10696
10697 command removes entries from the list.
10698 The current directory is always the first directory in the stack.
10699 <DL COMPACT><DT><DD>
10700
10701 <DL COMPACT>
10702 <DT><B>-c</B>
10703
10704 <DD>
10705 Clears the directory stack by deleting all of the entries.
10706 <DT><B>-l</B>
10707
10708 <DD>
10709 Produces a listing using full pathnames;
10710 the default listing format uses a tilde to denote the home directory.
10711 <DT><B>-p</B>
10712
10713 <DD>
10714 Print the directory stack with one entry per line.
10715 <DT><B>-v</B>
10716
10717 <DD>
10718 Print the directory stack with one entry per line,
10719 prefixing each entry with its index in the stack.
10720 <DT><B>+</B><I>n</I><DD>
10721 Displays the <I>n</I>th entry counting from the left of the list
10722 shown by
10723 <B>dirs</B>
10724
10725 when invoked without options, starting with zero.
10726 <DT><B>-</B><I>n</I><DD>
10727 Displays the <I>n</I>th entry counting from the right of the list
10728 shown by
10729 <B>dirs</B>
10730
10731 when invoked without options, starting with zero.
10732
10733 </DL>
10734 <P>
10735
10736 The return value is 0 unless an
10737 invalid option is supplied or <I>n</I> indexes beyond the end
10738 of the directory stack.
10739 </DL>
10740
10741 <DT><B>disown</B> [<B>-ar</B>] [<B>-h</B>] [<I>jobspec</I> ... | <I>pid</I> ... ]<DD>
10742 Without options, remove each
10743 <I>jobspec</I>
10744
10745 from the table of active jobs.
10746 If
10747 <I>jobspec</I>
10748
10749 is not present, and neither the <B>-a</B> nor the <B>-r</B> option
10750 is supplied, the <I>current job</I> is used.
10751 If the <B>-h</B> option is given, each
10752 <I>jobspec</I>
10753
10754 is not removed from the table, but is marked so that
10755 <FONT SIZE=-1><B>SIGHUP</B>
10756
10757 </FONT>
10758 is not sent to the job if the shell receives a
10759 <FONT SIZE=-1><B>SIGHUP</B>.
10760
10761 </FONT>
10762 If no
10763 <I>jobspec</I>
10764
10765 is supplied, the
10766 <B>-a</B>
10767
10768 option means to remove or mark all jobs; the
10769 <B>-r</B>
10770
10771 option without a
10772 <I>jobspec</I>
10773
10774 argument restricts operation to running jobs.
10775 The return value is 0 unless a
10776 <I>jobspec</I>
10777
10778 does not specify a valid job.
10779 <DT><B>echo</B> [<B>-neE</B>] [<I>arg</I> ...]<DD>
10780 Output the <I>arg</I>s, separated by spaces, followed by a newline.
10781 The return status is 0 unless a write error occurs.
10782 If <B>-n</B> is specified, the trailing newline is
10783 suppressed. If the <B>-e</B> option is given, interpretation of
10784 the following backslash-escaped characters is enabled. The
10785 <B>-E</B>
10786
10787 option disables the interpretation of these escape characters,
10788 even on systems where they are interpreted by default.
10789 The <B>xpg_echo</B> shell option may be used to
10790 dynamically determine whether or not <B>echo</B> expands these
10791 escape characters by default.
10792 <B>echo</B>
10793
10794 does not interpret <B>--</B> to mean the end of options.
10795 <B>echo</B>
10796
10797 interprets the following escape sequences:
10798 <DL COMPACT><DT><DD>
10799
10800 <DL COMPACT>
10801 <DT><B>\a</B>
10802
10803 <DD>
10804 alert (bell)
10805 <DT><B>\b</B>
10806
10807 <DD>
10808 backspace
10809 <DT><B>\c</B>
10810
10811 <DD>
10812 suppress further output
10813 <DT><B>\e</B>
10814
10815 <DD>
10816 <DT><B>\E</B>
10817
10818 <DD>
10819 an escape character
10820 <DT><B>\f</B>
10821
10822 <DD>
10823 form feed
10824 <DT><B>\n</B>
10825
10826 <DD>
10827 new line
10828 <DT><B>\r</B>
10829
10830 <DD>
10831 carriage return
10832 <DT><B>\t</B>
10833
10834 <DD>
10835 horizontal tab
10836 <DT><B>\v</B>
10837
10838 <DD>
10839 vertical tab
10840 <DT><B>\\</B>
10841
10842 <DD>
10843 backslash
10844 <DT><B>\0</B><I>nnn</I>
10845
10846 <DD>
10847 the eight-bit character whose value is the octal value <I>nnn</I>
10848 (zero to three octal digits)
10849 <DT><B>\x</B><I>HH</I>
10850
10851 <DD>
10852 the eight-bit character whose value is the hexadecimal value <I>HH</I>
10853 (one or two hex digits)
10854 <DT><B>\u</B><I>HHHH</I>
10855
10856 <DD>
10857 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
10858 <I>HHHH</I> (one to four hex digits)
10859 <DT><B>\U</B><I>HHHHHHHH</I>
10860
10861 <DD>
10862 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
10863 <I>HHHHHHHH</I> (one to eight hex digits)
10864
10865 </DL></DL>
10866
10867 <DT><B>enable</B> [<B>-a</B>] [<B>-dnps</B>] [<B>-f</B> <I>filename</I>] [<I>name</I> ...]<DD>
10868 Enable and disable builtin shell commands.
10869 Disabling a builtin allows a disk command which has the same name
10870 as a shell builtin to be executed without specifying a full pathname,
10871 even though the shell normally searches for builtins before disk commands.
10872 If <B>-n</B> is used, each <I>name</I>
10873 is disabled; otherwise,
10874 <I>names</I> are enabled. For example, to use the
10875 <B>test</B>
10876
10877 binary found via the
10878 <FONT SIZE=-1><B>PATH</B>
10879
10880 </FONT>
10881 instead of the shell builtin version, run
10882 <TT>enable -n test</TT>.
10883
10884 The
10885 <B>-f</B>
10886
10887 option means to load the new builtin command
10888 <I>name</I>
10889
10890 from shared object
10891 <I>filename</I>,
10892
10893 on systems that support dynamic loading.
10894 Bash will use the value of the <B>BASH_LOADABLES_PATH</B> variable as a
10895 colon-separated list of directories in which to search for <I>filename</I>.
10896 The default is system-dependent.
10897 The
10898 <B>-d</B>
10899
10900 option will delete a builtin previously loaded with
10901 <B>-f</B>.
10902
10903 If no <I>name</I> arguments are given, or if the
10904 <B>-p</B>
10905
10906 option is supplied, a list of shell builtins is printed.
10907 With no other option arguments, the list consists of all enabled
10908 shell builtins.
10909 If <B>-n</B> is supplied, only disabled builtins are printed.
10910 If <B>-a</B> is supplied, the list printed includes all builtins, with an
10911 indication of whether or not each is enabled.
10912 If <B>-s</B> is supplied, the output is restricted to the POSIX
10913 <I>special</I> builtins.
10914 If no options are supplied and a <I>name</I> is not a shell builtin,
10915 <B>enable</B> will attempt to load <I>name</I> from a shared object named
10916 <I>name</I>, as if the command were
10917 <TT>enable -f</TT> <I>name name</I> .
10918
10919 The return value is 0 unless a
10920 <I>name</I>
10921
10922 is not a shell builtin or there is an error loading a new builtin
10923 from a shared object.
10924 <DT><B>eval</B> [<I>arg</I> ...]<DD>
10925 The <I>arg</I>s are read and concatenated together into a single
10926 command. This command is then read and executed by the shell, and
10927 its exit status is returned as the value of
10928 <B>eval</B>.
10929
10930 If there are no
10931 <I>args</I>,
10932
10933 or only null arguments,
10934 <B>eval</B>
10935
10936 returns 0.
10937 <DT><B>exec</B> [<B>-cl</B>] [<B>-a</B> <I>name</I>] [<I>command</I> [<I>arguments</I>]]<DD>
10938 If
10939 <I>command</I>
10940
10941 is specified, it replaces the shell.
10942 No new process is created. The
10943 <I>arguments</I>
10944
10945 become the arguments to <I>command</I>.
10946 If the
10947 <B>-l</B>
10948
10949 option is supplied,
10950 the shell places a dash at the beginning of the zeroth argument passed to
10951 <I>command</I>.
10952
10953 This is what
10954 <I>login</I>(1)
10955
10956 does. The
10957 <B>-c</B>
10958
10959 option causes
10960 <I>command</I>
10961
10962 to be executed with an empty environment. If
10963 <B>-a</B>
10964
10965 is supplied, the shell passes
10966 <I>name</I>
10967
10968 as the zeroth argument to the executed command.
10969 If
10970 <I>command</I>
10971
10972 cannot be executed for some reason, a non-interactive shell exits,
10973 unless the
10974 <B>execfail</B>
10975
10976 shell option
10977 is enabled. In that case, it returns failure.
10978 An interactive shell returns failure if the file cannot be executed.
10979 A subshell exits unconditionally if <B>exec</B> fails.
10980 If
10981 <I>command</I>
10982
10983 is not specified, any redirections take effect in the current shell,
10984 and the return status is 0. If there is a redirection error, the
10985 return status is 1.
10986 <DT><B>exit</B> [<I>n</I>]<DD>
10987 Cause the shell to exit
10988 with a status of <I>n</I>. If
10989 <I>n</I>
10990
10991 is omitted, the exit status
10992 is that of the last command executed.
10993 A trap on
10994 <FONT SIZE=-1><B>EXIT</B>
10995
10996 </FONT>
10997 is executed before the shell terminates.
10998 <DT><B>export</B> [<B>-fn</B>] [<I>name</I>[=<I>word</I>]] ...<DD>
10999
11000 <DT><B>export -p</B>
11001
11002 <DD>
11003
11004 The supplied
11005 <I>names</I>
11006
11007 are marked for automatic export to the environment of
11008 subsequently executed commands. If the
11009 <B>-f</B>
11010
11011 option is given, the
11012 <I>names</I>
11013
11014 refer to functions.
11015 If no
11016 <I>names</I>
11017
11018 are given, or if the
11019 <B>-p</B>
11020
11021 option is supplied, a list
11022 of names of all exported variables is printed.
11023 The
11024 <B>-n</B>
11025
11026 option causes the export property to be removed from each
11027 <I>name</I>.
11028 If a variable name is followed by =<I>word</I>, the value of
11029 the variable is set to <I>word</I>.
11030 <B>export</B>
11031
11032 returns an exit status of 0 unless an invalid option is
11033 encountered,
11034 one of the <I>names</I> is not a valid shell variable name, or
11035 <B>-f</B>
11036
11037 is supplied with a
11038 <I>name</I>
11039
11040 that is not a function.
11041 <DT><B>fc</B> [<B>-e</B> <I>ename</I>] [<B>-lnr</B>] [<I>first</I>] [<I>last</I>]<DD>
11042
11043 <DT><B>fc</B> <B>-s</B> [<I>pat</I>=<I>rep</I>] [<I>cmd</I>]<DD>
11044
11045 The first form selects a range of commands from
11046 <I>first</I>
11047
11048 to
11049 <I>last</I>
11050
11051 from the history list and displays or edits and re-executes them.
11052 <I>First</I>
11053
11054 and
11055 <I>last</I>
11056
11057 may be specified as a string (to locate the last command beginning
11058 with that string) or as a number (an index into the history list,
11059 where a negative number is used as an offset from the current
11060 command number).
11061 When listing, a <I>first</I> or <I>last</I> of
11062 0 is equivalent to -1 and -0 is equivalent to the current
11063 command (usually the <B>fc</B> command); otherwise 0 is equivalent to -1
11064 and -0 is invalid.
11065 If
11066 <I>last</I>
11067
11068 is not specified, it is set to
11069 the current command for listing (so that
11070
11071 <TT>fc -l -10</TT>
11072 prints the last 10 commands) and to
11073 <I>first</I>
11074
11075 otherwise.
11076 If
11077 <I>first</I>
11078
11079 is not specified, it is set to the previous
11080 command for editing and -16 for listing.
11081 <P>
11082 The
11083 <B>-n</B>
11084
11085 option suppresses
11086 the command numbers when listing. The
11087 <B>-r</B>
11088
11089 option reverses the order of
11090 the commands. If the
11091 <B>-l</B>
11092
11093 option is given,
11094 the commands are listed on
11095 standard output. Otherwise, the editor given by
11096 <I>ename</I>
11097
11098 is invoked
11099 on a file containing those commands. If
11100 <I>ename</I>
11101
11102 is not given, the
11103 value of the
11104 <FONT SIZE=-1><B>FCEDIT</B>
11105
11106 </FONT>
11107 variable is used, and
11108 the value of
11109 <FONT SIZE=-1><B>EDITOR</B>
11110
11111 </FONT>
11112 if
11113 <FONT SIZE=-1><B>FCEDIT</B>
11114
11115 </FONT>
11116 is not set. If neither variable is set,
11117
11118 <I>vi</I>
11119
11120 is used. When editing is complete, the edited commands are
11121 echoed and executed.
11122 <P>
11123 In the second form, <I>command</I> is re-executed after each instance
11124 of <I>pat</I> is replaced by <I>rep</I>.
11125 <I>Command</I> is interpreted the same as <I>first</I> above.
11126 A useful alias to use with this is
11127
11128 <TT>r='fc -s'</TT>,
11129 so that typing
11130
11131 <TT>r cc</TT>
11132 runs the last command beginning with
11133
11134 <TT>cc</TT>
11135 and typing
11136
11137 <TT>r</TT>
11138 re-executes the last command.
11139 <P>
11140 If the first form is used, the return value is 0 unless an invalid
11141 option is encountered or
11142 <I>first</I>
11143
11144 or
11145 <I>last</I>
11146
11147 specify history lines out of range.
11148 If the
11149 <B>-e</B>
11150
11151 option is supplied, the return value is the value of the last
11152 command executed or failure if an error occurs with the temporary
11153 file of commands. If the second form is used, the return status
11154 is that of the command re-executed, unless
11155 <I>cmd</I>
11156
11157 does not specify a valid history line, in which case
11158 <B>fc</B>
11159
11160 returns failure.
11161 <DT><B>fg</B> [<I>jobspec</I>]<DD>
11162 Resume
11163 <I>jobspec</I>
11164
11165 in the foreground, and make it the current job.
11166 If
11167 <I>jobspec</I>
11168
11169 is not present, the shell's notion of the <I>current job</I> is used.
11170 The return value is that of the command placed into the foreground,
11171 or failure if run when job control is disabled or, when run with
11172 job control enabled, if
11173 <I>jobspec</I>
11174
11175 does not specify a valid job or
11176 <I>jobspec</I>
11177
11178 specifies a job that was started without job control.
11179 <DT><B>getopts</B> <I>optstring</I> <I>name</I> [<I>arg ...</I>]<DD>
11180 <B>getopts</B>
11181
11182 is used by shell procedures to parse positional parameters.
11183 <I>optstring</I>
11184
11185 contains the option characters to be recognized; if a character
11186 is followed by a colon, the option is expected to have an
11187 argument, which should be separated from it by white space.
11188 The colon and question mark characters may not be used as
11189 option characters.
11190 Each time it is invoked,
11191 <B>getopts</B>
11192
11193 places the next option in the shell variable
11194 <I>name</I>,
11195
11196 initializing
11197 <I>name</I>
11198
11199 if it does not exist,
11200 and the index of the next argument to be processed into the
11201 variable
11202 <FONT SIZE=-1><B>OPTIND</B>.
11203
11204 </FONT>
11205 <FONT SIZE=-1><B>OPTIND</B>
11206
11207 </FONT>
11208 is initialized to 1 each time the shell or a shell script
11209 is invoked. When an option requires an argument,
11210 <B>getopts</B>
11211
11212 places that argument into the variable
11213 <FONT SIZE=-1><B>OPTARG</B>.
11214
11215 </FONT>
11216 The shell does not reset
11217 <FONT SIZE=-1><B>OPTIND</B>
11218
11219 </FONT>
11220 automatically; it must be manually reset between multiple
11221 calls to
11222 <B>getopts</B>
11223
11224 within the same shell invocation if a new set of parameters
11225 is to be used.
11226 <P>
11227 When the end of options is encountered, <B>getopts</B> exits with a
11228 return value greater than zero.
11229 <FONT SIZE=-1><B>OPTIND</B>
11230
11231 </FONT>
11232 is set to the index of the first non-option argument,
11233 and <I>name</I> is set to ?.
11234 <P>
11235 <B>getopts</B>
11236
11237 normally parses the positional parameters, but if more arguments are
11238 supplied as
11239 <I>arg</I>
11240
11241 values,
11242 <B>getopts</B>
11243
11244 parses those instead.
11245 <P>
11246 <B>getopts</B>
11247
11248 can report errors in two ways. If the first character of
11249 <I>optstring</I>
11250
11251 is a colon,
11252 <I>silent</I>
11253
11254 error reporting is used. In normal operation, diagnostic messages
11255 are printed when invalid options or missing option arguments are
11256 encountered.
11257 If the variable
11258 <FONT SIZE=-1><B>OPTERR</B>
11259
11260 </FONT>
11261 is set to 0, no error messages will be displayed, even if the first
11262 character of
11263 <I>optstring</I>
11264
11265 is not a colon.
11266 <P>
11267 If an invalid option is seen,
11268 <B>getopts</B>
11269
11270 places ? into
11271 <I>name</I>
11272
11273 and, if not silent,
11274 prints an error message and unsets
11275 <FONT SIZE=-1><B>OPTARG</B>.
11276
11277 </FONT>
11278 If
11279 <B>getopts</B>
11280
11281 is silent,
11282 the option character found is placed in
11283 <FONT SIZE=-1><B>OPTARG</B>
11284
11285 </FONT>
11286 and no diagnostic message is printed.
11287 <P>
11288 If a required argument is not found, and
11289 <B>getopts</B>
11290
11291 is not silent,
11292 a question mark (<B>?</B>) is placed in
11293 <I>name</I>,
11294
11295 <FONT SIZE=-1><B>OPTARG</B>
11296
11297 </FONT>
11298 is unset, and a diagnostic message is printed.
11299 If
11300 <B>getopts</B>
11301
11302 is silent, then a colon (<B>:</B>) is placed in
11303 <I>name</I>
11304
11305 and
11306 <FONT SIZE=-1><B>OPTARG</B>
11307
11308 </FONT>
11309 is set to the option character found.
11310 <P>
11311 <B>getopts</B>
11312
11313 returns true if an option, specified or unspecified, is found.
11314 It returns false if the end of options is encountered or an
11315 error occurs.
11316 <DT><B>hash</B> [<B>-lr</B>] [<B>-p</B> <I>filename</I>] [<B>-dt</B>] [<I>name</I>]<DD>
11317 Each time <B>hash</B> is invoked,
11318 the full pathname of the command
11319 <I>name</I>
11320
11321 is determined by searching
11322 the directories in
11323 <B>$PATH</B>
11324
11325 and remembered. Any previously-remembered pathname is discarded.
11326 If the
11327 <B>-p</B>
11328
11329 option is supplied, no path search is performed, and
11330 <I>filename</I>
11331
11332 is used as the full filename of the command.
11333 The
11334 <B>-r</B>
11335
11336 option causes the shell to forget all
11337 remembered locations.
11338 The
11339 <B>-d</B>
11340
11341 option causes the shell to forget the remembered location of each <I>name</I>.
11342 If the
11343 <B>-t</B>
11344
11345 option is supplied, the full pathname to which each <I>name</I> corresponds
11346 is printed. If multiple <I>name</I> arguments are supplied with <B>-t</B>,
11347 the <I>name</I> is printed before the hashed full pathname.
11348 The
11349 <B>-l</B>
11350
11351 option causes output to be displayed in a format that may be reused as input.
11352 If no arguments are given, or if only <B>-l</B> is supplied,
11353 information about remembered commands is printed.
11354 The return status is true unless a
11355 <I>name</I>
11356
11357 is not found or an invalid option is supplied.
11358 <DT><B>help</B> [<B>-dms</B>] [<I>pattern</I>]<DD>
11359 Display helpful information about builtin commands. If
11360 <I>pattern</I>
11361
11362 is specified,
11363 <B>help</B>
11364
11365 gives detailed help on all commands matching
11366 <I>pattern</I>;
11367
11368 otherwise help for all the builtins and shell control structures
11369 is printed.
11370 <DL COMPACT><DT><DD>
11371
11372 <DL COMPACT>
11373 <DT><B>-d</B>
11374
11375 <DD>
11376 Display a short description of each <I>pattern</I>
11377 <DT><B>-m</B>
11378
11379 <DD>
11380 Display the description of each <I>pattern</I> in a manpage-like format
11381 <DT><B>-s</B>
11382
11383 <DD>
11384 Display only a short usage synopsis for each <I>pattern</I>
11385
11386 </DL>
11387 <P>
11388
11389 The return status is 0 unless no command matches
11390 <I>pattern</I>.
11391
11392 </DL>
11393
11394 <DT><B>history [</B><I>n</I>]<DD>
11395
11396 <DT><B>history</B> <B>-c</B><DD>
11397 <DT><B>history -d</B> <I>offset</I><DD>
11398 <DT><B>history -d</B> <I>start</I>-<I>end</I><DD>
11399 <DT><B>history</B> <B>-anrw</B> [<I>filename</I>]<DD>
11400 <DT><B>history</B> <B>-p</B> <I>arg</I> [<I>arg ...</I>]<DD>
11401 <DT><B>history</B> <B>-s</B> <I>arg</I> [<I>arg ...</I>]<DD>
11402
11403 With no options, display the command
11404 history list with line numbers. Lines listed
11405 with a
11406 <B>*</B>
11407
11408 have been modified. An argument of
11409 <I>n</I>
11410
11411 lists only the last
11412 <I>n</I>
11413
11414 lines.
11415 If the shell variable
11416 <FONT SIZE=-1><B>HISTTIMEFORMAT</B>
11417
11418 </FONT>
11419 is set and not null,
11420 it is used as a format string for <I>strftime</I>(3) to display
11421 the time stamp associated with each displayed history entry.
11422 No intervening blank is printed between the formatted time stamp
11423 and the history line.
11424 If <I>filename</I> is supplied, it is used as the
11425 name of the history file; if not, the value of
11426 <FONT SIZE=-1><B>HISTFILE</B>
11427
11428 </FONT>
11429 is used. Options, if supplied, have the following meanings:
11430 <DL COMPACT><DT><DD>
11431
11432 <DL COMPACT>
11433 <DT><B>-c</B>
11434
11435 <DD>
11436 Clear the history list by deleting all the entries.
11437 <DT><B>-d</B> <I>offset</I><DD>
11438 Delete the history entry at position <I>offset</I>.
11439 If <I>offset</I> is negative, it is interpreted as relative to one greater
11440 than the last history position, so negative indices count back from the
11441 end of the history, and an index of -1 refers to the current
11442 <B>history -d</B> command.
11443 <DT><B>-d</B> <I>start</I>-<I>end</I><DD>
11444 Delete the range of history entries between positions <I>start</I> and
11445 <I>end</I>, inclusive.
11446 Positive and negative values for <I>start</I> and <I>end</I>
11447 are interpreted as described above.
11448 <DT><B>-a</B>
11449
11450 <DD>
11451 Append the ``new'' history lines to the history file.
11452 These are history lines entered since the beginning of the current
11453 <B>bash</B> session, but not already appended to the history file.
11454 <DT><B>-n</B>
11455
11456 <DD>
11457 Read the history lines not already read from the history
11458 file into the current history list. These are lines
11459 appended to the history file since the beginning of the
11460 current <B>bash</B> session.
11461 <DT><B>-r</B>
11462
11463 <DD>
11464 Read the contents of the history file
11465 and append them to the current history list.
11466 <DT><B>-w</B>
11467
11468 <DD>
11469 Write the current history list to the history file, overwriting the
11470 history file's contents.
11471 <DT><B>-p</B>
11472
11473 <DD>
11474 Perform history substitution on the following <I>args</I> and display
11475 the result on the standard output.
11476 Does not store the results in the history list.
11477 Each <I>arg</I> must be quoted to disable normal history expansion.
11478 <DT><B>-s</B>
11479
11480 <DD>
11481 Store the
11482 <I>args</I>
11483
11484 in the history list as a single entry. The last command in the
11485 history list is removed before the
11486 <I>args</I>
11487
11488 are added.
11489
11490 </DL>
11491 <P>
11492
11493 If the
11494 <FONT SIZE=-1><B>HISTTIMEFORMAT</B>
11495
11496 </FONT>
11497 variable is set, the time stamp information
11498 associated with each history entry is written to the history file,
11499 marked with the history comment character.
11500 When the history file is read, lines beginning with the history
11501 comment character followed immediately by a digit are interpreted
11502 as timestamps for the following history entry.
11503 The return value is 0 unless an invalid option is encountered, an
11504 error occurs while reading or writing the history file, an invalid
11505 <I>offset</I> or range is supplied as an argument to <B>-d</B>, or the
11506 history expansion supplied as an argument to <B>-p</B> fails.
11507 </DL>
11508
11509 <DT><B>jobs</B> [<B>-lnprs</B>] [ <I>jobspec</I> ... ]<DD>
11510
11511 <DT><B>jobs</B> <B>-x</B> <I>command</I> [ <I>args</I> ... ]<DD>
11512
11513 The first form lists the active jobs. The options have the following
11514 meanings:
11515 <DL COMPACT><DT><DD>
11516
11517 <DL COMPACT>
11518 <DT><B>-l</B>
11519
11520 <DD>
11521 List process IDs
11522 in addition to the normal information.
11523 <DT><B>-n</B>
11524
11525 <DD>
11526 Display information only about jobs that have changed status since
11527 the user was last notified of their status.
11528 <DT><B>-p</B>
11529
11530 <DD>
11531 List only the process ID of the job's process group
11532 leader.
11533 <DT><B>-r</B>
11534
11535 <DD>
11536 Display only running jobs.
11537 <DT><B>-s</B>
11538
11539 <DD>
11540 Display only stopped jobs.
11541
11542 </DL>
11543 <P>
11544
11545 If
11546 <I>jobspec</I>
11547
11548 is given, output is restricted to information about that job.
11549 The return status is 0 unless an invalid option is encountered
11550 or an invalid
11551 <I>jobspec</I>
11552
11553 is supplied.
11554 <P>
11555
11556 If the
11557 <B>-x</B>
11558
11559 option is supplied,
11560 <B>jobs</B>
11561
11562 replaces any
11563 <I>jobspec</I>
11564
11565 found in
11566 <I>command</I>
11567
11568 or
11569 <I>args</I>
11570
11571 with the corresponding process group ID, and executes
11572 <I>command</I>
11573
11574 passing it
11575 <I>args</I>,
11576
11577 returning its exit status.
11578 </DL>
11579
11580 <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>
11581
11582 <DT><B>kill</B> <B>-l</B>|<B>-L</B> [<I>sigspec</I> | <I>exit_status</I>]<DD>
11583
11584 Send the signal named by
11585 <I>sigspec</I>
11586
11587 or
11588 <I>signum</I>
11589
11590 to the processes named by
11591 <I>pid</I>
11592
11593 or
11594 <I>jobspec</I>.
11595
11596 <I>sigspec</I>
11597
11598 is either a case-insensitive signal name such as
11599 <FONT SIZE=-1><B>SIGKILL</B>
11600
11601 </FONT>
11602 (with or without the
11603 <FONT SIZE=-1><B>SIG</B>
11604
11605 </FONT>
11606 prefix) or a signal number;
11607 <I>signum</I>
11608
11609 is a signal number.
11610 If
11611 <I>sigspec</I>
11612
11613 is not present, then
11614 <FONT SIZE=-1><B>SIGTERM</B>
11615
11616 </FONT>
11617 is assumed.
11618 An argument of
11619 <B>-l</B>
11620
11621 lists the signal names.
11622 If any arguments are supplied when
11623 <B>-l</B>
11624
11625 is given, the names of the signals corresponding to the arguments are
11626 listed, and the return status is 0.
11627 The <I>exit_status</I> argument to
11628 <B>-l</B>
11629
11630 is a number specifying either a signal number or the exit status of
11631 a process terminated by a signal.
11632 The
11633 <B>-L</B>
11634
11635 option is equivalent to <B>-l</B>.
11636 <B>kill</B>
11637
11638 returns true if at least one signal was successfully sent, or false
11639 if an error occurs or an invalid option is encountered.
11640 <DT><B>let</B> <I>arg</I> [<I>arg</I> ...]<DD>
11641 Each
11642 <I>arg</I>
11643
11644 is an arithmetic expression to be evaluated (see
11645 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
11646
11647 </FONT>
11648
11649 above).
11650 If the last
11651 <I>arg</I>
11652
11653 evaluates to 0,
11654 <B>let</B>
11655
11656 returns 1; 0 is returned otherwise.
11657 <DT><B>local</B> [<I>option</I>] [<I>name</I>[=<I>value</I>] ... | - ]<DD>
11658 For each argument, a local variable named
11659 <I>name</I>
11660
11661 is created, and assigned
11662 <I>value</I>.
11663
11664 The <I>option</I> can be any of the options accepted by <B>declare</B>.
11665 When
11666 <B>local</B>
11667
11668 is used within a function, it causes the variable
11669 <I>name</I>
11670
11671 to have a visible scope restricted to that function and its children.
11672 If <I>name</I> is -, the set of shell options is made local to the function
11673 in which <B>local</B> is invoked: shell options changed using the
11674 <B>set</B> builtin inside the function are restored to their original values
11675 when the function returns.
11676 The restore is effected as if a series of <B>set</B> commands were executed
11677 to restore the values that were in place before the function.
11678 With no operands,
11679 <B>local</B>
11680
11681 writes a list of local variables to the standard output. It is
11682 an error to use
11683 <B>local</B>
11684
11685 when not within a function. The return status is 0 unless
11686 <B>local</B>
11687
11688 is used outside a function, an invalid
11689 <I>name</I>
11690
11691 is supplied, or
11692 <I>name</I> is a readonly variable.
11693 <DT><B>logout</B>
11694
11695 <DD>
11696 Exit a login shell.
11697 <DT><B>mapfile</B> [<B>-d</B> <I>delim</I>] [<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>
11698
11699 <DT><B>readarray</B> [<B>-d</B> <I>delim</I>] [<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>
11700
11701 Read lines from the standard input into the indexed array variable
11702 <I>array</I>,
11703
11704 or from file descriptor
11705 <I>fd</I>
11706
11707 if the
11708 <B>-u</B>
11709
11710 option is supplied.
11711 The variable
11712 <FONT SIZE=-1><B>MAPFILE</B>
11713
11714 </FONT>
11715 is the default <I>array</I>.
11716 Options, if supplied, have the following meanings:
11717 <DL COMPACT><DT><DD>
11718
11719 <DL COMPACT>
11720 <DT><B>-d</B>
11721
11722 <DD>
11723 The first character of <I>delim</I> is used to terminate each input line,
11724 rather than newline.
11725 If <I>delim</I> is the empty string, <B>mapfile</B> will terminate a line
11726 when it reads a NUL character.
11727 <DT><B>-n</B>
11728
11729 <DD>
11730 Copy at most
11731 <I>count</I>
11732
11733 lines. If <I>count</I> is 0, all lines are copied.
11734 <DT><B>-O</B>
11735
11736 <DD>
11737 Begin assigning to
11738 <I>array</I>
11739
11740 at index
11741 <I>origin</I>.
11742
11743 The default index is 0.
11744 <DT><B>-s</B>
11745
11746 <DD>
11747 Discard the first <I>count</I> lines read.
11748 <DT><B>-t</B>
11749
11750 <DD>
11751 Remove a trailing <I>delim</I> (default newline) from each line read.
11752 <DT><B>-u</B>
11753
11754 <DD>
11755 Read lines from file descriptor <I>fd</I> instead of the standard input.
11756 <DT><B>-C</B>
11757
11758 <DD>
11759 Evaluate
11760 <I>callback</I>
11761
11762 each time <I>quantum</I> lines are read. The <B>-c</B> option specifies
11763 <I>quantum</I>.
11764
11765 <DT><B>-c</B>
11766
11767 <DD>
11768 Specify the number of lines read between each call to
11769 <I>callback</I>.
11770
11771
11772 </DL>
11773 <P>
11774
11775 If
11776 <B>-C</B>
11777
11778 is specified without
11779 <B>-c</B>,
11780
11781 the default quantum is 5000.
11782 When <I>callback</I> is evaluated, it is supplied the index of the next
11783 array element to be assigned and the line to be assigned to that element
11784 as additional arguments.
11785 <I>callback</I> is evaluated after the line is read but before the
11786 array element is assigned.
11787 <P>
11788
11789 If not supplied with an explicit origin, <B>mapfile</B> will clear <I>array</I>
11790 before assigning to it.
11791 <P>
11792
11793 <B>mapfile</B> returns successfully unless an invalid option or option
11794 argument is supplied, <I>array</I> is invalid or unassignable, or if
11795 <I>array</I> is not an indexed array.
11796 </DL>
11797
11798 <DT><B>popd</B> [-<B>n</B>] [+<I>n</I>] [-<I>n</I>]<DD>
11799 Removes entries from the directory stack.
11800 The elements are numbered from 0 starting at the first directory
11801 listed by <B>dirs</B>.
11802 With no arguments, <B>popd</B>
11803 removes the top directory from the stack, and
11804 changes to the new top directory.
11805 Arguments, if supplied, have the following meanings:
11806 <DL COMPACT><DT><DD>
11807
11808 <DL COMPACT>
11809 <DT><B>-n</B>
11810
11811 <DD>
11812 Suppresses the normal change of directory when removing directories
11813 from the stack, so that only the stack is manipulated.
11814 <DT><B>+</B><I>n</I><DD>
11815 Removes the <I>n</I>th entry counting from the left of the list
11816 shown by
11817 <B>dirs</B>,
11818
11819 starting with zero, from the stack.
11820 For example:
11821
11822 <TT>popd +0</TT>
11823 removes the first directory,
11824
11825 <TT>popd +1</TT>
11826 the second.
11827 <DT><B>-</B><I>n</I><DD>
11828 Removes the <I>n</I>th entry counting from the right of the list
11829 shown by
11830 <B>dirs</B>,
11831
11832 starting with zero. For example:
11833
11834 <TT>popd -0</TT>
11835 removes the last directory,
11836
11837 <TT>popd -1</TT>
11838 the next to last.
11839
11840 </DL>
11841 <P>
11842
11843 If the top element of the directory stack is modified, and
11844 the <I>-n</I> option was not supplied, <B>popd</B> uses the <B>cd</B>
11845 builtin to change to the directory at the top of the stack.
11846 If the <B>cd</B> fails, <B>popd</B> returns a non-zero value.
11847 <P>
11848
11849 Otherwise,
11850 <B>popd</B>
11851
11852 returns false if an invalid option is encountered, the directory stack
11853 is empty, or a non-existent directory stack entry is specified.
11854 <P>
11855
11856 If the
11857 <B>popd</B>
11858
11859 command is successful,
11860 bash runs
11861 <B>dirs</B>
11862
11863 to show the final contents of the directory stack,
11864 and the return status is 0.
11865 </DL>
11866
11867 <DT><B>printf</B> [<B>-v</B> <I>var</I>] <I>format</I> [<I>arguments</I>]<DD>
11868 Write the formatted <I>arguments</I> to the standard output under the
11869 control of the <I>format</I>.
11870 The <B>-v</B> option causes the output to be assigned to the variable
11871 <I>var</I> rather than being printed to the standard output.
11872 <P>
11873 The <I>format</I> is a character string which contains three types of objects:
11874 plain characters, which are simply copied to standard output, character
11875 escape sequences, which are converted and copied to the standard output, and
11876 format specifications, each of which causes printing of the next successive
11877 <I>argument</I>.
11878 In addition to the standard <I>printf</I>(1) format specifications,
11879 <B>printf</B> interprets the following extensions:
11880 <DL COMPACT><DT><DD>
11881
11882 <DL COMPACT>
11883 <DT><B>%b</B>
11884
11885 <DD>
11886 causes
11887 <B>printf</B> to expand backslash escape sequences in the corresponding
11888 <I>argument</I>
11889 in the same way as <B>echo -e</B>.
11890 <DT><B>%q</B>
11891
11892 <DD>
11893 causes <B>printf</B> to output the corresponding
11894 <I>argument</I> in a format that can be reused as shell input.
11895 <DT><B>%Q</B>
11896
11897 <DD>
11898 like <B>%q</B>, but applies any supplied precision to the <I>argument</I>
11899 before quoting it.
11900 <DT><B>%(</B><I>datefmt</I>)T
11901
11902 <DD>
11903 causes <B>printf</B> to output the date-time string resulting from using
11904 <I>datefmt</I> as a format string for <I>strftime</I>(3).
11905 The corresponding <I>argument</I> is an integer representing the number of
11906 seconds since the epoch.
11907 Two special argument values may be used: -1 represents the current
11908 time, and -2 represents the time the shell was invoked.
11909 If no argument is specified, conversion behaves as if -1 had been given.
11910 This is an exception to the usual <B>printf</B> behavior.
11911
11912 </DL>
11913 <P>
11914
11915 The %b, %q, and %T directives all use the field width and precision
11916 arguments from the format specification and write that many bytes from
11917 (or use that wide a field for) the expanded argument, which usually
11918 contains more characters than the original.
11919 <P>
11920
11921 Arguments to non-string format specifiers are treated as C constants,
11922 except that a leading plus or minus sign is allowed, and if the leading
11923 character is a single or double quote, the value is the ASCII value of
11924 the following character.
11925 <P>
11926
11927 The <I>format</I> is reused as necessary to consume all of the <I>arguments</I>.
11928 If the <I>format</I> requires more <I>arguments</I> than are supplied, the
11929 extra format specifications behave as if a zero value or null string, as
11930 appropriate, had been supplied.
11931 The return value is zero on success, non-zero on failure.
11932 </DL>
11933
11934 <DT><B>pushd</B> [<B>-n</B>] [+<I>n</I>] [-<I>n</I>]<DD>
11935
11936 <DT><B>pushd</B> [<B>-n</B>] [<I>dir</I>]<DD>
11937
11938 Adds a directory to the top of the directory stack, or rotates
11939 the stack, making the new top of the stack the current working
11940 directory.
11941 With no arguments, <B>pushd</B> exchanges the top two elements of
11942 the directory stack.
11943 Arguments, if supplied, have the following meanings:
11944 <DL COMPACT><DT><DD>
11945
11946 <DL COMPACT>
11947 <DT><B>-n</B>
11948
11949 <DD>
11950 Suppresses the normal change of directory when rotating or
11951 adding directories to the stack, so that only the stack is manipulated.
11952 <DT><B>+</B><I>n</I><DD>
11953 Rotates the stack so that the <I>n</I>th directory
11954 (counting from the left of the list shown by
11955 <B>dirs</B>,
11956
11957 starting with zero)
11958 is at the top.
11959 <DT><B>-</B><I>n</I><DD>
11960 Rotates the stack so that the <I>n</I>th directory
11961 (counting from the right of the list shown by
11962 <B>dirs</B>,
11963
11964 starting with zero) is at the top.
11965 <DT><I>dir</I>
11966
11967 <DD>
11968 Adds
11969 <I>dir</I>
11970
11971 to the directory stack at the top
11972
11973 </DL>
11974 <P>
11975
11976 After the stack has been modified, if the <B>-n</B> option was not
11977 supplied, <B>pushd</B> uses the <B>cd</B> builtin to change to the
11978 directory at the top of the stack.
11979 If the <B>cd</B> fails, <B>pushd</B> returns a non-zero value.
11980 <P>
11981
11982 Otherwise, if no arguments are supplied,
11983 <B>pushd</B>
11984
11985 returns 0 unless the directory stack is empty.
11986 When rotating the directory stack,
11987 <B>pushd</B>
11988
11989 returns 0 unless the directory stack is empty or
11990 a non-existent directory stack element is specified.
11991 <P>
11992
11993 If the
11994 <B>pushd</B>
11995
11996 command is successful,
11997 bash runs
11998 <B>dirs</B>
11999
12000 to show the final contents of the directory stack.
12001 </DL>
12002
12003 <DT><B>pwd</B> [<B>-LP</B>]<DD>
12004 Print the absolute pathname of the current working directory.
12005 The pathname printed contains no symbolic links if the
12006 <B>-P</B>
12007
12008 option is supplied or the
12009 <B>-o physical</B>
12010
12011 option to the
12012 <B>set</B>
12013
12014 builtin command is enabled.
12015 If the
12016 <B>-L</B>
12017
12018 option is used, the pathname printed may contain symbolic links.
12019 The return status is 0 unless an error occurs while
12020 reading the name of the current directory or an
12021 invalid option is supplied.
12022 <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>
12023 One line is read from the standard input, or from the file descriptor
12024 <I>fd</I> supplied as an argument to the <B>-u</B> option,
12025 split into words as described
12026
12027 above
12028 under <B>Word Splitting</B>,
12029 and the first word
12030 is assigned to the first
12031 <I>name</I>,
12032
12033 the second word to the second
12034 <I>name</I>,
12035
12036 and so on.
12037 If there are more words than names, the remaining words and their
12038 intervening delimiters are assigned to the last
12039 <I>name</I>.
12040
12041 If there are fewer words read from the input stream than names,
12042 the remaining names are assigned empty values.
12043 The characters in
12044 <FONT SIZE=-1><B>IFS</B>
12045
12046 </FONT>
12047 are used to split the line into words using the same rules the shell
12048 uses for expansion (described
12049
12050 above
12051 under <B>Word Splitting</B>).
12052 The backslash character (<B>\</B>) may be used to remove any special
12053 meaning for the next character read and for line continuation.
12054 Options, if supplied, have the following meanings:
12055 <DL COMPACT><DT><DD>
12056
12057 <DL COMPACT>
12058 <DT><B>-a </B><I>aname</I>
12059
12060 <DD>
12061 The words are assigned to sequential indices
12062 of the array variable
12063 <I>aname</I>,
12064
12065 starting at 0.
12066 <I>aname</I>
12067
12068 is unset before any new values are assigned.
12069 Other <I>name</I> arguments are ignored.
12070 <DT><B>-d </B><I>delim</I>
12071
12072 <DD>
12073 The first character of <I>delim</I> is used to terminate the input line,
12074 rather than newline.
12075 If <I>delim</I> is the empty string, <B>read</B> will terminate a line
12076 when it reads a NUL character.
12077 <DT><B>-e</B>
12078
12079 <DD>
12080 If the standard input
12081 is coming from a terminal,
12082 <B>readline</B>
12083
12084 (see
12085 <FONT SIZE=-1><B>READLINE</B>
12086
12087 </FONT>
12088
12089 above)
12090 is used to obtain the line.
12091 Readline uses the current (or default, if line editing was not previously
12092 active) editing settings, but uses readline's default filename completion.
12093 <DT><B>-i </B><I>text</I>
12094
12095 <DD>
12096 If
12097 <B>readline</B>
12098
12099 is being used to read the line, <I>text</I> is placed into the editing
12100 buffer before editing begins.
12101 <DT><B>-n </B><I>nchars</I>
12102
12103 <DD>
12104 <B>read</B> returns after reading <I>nchars</I> characters rather than
12105 waiting for a complete line of input, but honors a delimiter if fewer
12106 than <I>nchars</I> characters are read before the delimiter.
12107 <DT><B>-N </B><I>nchars</I>
12108
12109 <DD>
12110 <B>read</B> returns after reading exactly <I>nchars</I> characters rather
12111 than waiting for a complete line of input, unless EOF is encountered or
12112 <B>read</B> times out.
12113 Delimiter characters encountered in the input are
12114 not treated specially and do not cause <B>read</B> to return until
12115 <I>nchars</I> characters are read.
12116 The result is not split on the characters in <B>IFS</B>; the intent is
12117 that the variable is assigned exactly the characters read
12118 (with the exception of backslash; see the <B>-r</B> option below).
12119 <DT><B>-p </B><I>prompt</I>
12120
12121 <DD>
12122 Display <I>prompt</I> on standard error, without a
12123 trailing newline, before attempting to read any input. The prompt
12124 is displayed only if input is coming from a terminal.
12125 <DT><B>-r</B>
12126
12127 <DD>
12128 Backslash does not act as an escape character.
12129 The backslash is considered to be part of the line.
12130 In particular, a backslash-newline pair may not then be used as a line
12131 continuation.
12132 <DT><B>-s</B>
12133
12134 <DD>
12135 Silent mode. If input is coming from a terminal, characters are
12136 not echoed.
12137 <DT><B>-t </B><I>timeout</I>
12138
12139 <DD>
12140 Cause <B>read</B> to time out and return failure if a complete line of
12141 input (or a specified number of characters)
12142 is not read within <I>timeout</I> seconds.
12143 <I>timeout</I> may be a decimal number with a fractional portion following
12144 the decimal point.
12145 This option is only effective if <B>read</B> is reading input from a
12146 terminal, pipe, or other special file; it has no effect when reading
12147 from regular files.
12148 If <B>read</B> times out, <B>read</B> saves any partial input read into
12149 the specified variable <I>name</I>.
12150 If <I>timeout</I> is 0, <B>read</B> returns immediately, without trying to
12151 read any data.
12152 The exit status is 0 if input is available on the specified file descriptor,
12153 or the read will return EOF,
12154 non-zero otherwise.
12155 The exit status is greater than 128 if the timeout is exceeded.
12156 <DT><B>-u </B><I>fd</I>
12157
12158 <DD>
12159 Read input from file descriptor <I>fd</I>.
12160
12161 </DL>
12162 <P>
12163
12164 If no
12165 <I>names</I>
12166
12167 are supplied, the line read,
12168 without the ending delimiter but otherwise unmodified,
12169 is assigned to the variable
12170 <FONT SIZE=-1><B>REPLY</B>.
12171
12172 </FONT>
12173 The exit status is zero, unless end-of-file is encountered, <B>read</B>
12174 times out (in which case the status is greater than 128),
12175 a variable assignment error (such as assigning to a readonly variable) occurs,
12176 or an invalid file descriptor is supplied as the argument to <B>-u</B>.
12177 </DL>
12178
12179 <DT><B>readonly</B> [<B>-aAf</B>] [<B>-p</B>] [<I>name</I>[=<I>word</I>] ...]<DD>
12180
12181 The given
12182 <I>names</I> are marked readonly; the values of these
12183 <I>names</I>
12184
12185 may not be changed by subsequent assignment.
12186 If the
12187 <B>-f</B>
12188
12189 option is supplied, the functions corresponding to the
12190 <I>names</I> are so
12191 marked.
12192 The
12193 <B>-a</B>
12194
12195 option restricts the variables to indexed arrays; the
12196 <B>-A</B>
12197
12198 option restricts the variables to associative arrays.
12199 If both options are supplied,
12200 <B>-A</B>
12201
12202 takes precedence.
12203 If no
12204 <I>name</I>
12205
12206 arguments are given, or if the
12207 <B>-p</B>
12208
12209 option is supplied, a list of all readonly names is printed.
12210 The other options may be used to restrict the output to a subset of
12211 the set of readonly names.
12212 The
12213 <B>-p</B>
12214
12215 option causes output to be displayed in a format that
12216 may be reused as input.
12217 If a variable name is followed by =<I>word</I>, the value of
12218 the variable is set to <I>word</I>.
12219 The return status is 0 unless an invalid option is encountered,
12220 one of the
12221 <I>names</I>
12222
12223 is not a valid shell variable name, or
12224 <B>-f</B>
12225
12226 is supplied with a
12227 <I>name</I>
12228
12229 that is not a function.
12230 <DT><B>return</B> [<I>n</I>]<DD>
12231 Causes a function to stop executing and return the value specified by
12232 <I>n</I>
12233
12234 to its caller.
12235 If
12236 <I>n</I>
12237
12238 is omitted, the return status is that of the last command
12239 executed in the function body.
12240 If <B>return</B> is executed by a trap handler, the last command used to
12241 determine the status is the last command executed before the trap handler.
12242 If <B>return</B> is executed during a <B>DEBUG</B> trap, the last command
12243 used to determine the status is the last command executed by the trap
12244 handler before <B>return</B> was invoked.
12245 If
12246 <B>return</B>
12247
12248 is used outside a function,
12249 but during execution of a script by the
12250 <B>.</B>
12251
12252 (<B>source</B>) command, it causes the shell to stop executing
12253 that script and return either
12254 <I>n</I>
12255
12256 or the exit status of the last command executed within the
12257 script as the exit status of the script.
12258 If <I>n</I> is supplied, the return value is its least significant
12259 8 bits.
12260 The return status is non-zero if
12261 <B>return</B>
12262
12263 is supplied a non-numeric argument, or
12264 is used outside a
12265 function and not during execution of a script by <B>.</B> or <B>source</B>.
12266 Any command associated with the <B>RETURN</B> trap is executed
12267 before execution resumes after the function or script.
12268 <DT><B>set</B> [<B>-abefhkmnptuvxBCEHPT</B>] [<B>-o</B> <I>option-name</I>] [<B>--</B>] [<B>-</B>] [<I>arg</I> ...]<DD>
12269
12270 <DT><B>set</B> [<B>+abefhkmnptuvxBCEHPT</B>] [<B>+o</B> <I>option-name</I>] [<B>--</B>] [<B>-</B>] [<I>arg</I> ...]<DD>
12271
12272 Without options, display the name and value of each shell variable
12273 in a format that can be reused as input
12274 for setting or resetting the currently-set variables.
12275 Read-only variables cannot be reset.
12276 In <I>posix mode</I>, only shell variables are listed.
12277 The output is sorted according to the current locale.
12278 When options are specified, they set or unset shell attributes.
12279 Any arguments remaining after option processing are treated
12280 as values for the positional parameters and are assigned, in order, to
12281 <B>$1</B>,
12282
12283 <B>$2</B>,
12284
12285 <B>...</B>
12286
12287 <B>$</B><I>n</I>.
12288
12289 Options, if specified, have the following meanings:
12290 <DL COMPACT><DT><DD>
12291
12292 <DL COMPACT>
12293 <DT><B>-a</B>
12294
12295 <DD>
12296 Each variable or function that is created or modified is given the
12297 export attribute and marked for export to the environment of
12298 subsequent commands.
12299 <DT><B>-b</B>
12300
12301 <DD>
12302 Report the status of terminated background jobs
12303 immediately, rather than before the next primary prompt. This is
12304 effective only when job control is enabled.
12305 <DT><B>-e</B>
12306
12307 <DD>
12308 Exit immediately if a
12309 <I>pipeline</I> (which may consist of a single <I>simple command</I>),
12310 a <I>list</I>,
12311 or a <I>compound command</I>
12312 (see
12313 <FONT SIZE=-1><B>SHELL GRAMMAR</B>
12314
12315 </FONT>
12316
12317 above),
12318 exits with a non-zero status.
12319 The shell does not exit if the
12320 command that fails is part of the command list immediately following a
12321 <B>while</B>
12322
12323 or
12324 <B>until</B>
12325
12326 keyword,
12327 part of the test following the
12328 <B>if</B>
12329
12330 or
12331 <B>elif</B>
12332
12333 reserved words, part of any command executed in a
12334 <B>&amp;&amp;</B>
12335
12336 or
12337 <B>||</B>
12338
12339 list except the command following the final <B>&amp;&amp;</B> or <B>||</B>,
12340 any command in a pipeline but the last,
12341 or if the command's return value is
12342 being inverted with
12343 <B>!</B>.
12344
12345 If a compound command other than a subshell
12346 returns a non-zero status because a command failed
12347 while <B>-e</B> was being ignored, the shell does not exit.
12348 A trap on <B>ERR</B>, if set, is executed before the shell exits.
12349 This option applies to the shell environment and each subshell environment
12350 separately (see
12351 <FONT SIZE=-1><B>COMMAND EXECUTION ENVIRONMENT</B>
12352
12353 </FONT>
12354
12355 above),
12356 and may cause
12357 subshells to exit before executing all the commands in the subshell.
12358 <P>
12359
12360
12361 If a compound command or shell function executes in a context
12362 where <B>-e</B> is being ignored,
12363 none of the commands executed within the compound command or function body
12364 will be affected by the <B>-e</B> setting, even if <B>-e</B> is set
12365 and a command returns a failure status.
12366 If a compound command or shell function sets <B>-e</B> while executing in
12367 a context where <B>-e</B> is ignored, that setting will not have any
12368 effect until the compound command or the command containing the function
12369 call completes.
12370 <DT><B>-f</B>
12371
12372 <DD>
12373 Disable pathname expansion.
12374 <DT><B>-h</B>
12375
12376 <DD>
12377 Remember the location of commands as they are looked up for execution.
12378 This is enabled by default.
12379 <DT><B>-k</B>
12380
12381 <DD>
12382 All arguments in the form of assignment statements
12383 are placed in the environment for a command, not just
12384 those that precede the command name.
12385 <DT><B>-m</B>
12386
12387 <DD>
12388 Monitor mode. Job control is enabled. This option is on
12389 by default for interactive shells on systems that support
12390 it (see
12391 <FONT SIZE=-1><B>JOB CONTROL</B>
12392
12393 </FONT>
12394
12395 above).
12396 All processes run in a separate process group.
12397 When a background job completes, the shell prints a line
12398 containing its exit status.
12399 <DT><B>-n</B>
12400
12401 <DD>
12402 Read commands but do not execute them.
12403 This may be used to check a shell script for syntax errors.
12404 This is ignored by interactive shells.
12405 <DT><B>-o </B><I>option-name</I>
12406
12407 <DD>
12408 The <I>option-name</I> can be one of the following:
12409 <DL COMPACT><DT><DD>
12410 <DL COMPACT>
12411 <DT><B>allexport</B>
12412
12413 <DD>
12414 Same as
12415 <B>-a</B>.
12416
12417 <DT><B>braceexpand</B>
12418
12419 <DD>
12420 Same as
12421 <B>-B</B>.
12422
12423 <DT><B>emacs</B>
12424
12425 <DD>
12426 Use an emacs-style command line editing interface. This is enabled
12427 by default when the shell is interactive, unless the shell is started
12428 with the
12429 <B>--noediting</B>
12430
12431 option.
12432 This also affects the editing interface used for <B>read -e</B>.
12433 <DT><B>errexit</B>
12434
12435 <DD>
12436 Same as
12437 <B>-e</B>.
12438
12439 <DT><B>errtrace</B>
12440
12441 <DD>
12442 Same as
12443 <B>-E</B>.
12444
12445 <DT><B>functrace</B>
12446
12447 <DD>
12448 Same as
12449 <B>-T</B>.
12450
12451 <DT><B>hashall</B>
12452
12453 <DD>
12454 Same as
12455 <B>-h</B>.
12456
12457 <DT><B>histexpand</B>
12458
12459 <DD>
12460 Same as
12461 <B>-H</B>.
12462
12463 <DT><B>history</B>
12464
12465 <DD>
12466 Enable command history, as described
12467
12468 above
12469 under
12470 <FONT SIZE=-1><B>HISTORY</B>.
12471
12472 </FONT>
12473 This option is on by default in interactive shells.
12474 <DT><B>ignoreeof</B>
12475
12476 <DD>
12477 The effect is as if the shell command
12478 <TT>IGNOREEOF=10</TT>
12479
12480 had been executed
12481 (see
12482 <B>Shell Variables</B>
12483
12484
12485 above).
12486 <DT><B>keyword</B>
12487
12488 <DD>
12489 Same as
12490 <B>-k</B>.
12491
12492 <DT><B>monitor</B>
12493
12494 <DD>
12495 Same as
12496 <B>-m</B>.
12497
12498 <DT><B>noclobber</B>
12499
12500 <DD>
12501 Same as
12502 <B>-C</B>.
12503
12504 <DT><B>noexec</B>
12505
12506 <DD>
12507 Same as
12508 <B>-n</B>.
12509
12510 <DT><B>noglob</B>
12511
12512 <DD>
12513 Same as
12514 <B>-f</B>.
12515
12516 <DT><B>nolog</B>
12517
12518 <DD>
12519 Currently ignored.
12520 <DT><B>notify</B>
12521
12522 <DD>
12523 Same as
12524 <B>-b</B>.
12525
12526 <DT><B>nounset</B>
12527
12528 <DD>
12529 Same as
12530 <B>-u</B>.
12531
12532 <DT><B>onecmd</B>
12533
12534 <DD>
12535 Same as
12536 <B>-t</B>.
12537
12538 <DT><B>physical</B>
12539
12540 <DD>
12541 Same as
12542 <B>-P</B>.
12543
12544 <DT><B>pipefail</B>
12545
12546 <DD>
12547 If set, the return value of a pipeline is the value of the last
12548 (rightmost) command to exit with a non-zero status, or zero if all
12549 commands in the pipeline exit successfully.
12550 This option is disabled by default.
12551 <DT><B>posix</B>
12552
12553 <DD>
12554 Change the behavior of
12555 <B>bash</B>
12556
12557 where the default operation differs
12558 from the POSIX standard to match the standard (<I>posix mode</I>).
12559 See
12560 <FONT SIZE=-1><B>SEE ALSO</B>
12561
12562 </FONT>
12563
12564 below
12565 for a reference to a document that details how posix mode affects
12566 bash's behavior.
12567 <DT><B>privileged</B>
12568
12569 <DD>
12570 Same as
12571 <B>-p</B>.
12572
12573 <DT><B>verbose</B>
12574
12575 <DD>
12576 Same as
12577 <B>-v</B>.
12578
12579 <DT><B>vi</B>
12580
12581 <DD>
12582 Use a vi-style command line editing interface.
12583 This also affects the editing interface used for <B>read -e</B>.
12584 <DT><B>xtrace</B>
12585
12586 <DD>
12587 Same as
12588 <B>-x</B>.
12589
12590 <P>
12591 </DL>
12592 <P>
12593
12594 If
12595 <B>-o</B>
12596
12597 is supplied with no <I>option-name</I>, the values of the current options are
12598 printed.
12599 If
12600 <B>+o</B>
12601
12602 is supplied with no <I>option-name</I>, a series of
12603 <B>set</B>
12604
12605 commands to recreate the current option settings is displayed on
12606 the standard output.
12607 </DL>
12608
12609 <DT><B>-p</B>
12610
12611 <DD>
12612 Turn on
12613 <I>privileged</I>
12614
12615 mode. In this mode, the
12616 <FONT SIZE=-1><B>$ENV</B>
12617
12618 </FONT>
12619 and
12620 <FONT SIZE=-1><B>$BASH_ENV</B>
12621
12622 </FONT>
12623 files are not processed, shell functions are not inherited from the
12624 environment, and the
12625 <FONT SIZE=-1><B>SHELLOPTS</B>,
12626
12627 </FONT>
12628 <FONT SIZE=-1><B>BASHOPTS</B>,
12629
12630 </FONT>
12631 <FONT SIZE=-1><B>CDPATH</B>,
12632
12633 </FONT>
12634 and
12635 <FONT SIZE=-1><B>GLOBIGNORE</B>
12636
12637 </FONT>
12638 variables, if they appear in the environment, are ignored.
12639 If the shell is started with the effective user (group) id not equal to the
12640 real user (group) id, and the <B>-p</B> option is not supplied, these actions
12641 are taken and the effective user id is set to the real user id.
12642 If the <B>-p</B> option is supplied at startup, the effective user id is
12643 not reset.
12644 Turning this option off causes the effective user
12645 and group ids to be set to the real user and group ids.
12646 <DT><B>-r</B>
12647
12648 <DD>
12649 Enable restricted shell mode.
12650 This option cannot be unset once it has been set.
12651 <DT><B>-t</B>
12652
12653 <DD>
12654 Exit after reading and executing one command.
12655 <DT><B>-u</B>
12656
12657 <DD>
12658 Treat unset variables and parameters other than the special
12659 parameters &quot;@&quot; and &quot;*&quot;,
12660 or array variables subscripted with &quot;@&quot; or &quot;*&quot;,
12661 as an error when performing
12662 parameter expansion. If expansion is attempted on an
12663 unset variable or parameter, the shell prints an error message, and,
12664 if not interactive, exits with a non-zero status.
12665 <DT><B>-v</B>
12666
12667 <DD>
12668 Print shell input lines as they are read.
12669 <DT><B>-x</B>
12670
12671 <DD>
12672 After expanding each <I>simple command</I>,
12673 <B>for</B> command, <B>case</B> command, <B>select</B> command, or
12674 arithmetic <B>for</B> command, display the expanded value of
12675 <FONT SIZE=-1><B>PS4</B>,
12676
12677 </FONT>
12678 followed by the command and its expanded arguments
12679 or associated word list.
12680 <DT><B>-B</B>
12681
12682 <DD>
12683 The shell performs brace expansion (see
12684 <B>Brace Expansion</B>
12685
12686
12687 above).
12688 This is on by default.
12689 <DT><B>-C</B>
12690
12691 <DD>
12692 If set,
12693 <B>bash</B>
12694
12695 does not overwrite an existing file with the
12696 <B>&gt;</B>,
12697
12698 <B>&gt;&amp;</B>,
12699
12700 and
12701 <B>&lt;&gt;</B>
12702
12703 redirection operators. This may be overridden when
12704 creating output files by using the redirection operator
12705 <B>&gt;|</B>
12706
12707 instead of
12708 <B>&gt;</B>.
12709
12710 <DT><B>-E</B>
12711
12712 <DD>
12713 If set, any trap on <B>ERR</B> is inherited by shell functions, command
12714 substitutions, and commands executed in a subshell environment.
12715 The <B>ERR</B> trap is normally not inherited in such cases.
12716 <DT><B>-H</B>
12717
12718 <DD>
12719 Enable
12720 <B>!</B>
12721
12722 style history substitution. This option is on by
12723 default when the shell is interactive.
12724 <DT><B>-P</B>
12725
12726 <DD>
12727 If set, the shell does not resolve symbolic links when executing
12728 commands such as
12729 <B>cd</B>
12730
12731 that change the current working directory. It uses the
12732 physical directory structure instead. By default,
12733 <B>bash</B>
12734
12735 follows the logical chain of directories when performing commands
12736 which change the current directory.
12737 <DT><B>-T</B>
12738
12739 <DD>
12740 If set, any traps on <B>DEBUG</B> and <B>RETURN</B> are inherited by shell
12741 functions, command substitutions, and commands executed in a
12742 subshell environment.
12743 The <B>DEBUG</B> and <B>RETURN</B> traps are normally not inherited
12744 in such cases.
12745 <DT><B>--</B>
12746
12747 <DD>
12748 If no arguments follow this option, then the positional parameters are
12749 unset. Otherwise, the positional parameters are set to the
12750 <I>arg</I>s, even if some of them begin with a
12751 <B>-</B>.
12752
12753 <DT><B>-</B>
12754
12755 <DD>
12756 Signal the end of options, cause all remaining <I>arg</I>s to be
12757 assigned to the positional parameters. The
12758 <B>-x</B>
12759
12760 and
12761 <B>-v</B>
12762
12763 options are turned off.
12764 If there are no <I>arg</I>s,
12765 the positional parameters remain unchanged.
12766
12767 </DL>
12768 <P>
12769
12770 The options are off by default unless otherwise noted.
12771 Using + rather than - causes these options to be turned off.
12772 The options can also be specified as arguments to an invocation of
12773 the shell.
12774 The current set of options may be found in
12775 <B>$-</B>.
12776
12777 The return status is always true unless an invalid option is encountered.
12778 </DL>
12779
12780 <DT><B>shift</B> [<I>n</I>]<DD>
12781 The positional parameters from <I>n</I>+1 ... are renamed to
12782 <B>$1</B>
12783
12784 <B>....</B>
12785
12786 Parameters represented by the numbers <B>$#</B>
12787 down to <B>$#</B>-<I>n</I>+1 are unset.
12788 <I>n</I>
12789
12790 must be a non-negative number less than or equal to <B>$#</B>.
12791 If
12792 <I>n</I>
12793
12794 is 0, no parameters are changed.
12795 If
12796 <I>n</I>
12797
12798 is not given, it is assumed to be 1.
12799 If
12800 <I>n</I>
12801
12802 is greater than <B>$#</B>, the positional parameters are not changed.
12803 The return status is greater than zero if
12804 <I>n</I>
12805
12806 is greater than
12807 <B>$#</B>
12808
12809 or less than zero; otherwise 0.
12810 <DT><B>shopt</B> [<B>-pqsu</B>] [<B>-o</B>] [<I>optname</I> ...]<DD>
12811 Toggle the values of settings controlling optional shell behavior.
12812 The settings can be either those listed below, or, if the
12813 <B>-o</B>
12814
12815 option is used, those available with the
12816 <B>-o</B>
12817
12818 option to the <B>set</B> builtin command.
12819 With no options, or with the
12820 <B>-p</B>
12821
12822 option, a list of all settable options is displayed, with
12823 an indication of whether or not each is set;
12824 if <I>optnames</I> are supplied, the output is restricted to those options.
12825 The <B>-p</B> option causes output to be displayed in a form that
12826 may be reused as input.
12827 Other options have the following meanings:
12828 <DL COMPACT><DT><DD>
12829
12830 <DL COMPACT>
12831 <DT><B>-s</B>
12832
12833 <DD>
12834 Enable (set) each <I>optname</I>.
12835 <DT><B>-u</B>
12836
12837 <DD>
12838 Disable (unset) each <I>optname</I>.
12839 <DT><B>-q</B>
12840
12841 <DD>
12842 Suppresses normal output (quiet mode); the return status indicates
12843 whether the <I>optname</I> is set or unset.
12844 If multiple <I>optname</I> arguments are given with
12845 <B>-q</B>,
12846
12847 the return status is zero if all <I>optnames</I> are enabled; non-zero
12848 otherwise.
12849 <DT><B>-o</B>
12850
12851 <DD>
12852 Restricts the values of <I>optname</I> to be those defined for the
12853 <B>-o</B>
12854
12855 option to the
12856 <B>set</B>
12857
12858 builtin.
12859
12860 </DL>
12861 <P>
12862
12863 If either
12864 <B>-s</B>
12865
12866 or
12867 <B>-u</B>
12868
12869 is used with no <I>optname</I> arguments,
12870 <B>shopt</B>
12871
12872 shows only those options which are set or unset, respectively.
12873 Unless otherwise noted, the <B>shopt</B> options are disabled (unset)
12874 by default.
12875 <P>
12876
12877 The return status when listing options is zero if all <I>optnames</I>
12878 are enabled, non-zero otherwise. When setting or unsetting options,
12879 the return status is zero unless an <I>optname</I> is not a valid shell
12880 option.
12881 <P>
12882
12883 The list of <B>shopt</B> options is:
12884 <P>
12885
12886
12887
12888 <DL COMPACT>
12889 <DT><B>assoc_expand_once</B>
12890
12891 <DD>
12892 If set, the shell suppresses multiple evaluation of associative array
12893 subscripts during arithmetic expression evaluation, while executing
12894 builtins that can perform variable assignments,
12895 and while executing builtins that perform array dereferencing.
12896 <DT><B>autocd</B>
12897
12898 <DD>
12899 If set, a command name that is the name of a directory is executed as if
12900 it were the argument to the <B>cd</B> command.
12901 This option is only used by interactive shells.
12902 <DT><B>cdable_vars</B>
12903
12904 <DD>
12905 If set, an argument to the
12906 <B>cd</B>
12907
12908 builtin command that
12909 is not a directory is assumed to be the name of a variable whose
12910 value is the directory to change to.
12911 <DT><B>cdspell</B>
12912
12913 <DD>
12914 If set, minor errors in the spelling of a directory component in a
12915 <B>cd</B>
12916
12917 command will be corrected.
12918 The errors checked for are transposed characters,
12919 a missing character, and one character too many.
12920 If a correction is found, the corrected filename is printed,
12921 and the command proceeds.
12922 This option is only used by interactive shells.
12923 <DT><B>checkhash</B>
12924
12925 <DD>
12926 If set, <B>bash</B> checks that a command found in the hash
12927 table exists before trying to execute it. If a hashed command no
12928 longer exists, a normal path search is performed.
12929 <DT><B>checkjobs</B>
12930
12931 <DD>
12932 If set, <B>bash</B> lists the status of any stopped and running jobs before
12933 exiting an interactive shell. If any jobs are running, this causes
12934 the exit to be deferred until a second exit is attempted without an
12935 intervening command (see
12936 <FONT SIZE=-1><B>JOB CONTROL</B>
12937
12938 </FONT>
12939
12940 above).
12941 The shell always postpones exiting if any jobs are stopped.
12942 <DT><B>checkwinsize</B>
12943
12944 <DD>
12945 If set, <B>bash</B> checks the window size after each external (non-builtin)
12946 command and, if necessary, updates the values of
12947 <FONT SIZE=-1><B>LINES</B>
12948
12949 </FONT>
12950 and
12951 <FONT SIZE=-1><B>COLUMNS</B>.
12952
12953 </FONT>
12954 This option is enabled by default.
12955 <DT><B>cmdhist</B>
12956
12957 <DD>
12958 If set,
12959 <B>bash</B>
12960
12961 attempts to save all lines of a multiple-line
12962 command in the same history entry. This allows
12963 easy re-editing of multi-line commands.
12964 This option is enabled by default, but only has an effect if command
12965 history is enabled, as described
12966
12967 above
12968 under
12969 <FONT SIZE=-1><B>HISTORY</B>.
12970
12971 </FONT>
12972
12973 <DT><B>compat31</B>
12974
12975 <DD>
12976 <DT><B>compat32</B>
12977
12978 <DD>
12979 <DT><B>compat40</B>
12980
12981 <DD>
12982 <DT><B>compat41</B>
12983
12984 <DD>
12985 <DT><B>compat42</B>
12986
12987 <DD>
12988 <DT><B>compat43</B>
12989
12990 <DD>
12991 <DT><B>compat44</B>
12992
12993 <DD>
12994 <DT><B>compat50</B>
12995
12996 <DD>
12997
12998 These control aspects of the shell's compatibility mode
12999 (see
13000 <FONT SIZE=-1><B>SHELL COMPATIBILITY MODE</B>
13001
13002 </FONT>
13003
13004 below).
13005 <DT><B>complete_fullquote</B>
13006
13007 <DD>
13008 If set,
13009 <B>bash</B>
13010
13011 quotes all shell metacharacters in filenames and directory names when
13012 performing completion.
13013 If not set,
13014 <B>bash</B>
13015
13016 removes metacharacters such as the dollar sign from the set of
13017 characters that will be quoted in completed filenames
13018 when these metacharacters appear in shell variable references in words to be
13019 completed.
13020 This means that dollar signs in variable names that expand to directories
13021 will not be quoted;
13022 however, any dollar signs appearing in filenames will not be quoted, either.
13023 This is active only when bash is using backslashes to quote completed
13024 filenames.
13025 This variable is set by default, which is the default bash behavior in
13026 versions through 4.2.
13027 <DT><B>direxpand</B>
13028
13029 <DD>
13030 If set,
13031 <B>bash</B>
13032
13033 replaces directory names with the results of word expansion when performing
13034 filename completion. This changes the contents of the readline editing
13035 buffer.
13036 If not set,
13037 <B>bash</B>
13038
13039 attempts to preserve what the user typed.
13040 <DT><B>dirspell</B>
13041
13042 <DD>
13043 If set,
13044 <B>bash</B>
13045
13046 attempts spelling correction on directory names during word completion
13047 if the directory name initially supplied does not exist.
13048 <DT><B>dotglob</B>
13049
13050 <DD>
13051 If set,
13052 <B>bash</B>
13053
13054 includes filenames beginning with a `.' in the results of pathname
13055 expansion.
13056 The filenames
13057 <B>``.''</B>
13058
13059 and
13060 <B>``..''</B>
13061
13062 must always be matched explicitly, even if
13063 <B>dotglob</B>
13064
13065 is set.
13066 <DT><B>execfail</B>
13067
13068 <DD>
13069 If set, a non-interactive shell will not exit if
13070 it cannot execute the file specified as an argument to the
13071 <B>exec</B>
13072
13073 builtin command. An interactive shell does not exit if
13074 <B>exec</B>
13075
13076 fails.
13077 <DT><B>expand_aliases</B>
13078
13079 <DD>
13080 If set, aliases are expanded as described
13081
13082 above
13083 under
13084 <FONT SIZE=-1><B>ALIASES</B>.
13085
13086 </FONT>
13087 This option is enabled by default for interactive shells.
13088 <DT><B>extdebug</B>
13089
13090 <DD>
13091 If set at shell invocation,
13092 or in a shell startup file,
13093 arrange to execute the debugger profile
13094 before the shell starts, identical to the <B>--debugger</B> option.
13095 If set after invocation, behavior intended for use by debuggers is enabled:
13096 <DL COMPACT><DT><DD>
13097 <DL COMPACT>
13098 <DT><B>1.</B>
13099
13100 <DD>
13101 The <B>-F</B> option to the <B>declare</B> builtin displays the source
13102 file name and line number corresponding to each function name supplied
13103 as an argument.
13104 <DT><B>2.</B>
13105
13106 <DD>
13107 If the command run by the <B>DEBUG</B> trap returns a non-zero value, the
13108 next command is skipped and not executed.
13109 <DT><B>3.</B>
13110
13111 <DD>
13112 If the command run by the <B>DEBUG</B> trap returns a value of 2, and the
13113 shell is executing in a subroutine (a shell function or a shell script
13114 executed by the <B>.</B> or <B>source</B> builtins), the shell simulates
13115 a call to <B>return</B>.
13116 <DT><B>4.</B>
13117
13118 <DD>
13119 <FONT SIZE=-1><B>BASH_ARGC</B>
13120
13121 </FONT>
13122 and
13123 <FONT SIZE=-1><B>BASH_ARGV</B>
13124
13125 </FONT>
13126 are updated as described in their descriptions
13127
13128 above).
13129 <DT><B>5.</B>
13130
13131 <DD>
13132 Function tracing is enabled: command substitution, shell functions, and
13133 subshells invoked with <B>(</B> <I>command</I> <B>)</B> inherit the
13134 <B>DEBUG</B> and <B>RETURN</B> traps.
13135 <DT><B>6.</B>
13136
13137 <DD>
13138 Error tracing is enabled: command substitution, shell functions, and
13139 subshells invoked with <B>(</B> <I>command</I> <B>)</B> inherit the
13140 <B>ERR</B> trap.
13141 </DL></DL>
13142
13143 <DT><B>extglob</B>
13144
13145 <DD>
13146 If set, the extended pattern matching features described
13147
13148 above
13149 under
13150 <B>Pathname Expansion</B> are enabled.
13151 <DT><B>extquote</B>
13152
13153 <DD>
13154 If set, <B>$</B>aq<I>string</I>aq and <B>$</B>&quot;<I>string</I>&quot; quoting is
13155 performed within <B>${</B><I>parameter</I><B>}</B> expansions
13156 enclosed in double quotes. This option is enabled by default.
13157 <DT><B>failglob</B>
13158
13159 <DD>
13160 If set, patterns which fail to match filenames during pathname expansion
13161 result in an expansion error.
13162 <DT><B>force_fignore</B>
13163
13164 <DD>
13165 If set, the suffixes specified by the
13166 <FONT SIZE=-1><B>FIGNORE</B>
13167
13168 </FONT>
13169 shell variable
13170 cause words to be ignored when performing word completion even if
13171 the ignored words are the only possible completions.
13172 See
13173 <FONT SIZE=-1><B>SHELL VARIABLES</B></FONT>
13174
13175 above
13176 for a description of
13177 <FONT SIZE=-1><B>FIGNORE</B>.
13178
13179 </FONT>
13180 This option is enabled by default.
13181 <DT><B>globasciiranges</B>
13182
13183 <DD>
13184 If set, range expressions used in pattern matching bracket expressions (see
13185 <FONT SIZE=-1><B>Pattern Matching</B>
13186
13187 </FONT>
13188
13189 above)
13190 behave as if in the traditional C locale when performing
13191 comparisons. That is, the current locale's collating sequence
13192 is not taken into account, so
13193 <B>b</B>
13194
13195 will not collate between
13196 <B>A</B>
13197
13198 and
13199 <B>B</B>,
13200
13201 and upper-case and lower-case ASCII characters will collate together.
13202 <DT><B>globskipdots</B>
13203
13204 <DD>
13205 If set, pathname expansion will never match the filenames
13206 <B>``.''</B>
13207
13208 and
13209 <B>``..''</B>,
13210
13211 even if the pattern begins with a
13212 <B>``.''</B>.
13213
13214 This option is enabled by default.
13215 <DT><B>globstar</B>
13216
13217 <DD>
13218 If set, the pattern <B>**</B> used in a pathname expansion context will
13219 match all files and zero or more directories and subdirectories.
13220 If the pattern is followed by a <B>/</B>, only directories and
13221 subdirectories match.
13222 <DT><B>gnu_errfmt</B>
13223
13224 <DD>
13225 If set, shell error messages are written in the standard GNU error
13226 message format.
13227 <DT><B>histappend</B>
13228
13229 <DD>
13230 If set, the history list is appended to the file named by the value
13231 of the
13232 <FONT SIZE=-1><B>HISTFILE</B>
13233
13234 </FONT>
13235 variable when the shell exits, rather than overwriting the file.
13236 <DT><B>histreedit</B>
13237
13238 <DD>
13239 If set, and
13240 <B>readline</B>
13241
13242 is being used, a user is given the opportunity to re-edit a
13243 failed history substitution.
13244 <DT><B>histverify</B>
13245
13246 <DD>
13247 If set, and
13248 <B>readline</B>
13249
13250 is being used, the results of history substitution are not immediately
13251 passed to the shell parser. Instead, the resulting line is loaded into
13252 the <B>readline</B> editing buffer, allowing further modification.
13253 <DT><B>hostcomplete</B>
13254
13255 <DD>
13256 If set, and
13257 <B>readline</B>
13258
13259 is being used, <B>bash</B> will attempt to perform hostname completion when a
13260 word containing a <B>@</B> is being completed (see
13261 <B>Completing</B>
13262
13263 under
13264 <FONT SIZE=-1><B>READLINE</B>
13265
13266 </FONT>
13267
13268 above).
13269 This is enabled by default.
13270 <DT><B>huponexit</B>
13271
13272 <DD>
13273 If set, <B>bash</B> will send
13274 <FONT SIZE=-1><B>SIGHUP</B>
13275
13276 </FONT>
13277 to all jobs when an interactive login shell exits.
13278 <DT><B>inherit_errexit</B>
13279
13280 <DD>
13281 If set, command substitution inherits the value of the <B>errexit</B> option,
13282 instead of unsetting it in the subshell environment.
13283 This option is enabled when <I>posix mode</I> is enabled.
13284 <DT><B>interactive_comments</B>
13285
13286 <DD>
13287 If set, allow a word beginning with
13288 <B>#</B>
13289
13290 to cause that word and all remaining characters on that
13291 line to be ignored in an interactive shell (see
13292 <FONT SIZE=-1><B>COMMENTS</B>
13293
13294 </FONT>
13295
13296 above).
13297 This option is enabled by default.
13298 <DT><B>lastpipe</B>
13299
13300 <DD>
13301 If set, and job control is not active, the shell runs the last command of
13302 a pipeline not executed in the background in the current shell environment.
13303 <DT><B>lithist</B>
13304
13305 <DD>
13306 If set, and the
13307 <B>cmdhist</B>
13308
13309 option is enabled, multi-line commands are saved to the history with
13310 embedded newlines rather than using semicolon separators where possible.
13311 <DT><B>localvar_inherit</B>
13312
13313 <DD>
13314 If set, local variables inherit the value and attributes of a variable of
13315 the same name that exists at a previous scope before any new value is
13316 assigned. The nameref attribute is not inherited.
13317 <DT><B>localvar_unset</B>
13318
13319 <DD>
13320 If set, calling <B>unset</B> on local variables in previous function scopes
13321 marks them so subsequent lookups find them unset until that function
13322 returns. This is identical to the behavior of unsetting local variables
13323 at the current function scope.
13324 <DT><B>login_shell</B>
13325
13326 <DD>
13327 The shell sets this option if it is started as a login shell (see
13328 <FONT SIZE=-1><B>INVOCATION</B>
13329
13330 </FONT>
13331
13332 above).
13333 The value may not be changed.
13334 <DT><B>mailwarn</B>
13335
13336 <DD>
13337 If set, and a file that <B>bash</B> is checking for mail has been
13338 accessed since the last time it was checked, the message ``The mail in
13339 <I>mailfile</I> has been read'' is displayed.
13340 <DT><B>no_empty_cmd_completion</B>
13341
13342 <DD>
13343 If set, and
13344 <B>readline</B>
13345
13346 is being used,
13347 <B>bash</B>
13348
13349 will not attempt to search the
13350 <FONT SIZE=-1><B>PATH</B>
13351
13352 </FONT>
13353 for possible completions when
13354 completion is attempted on an empty line.
13355 <DT><B>nocaseglob</B>
13356
13357 <DD>
13358 If set,
13359 <B>bash</B>
13360
13361 matches filenames in a case-insensitive fashion when performing pathname
13362 expansion (see
13363 <B>Pathname Expansion</B>
13364
13365
13366 above).
13367 <DT><B>nocasematch</B>
13368
13369 <DD>
13370 If set,
13371 <B>bash</B>
13372
13373 matches patterns in a case-insensitive fashion when performing matching
13374 while executing <B>case</B> or <B>[[</B> conditional commands,
13375 when performing pattern substitution word expansions,
13376 or when filtering possible completions as part of programmable completion.
13377 <DT><B>noexpand_translation</B>
13378
13379 <DD>
13380 If set,
13381 <B>bash</B>
13382
13383 encloses the translated results of $&quot;...&quot; quoting in single quotes
13384 instead of double quotes.
13385 If the string is not translated, this has no effect.
13386 <DT><B>nullglob</B>
13387
13388 <DD>
13389 If set,
13390 <B>bash</B>
13391
13392 allows patterns which match no
13393 files (see
13394 <B>Pathname Expansion</B>
13395
13396
13397 above)
13398 to expand to a null string, rather than themselves.
13399 <DT><B>patsub_replacement</B>
13400
13401 <DD>
13402 If set, <B>bash</B>
13403 expands occurrences of <B>&amp;</B> in the replacement string of pattern
13404 substitution to the text matched by the pattern, as described
13405 under <B>Parameter Expansion</B>
13406
13407 above.
13408 This option is enabled by default.
13409 <DT><B>progcomp</B>
13410
13411 <DD>
13412 If set, the programmable completion facilities (see
13413 <B>Programmable Completion</B>
13414
13415 above)
13416 are enabled.
13417 This option is enabled by default.
13418 <DT><B>progcomp_alias</B>
13419
13420 <DD>
13421 If set, and programmable completion is enabled, <B>bash</B> treats a command
13422 name that doesn't have any completions as a possible alias and attempts
13423 alias expansion. If it has an alias, <B>bash</B> attempts programmable
13424 completion using the command word resulting from the expanded alias.
13425 <DT><B>promptvars</B>
13426
13427 <DD>
13428 If set, prompt strings undergo
13429 parameter expansion, command substitution, arithmetic
13430 expansion, and quote removal after being expanded as described in
13431 <FONT SIZE=-1><B>PROMPTING</B>
13432
13433 </FONT>
13434
13435 above.
13436 This option is enabled by default.
13437 <DT><B>restricted_shell</B>
13438
13439 <DD>
13440 The shell sets this option if it is started in restricted mode
13441 (see
13442 <FONT SIZE=-1><B>RESTRICTED SHELL</B>
13443
13444 </FONT>
13445
13446 below).
13447 The value may not be changed.
13448 This is not reset when the startup files are executed, allowing
13449 the startup files to discover whether or not a shell is restricted.
13450 <DT><B>shift_verbose</B>
13451
13452 <DD>
13453 If set, the
13454 <B>shift</B>
13455
13456 builtin prints an error message when the shift count exceeds the
13457 number of positional parameters.
13458 <DT><B>sourcepath</B>
13459
13460 <DD>
13461 If set, the
13462 <B>.</B> (<B>source</B>) builtin uses the value of
13463 <FONT SIZE=-1><B>PATH</B>
13464
13465 </FONT>
13466 to find the directory containing the file supplied as an argument.
13467 This option is enabled by default.
13468 <DT><B>varredir_close</B>
13469
13470 <DD>
13471 If set, the shell automatically closes file descriptors assigned using the
13472 <I>{varname}</I> redirection syntax (see
13473 <FONT SIZE=-1><B>REDIRECTION</B>
13474
13475 </FONT>
13476
13477 above)
13478 instead of leaving them open when the command completes.
13479 <DT><B>xpg_echo</B>
13480
13481 <DD>
13482 If set, the <B>echo</B> builtin expands backslash-escape sequences
13483 by default.
13484 </DL></DL>
13485
13486
13487 <DT><B>suspend</B> [<B>-f</B>]<DD>
13488 Suspend the execution of this shell until it receives a
13489 <FONT SIZE=-1><B>SIGCONT</B>
13490
13491 </FONT>
13492 signal. A login shell,
13493 or a shell without job control enabled,
13494 cannot be suspended; the
13495 <B>-f</B>
13496
13497 option can be used to override this and force the suspension.
13498 The return status is 0 unless the shell is a login shell
13499 or job control is not enabled
13500 and
13501 <B>-f</B>
13502
13503 is not supplied.
13504 <DT><B>test</B> <I>expr</I><DD>
13505
13506 <DT><B>[</B> <I>expr</I> <B>]</B><DD>
13507 Return a status of 0 (true) or 1 (false) depending on
13508 the evaluation of the conditional expression
13509 <I>expr</I>.
13510
13511 Each operator and operand must be a separate argument.
13512 Expressions are composed of the primaries described
13513
13514 above
13515 under
13516 <FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>.
13517
13518 </FONT>
13519 <B>test</B> does not accept any options, nor does it accept and ignore
13520 an argument of <B>--</B> as signifying the end of options.
13521 <P>
13522
13523
13524 Expressions may be combined using the following operators, listed
13525 in decreasing order of precedence.
13526 The evaluation depends on the number of arguments; see below.
13527 Operator precedence is used when there are five or more arguments.
13528 <DL COMPACT><DT><DD>
13529
13530 <DL COMPACT>
13531 <DT><B>! </B><I>expr</I>
13532
13533 <DD>
13534 True if
13535 <I>expr</I>
13536
13537 is false.
13538 <DT><B>( </B><I>expr</I> )
13539
13540 <DD>
13541 Returns the value of <I>expr</I>.
13542 This may be used to override the normal precedence of operators.
13543 <DT><I>expr1</I> -<B>a</B> <I>expr2</I><DD>
13544 True if both
13545 <I>expr1</I>
13546
13547 and
13548 <I>expr2</I>
13549
13550 are true.
13551 <DT><I>expr1</I> -<B>o</B> <I>expr2</I><DD>
13552 True if either
13553 <I>expr1</I>
13554
13555 or
13556 <I>expr2</I>
13557
13558 is true.
13559
13560 </DL>
13561 <P>
13562
13563 <B>test</B> and <B>[</B> evaluate conditional
13564 expressions using a set of rules based on the number of arguments.
13565 <P>
13566
13567
13568
13569 <DL COMPACT>
13570 <DT>0 arguments<DD>
13571 The expression is false.
13572 <DT>1 argument<DD>
13573 The expression is true if and only if the argument is not null.
13574 <DT>2 arguments<DD>
13575 If the first argument is <B>!</B>, the expression is true if and
13576 only if the second argument is null.
13577 If the first argument is one of the unary conditional operators listed
13578
13579 above
13580 under
13581 <FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>,
13582
13583 </FONT>
13584 the expression is true if the unary test is true.
13585 If the first argument is not a valid unary conditional operator, the expression
13586 is false.
13587 <DT>3 arguments<DD>
13588 The following conditions are applied in the order listed.
13589 If the second argument is one of the binary conditional operators listed
13590
13591 above
13592 under
13593 <FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>,
13594
13595 </FONT>
13596 the result of the expression is the result of the binary test using
13597 the first and third arguments as operands.
13598 The <B>-a</B> and <B>-o</B> operators are considered binary operators
13599 when there are three arguments.
13600 If the first argument is <B>!</B>, the value is the negation of
13601 the two-argument test using the second and third arguments.
13602 If the first argument is exactly <B>(</B> and the third argument is
13603 exactly <B>)</B>, the result is the one-argument test of the second
13604 argument.
13605 Otherwise, the expression is false.
13606 <DT>4 arguments<DD>
13607 The following conditions are applied in the order listed.
13608 If the first argument is <B>!</B>, the result is the negation of
13609 the three-argument expression composed of the remaining arguments.
13610 the two-argument test using the second and third arguments.
13611 If the first argument is exactly <B>(</B> and the fourth argument is
13612 exactly <B>)</B>, the result is the two-argument test of the second
13613 and third arguments.
13614 Otherwise, the expression is parsed and evaluated according to
13615 precedence using the rules listed above.
13616 <DT>5 or more arguments<DD>
13617 The expression is parsed and evaluated according to precedence
13618 using the rules listed above.
13619 <P>
13620
13621
13622 </DL>
13623 <P>
13624
13625 When used with <B>test</B> or <B>[</B>, the <B>&lt;</B> and <B>&gt;</B> operators
13626 sort lexicographically using ASCII ordering.
13627 </DL>
13628
13629
13630 <DT><B>times</B>
13631
13632 <DD>
13633 Print the accumulated user and system times for the shell and
13634 for processes run from the shell. The return status is 0.
13635 <DT><B>trap</B> [<B>-lp</B>] [[<I>arg</I>] <I>sigspec</I> ...]<DD>
13636 The command
13637 <I>arg</I>
13638
13639 is to be read and executed when the shell receives
13640 signal(s)
13641 <I>sigspec</I>.
13642
13643 If
13644 <I>arg</I>
13645
13646 is absent (and there is a single <I>sigspec</I>) or
13647 <B>-</B>,
13648
13649 each specified signal is
13650 reset to its original disposition (the value it had
13651 upon entrance to the shell).
13652 If
13653 <I>arg</I>
13654
13655 is the null string the signal specified by each
13656 <I>sigspec</I>
13657
13658 is ignored by the shell and by the commands it invokes.
13659 If
13660 <I>arg</I>
13661
13662 is not present and
13663 <B>-p</B>
13664
13665 has been supplied, then the trap commands associated with each
13666 <I>sigspec</I>
13667
13668 are displayed.
13669 If no arguments are supplied or if only
13670 <B>-p</B>
13671
13672 is given,
13673 <B>trap</B>
13674
13675 prints the list of commands associated with each signal.
13676 The
13677 <B>-l</B>
13678
13679 option causes the shell to print a list of signal names and
13680 their corresponding numbers.
13681 Each
13682 <I>sigspec</I>
13683
13684 is either
13685 a signal name defined in &lt;<I>signal.h</I>&gt;, or a signal number.
13686 Signal names are case insensitive and the
13687 <FONT SIZE=-1><B>SIG</B>
13688
13689 </FONT>
13690 prefix is optional.
13691 <P>
13692
13693
13694 If a
13695 <I>sigspec</I>
13696
13697 is
13698 <FONT SIZE=-1><B>EXIT</B>
13699
13700 </FONT>
13701 (0) the command
13702 <I>arg</I>
13703
13704 is executed on exit from the shell.
13705 If a
13706 <I>sigspec</I>
13707
13708 is
13709 <FONT SIZE=-1><B>DEBUG</B>,
13710
13711 </FONT>
13712 the command
13713 <I>arg</I>
13714
13715 is executed before every <I>simple command</I>, <I>for</I> command,
13716 <I>case</I> command, <I>select</I> command, every arithmetic <I>for</I>
13717 command, and before the first command executes in a shell function (see
13718 <FONT SIZE=-1><B>SHELL GRAMMAR</B>
13719
13720 </FONT>
13721
13722 above).
13723 Refer to the description of the <B>extdebug</B> option to the
13724 <B>shopt</B> builtin for details of its effect on the <B>DEBUG</B> trap.
13725 If a
13726 <I>sigspec</I>
13727
13728 is
13729 <FONT SIZE=-1><B>RETURN</B>,
13730
13731 </FONT>
13732 the command
13733 <I>arg</I>
13734
13735 is executed each time a shell function or a script executed with
13736 the <B>.</B> or <B>source</B> builtins finishes executing.
13737 <P>
13738
13739
13740 If a
13741 <I>sigspec</I>
13742
13743 is
13744 <FONT SIZE=-1><B>ERR</B>,
13745
13746 </FONT>
13747 the command
13748 <I>arg</I>
13749
13750 is executed whenever
13751 a pipeline (which may consist of a single simple
13752 command), a list, or a compound command returns a
13753 non-zero exit status,
13754 subject to the following conditions.
13755 The
13756 <FONT SIZE=-1><B>ERR</B>
13757
13758 </FONT>
13759 trap is not executed if the failed
13760 command is part of the command list immediately following a
13761 <B>while</B>
13762
13763 or
13764 <B>until</B>
13765
13766 keyword,
13767 part of the test in an
13768 <I>if</I>
13769
13770 statement, part of a command executed in a
13771 <B>&amp;&amp;</B>
13772
13773 or
13774 <B>||</B>
13775
13776 list except the command following the final <B>&amp;&amp;</B> or <B>||</B>,
13777 any command in a pipeline but the last,
13778 or if the command's return value is
13779 being inverted using
13780 <B>!</B>.
13781
13782 These are the same conditions obeyed by the <B>errexit</B> (<B>-e</B>) option.
13783 <P>
13784
13785
13786 Signals ignored upon entry to the shell cannot be trapped or reset.
13787 Trapped signals that are not being ignored are reset to their original
13788 values in a subshell or subshell environment when one is created.
13789 The return status is false if any
13790 <I>sigspec</I>
13791
13792 is invalid; otherwise
13793 <B>trap</B>
13794
13795 returns true.
13796 <DT><B>type</B> [<B>-aftpP</B>] <I>name</I> [<I>name</I> ...]<DD>
13797 With no options,
13798 indicate how each
13799 <I>name</I>
13800
13801 would be interpreted if used as a command name.
13802 If the
13803 <B>-t</B>
13804
13805 option is used,
13806 <B>type</B>
13807
13808 prints a string which is one of
13809 <I>alias</I>,
13810
13811 <I>keyword</I>,
13812
13813 <I>function</I>,
13814
13815 <I>builtin</I>,
13816
13817 or
13818 <I>file</I>
13819
13820 if
13821 <I>name</I>
13822
13823 is an alias, shell reserved word, function, builtin, or disk file,
13824 respectively.
13825 If the
13826 <I>name</I>
13827
13828 is not found, then nothing is printed, and an exit status of false
13829 is returned.
13830 If the
13831 <B>-p</B>
13832
13833 option is used,
13834 <B>type</B>
13835
13836 either returns the name of the disk file
13837 that would be executed if
13838 <I>name</I>
13839
13840 were specified as a command name,
13841 or nothing if
13842 <TT>type -t name</TT>
13843
13844 would not return
13845 <I>file</I>.
13846
13847 The
13848 <B>-P</B>
13849
13850 option forces a
13851 <FONT SIZE=-1><B>PATH</B>
13852
13853 </FONT>
13854 search for each <I>name</I>, even if
13855 <TT>type -t name</TT>
13856
13857 would not return
13858 <I>file</I>.
13859
13860 If a command is hashed,
13861 <B>-p</B>
13862
13863 and
13864 <B>-P</B>
13865
13866 print the hashed value, which is not necessarily the file that appears
13867 first in
13868 <FONT SIZE=-1><B>PATH</B>.
13869
13870 </FONT>
13871 If the
13872 <B>-a</B>
13873
13874 option is used,
13875 <B>type</B>
13876
13877 prints all of the places that contain
13878 an executable named
13879 <I>name</I>.
13880
13881 This includes aliases and functions,
13882 if and only if the
13883 <B>-p</B>
13884
13885 option is not also used.
13886 The table of hashed commands is not consulted
13887 when using
13888 <B>-a</B>.
13889
13890 The
13891 <B>-f</B>
13892
13893 option suppresses shell function lookup, as with the <B>command</B> builtin.
13894 <B>type</B>
13895
13896 returns true if all of the arguments are found, false if
13897 any are not found.
13898 <DT><B>ulimit</B> [<B>-HS</B>] <B>-a</B><DD>
13899
13900 <DT><B>ulimit</B> [<B>-HS</B>] [<B>-bcdefiklmnpqrstuvxPRT</B> [<I>limit</I>]]<DD>
13901
13902 Provides control over the resources available to the shell and to
13903 processes started by it, on systems that allow such control.
13904 The <B>-H</B> and <B>-S</B> options specify that the hard or soft limit is
13905 set for the given resource.
13906 A hard limit cannot be increased by a non-root user once it is set;
13907 a soft limit may be increased up to the value of the hard limit.
13908 If neither <B>-H</B> nor <B>-S</B> is specified, both the soft and hard
13909 limits are set.
13910 The value of
13911 <I>limit</I>
13912
13913 can be a number in the unit specified for the resource
13914 or one of the special values
13915 <B>hard</B>,
13916
13917 <B>soft</B>,
13918
13919 or
13920 <B>unlimited</B>,
13921
13922 which stand for the current hard limit, the current soft limit, and
13923 no limit, respectively.
13924 If
13925 <I>limit</I>
13926
13927 is omitted, the current value of the soft limit of the resource is
13928 printed, unless the <B>-H</B> option is given. When more than one
13929 resource is specified, the limit name and unit, if appropriate,
13930 are printed before the value.
13931 Other options are interpreted as follows:
13932 <DL COMPACT><DT><DD>
13933
13934 <DL COMPACT>
13935 <DT><B>-a</B>
13936
13937 <DD>
13938 All current limits are reported; no limits are set
13939 <DT><B>-b</B>
13940
13941 <DD>
13942 The maximum socket buffer size
13943 <DT><B>-c</B>
13944
13945 <DD>
13946 The maximum size of core files created
13947 <DT><B>-d</B>
13948
13949 <DD>
13950 The maximum size of a process's data segment
13951 <DT><B>-e</B>
13952
13953 <DD>
13954 The maximum scheduling priority (&quot;nice&quot;)
13955 <DT><B>-f</B>
13956
13957 <DD>
13958 The maximum size of files written by the shell and its children
13959 <DT><B>-i</B>
13960
13961 <DD>
13962 The maximum number of pending signals
13963 <DT><B>-k</B>
13964
13965 <DD>
13966 The maximum number of kqueues that may be allocated
13967 <DT><B>-l</B>
13968
13969 <DD>
13970 The maximum size that may be locked into memory
13971 <DT><B>-m</B>
13972
13973 <DD>
13974 The maximum resident set size (many systems do not honor this limit)
13975 <DT><B>-n</B>
13976
13977 <DD>
13978 The maximum number of open file descriptors (most systems do not
13979 allow this value to be set)
13980 <DT><B>-p</B>
13981
13982 <DD>
13983 The pipe size in 512-byte blocks (this may not be set)
13984 <DT><B>-q</B>
13985
13986 <DD>
13987 The maximum number of bytes in POSIX message queues
13988 <DT><B>-r</B>
13989
13990 <DD>
13991 The maximum real-time scheduling priority
13992 <DT><B>-s</B>
13993
13994 <DD>
13995 The maximum stack size
13996 <DT><B>-t</B>
13997
13998 <DD>
13999 The maximum amount of cpu time in seconds
14000 <DT><B>-u</B>
14001
14002 <DD>
14003 The maximum number of processes available to a single user
14004 <DT><B>-v</B>
14005
14006 <DD>
14007 The maximum amount of virtual memory available to the shell and, on
14008 some systems, to its children
14009 <DT><B>-x</B>
14010
14011 <DD>
14012 The maximum number of file locks
14013 <DT><B>-P</B>
14014
14015 <DD>
14016 The maximum number of pseudoterminals
14017 <DT><B>-R</B>
14018
14019 <DD>
14020 The maximum time a real-time process can run before blocking, in microseconds
14021 <DT><B>-T</B>
14022
14023 <DD>
14024 The maximum number of threads
14025
14026 </DL>
14027 <P>
14028
14029 If
14030 <I>limit</I>
14031
14032 is given, and the
14033 <B>-a</B>
14034
14035 option is not used,
14036 <I>limit</I> is the new value of the specified resource.
14037 If no option is given, then
14038 <B>-f</B>
14039
14040 is assumed. Values are in 1024-byte increments, except for
14041 <B>-t</B>,
14042
14043 which is in seconds;
14044 <B>-R</B>,
14045
14046 which is in microseconds;
14047 <B>-p</B>,
14048
14049 which is in units of 512-byte blocks;
14050 <B>-P</B>,
14051
14052 <B>-T</B>,
14053
14054 <B>-b</B>,
14055
14056 <B>-k</B>,
14057
14058 <B>-n</B>,
14059
14060 and
14061 <B>-u</B>,
14062
14063 which are unscaled values;
14064 and, when in posix mode,
14065 <B>-c</B>
14066
14067 and
14068 <B>-f</B>,
14069
14070 which are in 512-byte increments.
14071 The return status is 0 unless an invalid option or argument is supplied,
14072 or an error occurs while setting a new limit.
14073 </DL>
14074
14075 <DT><B>umask</B> [<B>-p</B>] [<B>-S</B>] [<I>mode</I>]<DD>
14076 The user file-creation mask is set to
14077 <I>mode</I>.
14078
14079 If
14080 <I>mode</I>
14081
14082 begins with a digit, it
14083 is interpreted as an octal number; otherwise
14084 it is interpreted as a symbolic mode mask similar
14085 to that accepted by
14086 <I>chmod</I>(1).
14087
14088 If
14089 <I>mode</I>
14090
14091 is omitted, the current value of the mask is printed.
14092 The
14093 <B>-S</B>
14094
14095 option causes the mask to be printed in symbolic form; the
14096 default output is an octal number.
14097 If the
14098 <B>-p</B>
14099
14100 option is supplied, and
14101 <I>mode</I>
14102
14103 is omitted, the output is in a form that may be reused as input.
14104 The return status is 0 if the mode was successfully changed or if
14105 no <I>mode</I> argument was supplied, and false otherwise.
14106 <DT><B>unalias</B> [-<B>a</B>] [<I>name</I> ...]<DD>
14107 Remove each <I>name</I> from the list of defined aliases. If
14108 <B>-a</B>
14109
14110 is supplied, all alias definitions are removed. The return
14111 value is true unless a supplied
14112 <I>name</I>
14113
14114 is not a defined alias.
14115 <DT><B>unset</B> [-<B>fv</B>] [-<B>n</B>] [<I>name</I> ...]<DD>
14116 For each
14117 <I>name</I>,
14118
14119 remove the corresponding variable or function.
14120 If the
14121 <B>-v</B>
14122
14123 option is given, each
14124 <I>name</I>
14125
14126 refers to a shell variable, and that variable is removed.
14127 Read-only variables may not be unset.
14128 If
14129 <B>-f</B>
14130
14131 is specified, each
14132 <I>name</I>
14133
14134 refers to a shell function, and the function definition
14135 is removed.
14136 If the
14137 <B>-n</B>
14138
14139 option is supplied, and <I>name</I> is a variable with the <I>nameref</I>
14140 attribute, <I>name</I> will be unset rather than the variable it
14141 references.
14142 <B>-n</B> has no effect if the <B>-f</B> option is supplied.
14143 If no options are supplied, each <I>name</I> refers to a variable; if
14144 there is no variable by that name, a function with that name, if any, is
14145 unset.
14146 Each unset variable or function is removed from the environment
14147 passed to subsequent commands.
14148 If any of
14149 <FONT SIZE=-1><B>BASH_ALIASES</B>,
14150
14151 </FONT>
14152 <FONT SIZE=-1><B>BASH_ARGV0</B>,
14153
14154 </FONT>
14155 <FONT SIZE=-1><B>BASH_CMDS</B>,
14156
14157 </FONT>
14158 <FONT SIZE=-1><B>BASH_COMMAND</B>,
14159
14160 </FONT>
14161 <FONT SIZE=-1><B>BASH_SUBSHELL</B>,
14162
14163 </FONT>
14164 <FONT SIZE=-1><B>BASHPID</B>,
14165
14166 </FONT>
14167 <FONT SIZE=-1><B>COMP_WORDBREAKS</B>,
14168
14169 </FONT>
14170 <FONT SIZE=-1><B>DIRSTACK</B>,
14171
14172 </FONT>
14173 <FONT SIZE=-1><B>EPOCHREALTIME</B>,
14174
14175 </FONT>
14176 <FONT SIZE=-1><B>EPOCHSECONDS</B>,
14177
14178 </FONT>
14179 <FONT SIZE=-1><B>FUNCNAME</B>,
14180
14181 </FONT>
14182 <FONT SIZE=-1><B>GROUPS</B>,
14183
14184 </FONT>
14185 <FONT SIZE=-1><B>HISTCMD</B>,
14186
14187 </FONT>
14188 <FONT SIZE=-1><B>LINENO</B>,
14189
14190 </FONT>
14191 <FONT SIZE=-1><B>RANDOM</B>,
14192
14193 </FONT>
14194 <FONT SIZE=-1><B>SECONDS</B>,
14195
14196 </FONT>
14197 or
14198 <FONT SIZE=-1><B>SRANDOM</B>
14199
14200 </FONT>
14201 are unset, they lose their special properties, even if they are
14202 subsequently reset. The exit status is true unless a
14203 <I>name</I>
14204
14205 is readonly or may not be unset.
14206 <DT><B>wait</B> [<B>-fn</B>] [-p <I>varname</I>] [<I>id ...</I>]<DD>
14207 Wait for each specified child process and return its termination status.
14208 Each
14209 <I>id</I>
14210
14211 may be a process
14212 ID or a job specification; if a job spec is given, all processes
14213 in that job's pipeline are waited for. If
14214 <I>id</I>
14215
14216 is not given,
14217 <B>wait</B> waits for all running background jobs and
14218 the last-executed process substitution, if its process id is the same as
14219 <B>$!</B>,
14220 and the return status is zero.
14221 If the <B>-n</B> option is supplied,
14222 <B>wait</B> waits for a single job
14223 from the list of <I>id</I>s or, if no <I>id</I>s are supplied, any job,
14224 to complete and returns its exit status.
14225 If none of the supplied arguments is a child of the shell, or if no arguments
14226 are supplied and the shell has no unwaited-for children, the exit status
14227 is 127.
14228 If the <B>-p</B> option is supplied, the process or job identifier of the job
14229 for which the exit status is returned is assigned to the variable
14230 <I>varname</I> named by the option argument.
14231 The variable will be unset initially, before any assignment.
14232 This is useful only when the <B>-n</B> option is supplied.
14233 Supplying the <B>-f</B> option, when job control is enabled,
14234 forces <B>wait</B> to wait for <I>id</I> to terminate before returning
14235 its status, instead of returning when it changes status.
14236 If
14237 <I>id</I>
14238
14239 specifies a non-existent process or job, the return status is 127.
14240 If <B>wait</B> is interrupted by a signal, the return status will be greater
14241 than 128, as described under
14242 <B>SIGNALS</B>
14243
14244
14245 above.
14246 Otherwise, the return status is the exit status of the last
14247 process or job waited for.
14248 </DL>
14249 <A NAME="lbDC">&nbsp;</A>
14250 <H3>SHELL COMPATIBILITY MODE</H3>
14251
14252 Bash-4.0 introduced the concept of a <I>shell compatibility level</I>,
14253 specified as a set of options to the shopt builtin (
14254 <B>compat31</B>,
14255
14256 <B>compat32</B>,
14257
14258 <B>compat40</B>,
14259
14260 <B>compat41</B>,
14261
14262 and so on).
14263 There is only one current
14264 compatibility level -- each option is mutually exclusive.
14265 The compatibility level is intended to allow users to select behavior
14266 from previous versions that is incompatible with newer versions
14267 while they migrate scripts to use current features and
14268 behavior. It's intended to be a temporary solution.
14269 <P>
14270
14271 This section does not mention behavior that is standard for a particular
14272 version (e.g., setting <B>compat32</B> means that quoting the rhs of the regexp
14273 matching operator quotes special regexp characters in the word, which is
14274 default behavior in bash-3.2 and subsequent versions).
14275 <P>
14276
14277 If a user enables, say, <B>compat32</B>, it may affect the behavior of other
14278 compatibility levels up to and including the current compatibility level.
14279 The idea is that each compatibility level controls behavior that changed
14280 in that version of <B>bash</B>,
14281 but that behavior may have been present in earlier versions.
14282 For instance, the change to use locale-based comparisons with the <B>[[</B>
14283 command came in bash-4.1, and earlier versions used ASCII-based comparisons,
14284 so enabling <B>compat32</B> will enable ASCII-based comparisons as well.
14285 That granularity may not be sufficient for
14286 all uses, and as a result users should employ compatibility levels carefully.
14287 Read the documentation for a particular feature to find out the
14288 current behavior.
14289 <P>
14290
14291 Bash-4.3 introduced a new shell variable:
14292 <FONT SIZE=-1><B>BASH_COMPAT</B>.
14293
14294 </FONT>
14295 The value assigned
14296 to this variable (a decimal version number like 4.2, or an integer
14297 corresponding to the <B>compat</B><I>NN</I> option, like 42) determines the
14298 compatibility level.
14299 <P>
14300
14301 Starting with bash-4.4, Bash has begun deprecating older compatibility
14302 levels.
14303 Eventually, the options will be removed in favor of
14304 <FONT SIZE=-1><B>BASH_COMPAT</B>.
14305
14306 </FONT>
14307 <P>
14308
14309 Bash-5.0 is the final version for which there will be an individual shopt
14310 option for the previous version. Users should use
14311 <FONT SIZE=-1><B>BASH_COMPAT</B>
14312
14313 </FONT>
14314 on bash-5.0 and later versions.
14315 <P>
14316
14317 The following table describes the behavior changes controlled by each
14318 compatibility level setting.
14319 The <B>compat</B><I>NN</I> tag is used as shorthand for setting the
14320 compatibility level
14321 to <I>NN</I> using one of the following mechanisms.
14322 For versions prior to bash-5.0, the compatibility level may be set using
14323 the corresponding <B>compat</B><I>NN</I> shopt option.
14324 For bash-4.3 and later versions, the
14325 <FONT SIZE=-1><B>BASH_COMPAT</B>
14326
14327 </FONT>
14328 variable is preferred,
14329 and it is required for bash-5.1 and later versions.
14330 <DL COMPACT>
14331 <DT><B>compat31</B><DD>
14332
14333 <DL COMPACT><DT><DD>
14334 <DL COMPACT>
14335 <DT>*<DD>
14336 quoting the rhs of the <B>[[</B> command's regexp matching operator (=~)
14337 has no special effect
14338 </DL></DL>
14339
14340
14341 <DT><B>compat32</B><DD>
14342
14343 <DL COMPACT><DT><DD>
14344 <DL COMPACT>
14345 <DT>*<DD>
14346 interrupting a command list such as &quot;a ; b ; c&quot; causes the execution
14347 of the next command in the list (in bash-4.0 and later versions,
14348 the shell acts as if it received the interrupt, so
14349 interrupting one command in a list aborts the execution of the
14350 entire list)
14351 </DL></DL>
14352
14353
14354 <DT><B>compat40</B><DD>
14355
14356 <DL COMPACT><DT><DD>
14357 <DL COMPACT>
14358 <DT>*<DD>
14359 the <B>&lt;</B> and <B>&gt;</B> operators to the <B>[[</B> command do not
14360 consider the current locale when comparing strings; they use ASCII
14361 ordering.
14362 Bash versions prior to bash-4.1 use ASCII collation and
14363 <I>strcmp</I>(3);
14364
14365 bash-4.1 and later use the current locale's collation sequence and
14366 <I>strcoll</I>(3).
14367
14368 </DL></DL>
14369
14370
14371 <DT><B>compat41</B><DD>
14372
14373 <DL COMPACT><DT><DD>
14374 <DL COMPACT>
14375 <DT>*<DD>
14376 in <I>posix</I> mode, <B>time</B> may be followed by options and still be
14377 recognized as a reserved word (this is POSIX interpretation 267)
14378 <DT>*<DD>
14379 in <I>posix</I> mode, the parser requires that an even number of single
14380 quotes occur in the <I>word</I> portion of a double-quoted
14381 parameter expansion and treats them specially, so that characters within
14382 the single quotes are considered quoted
14383 (this is POSIX interpretation 221)
14384 </DL></DL>
14385
14386
14387 <DT><B>compat42</B><DD>
14388
14389 <DL COMPACT><DT><DD>
14390 <DL COMPACT>
14391 <DT>*<DD>
14392 the replacement string in double-quoted pattern substitution does not
14393 undergo quote removal, as it does in versions after bash-4.2
14394 <DT>*<DD>
14395 in posix mode, single quotes are considered special when expanding
14396 the <I>word</I> portion of a double-quoted parameter expansion
14397 and can be used to quote a closing brace or other special character
14398 (this is part of POSIX interpretation 221);
14399 in later versions, single quotes
14400 are not special within double-quoted word expansions
14401 </DL></DL>
14402
14403
14404 <DT><B>compat43</B><DD>
14405
14406 <DL COMPACT><DT><DD>
14407 <DL COMPACT>
14408 <DT>*<DD>
14409 the shell does not print a warning message if an attempt is made to
14410 use a quoted compound assignment as an argument to declare
14411 (e.g., declare -a foo=aq(1 2)aq). Later versions warn that this usage is
14412 deprecated
14413 <DT>*<DD>
14414 word expansion errors are considered non-fatal errors that cause the
14415 current command to fail, even in posix mode
14416 (the default behavior is to make them fatal errors that cause the shell
14417 to exit)
14418 <DT>*<DD>
14419 when executing a shell function, the loop state (while/until/etc.)
14420 is not reset, so <B>break</B> or <B>continue</B> in that function will break
14421 or continue loops in the calling context. Bash-4.4 and later reset
14422 the loop state to prevent this
14423 </DL></DL>
14424
14425
14426 <DT><B>compat44</B><DD>
14427
14428 <DL COMPACT><DT><DD>
14429 <DL COMPACT>
14430 <DT>*<DD>
14431 the shell sets up the values used by
14432 <FONT SIZE=-1><B>BASH_ARGV</B>
14433
14434 </FONT>
14435 and
14436 <FONT SIZE=-1><B>BASH_ARGC</B>
14437
14438 </FONT>
14439 so they can expand to the shell's positional parameters even if extended
14440 debugging mode is not enabled
14441 <DT>*<DD>
14442 a subshell inherits loops from its parent context, so <B>break</B>
14443 or <B>continue</B> will cause the subshell to exit.
14444 Bash-5.0 and later reset the loop state to prevent the exit
14445 <DT>*<DD>
14446 variable assignments preceding builtins like <B>export</B> and <B>readonly</B>
14447 that set attributes continue to affect variables with the same
14448 name in the calling environment even if the shell is not in posix
14449 mode
14450 </DL></DL>
14451
14452
14453 <DT><B>compat50</B><DD>
14454
14455 <DL COMPACT><DT><DD>
14456 <DL COMPACT>
14457 <DT>*<DD>
14458 Bash-5.1 changed the way
14459 <FONT SIZE=-1><B>$RANDOM</B>
14460
14461 </FONT>
14462 is generated to introduce slightly
14463 more randomness. If the shell compatibility level is set to 50 or
14464 lower, it reverts to the method from bash-5.0 and previous versions,
14465 so seeding the random number generator by assigning a value to
14466 <FONT SIZE=-1><B>RANDOM</B>
14467
14468 </FONT>
14469 will produce the same sequence as in bash-5.0
14470 <DT>*<DD>
14471 If the command hash table is empty, bash versions prior to bash-5.1
14472 printed an informational message to that effect, even when producing
14473 output that can be reused as input. Bash-5.1 suppresses that message
14474 when the <B>-l</B> option is supplied.
14475 </DL></DL>
14476
14477
14478 <DT><B>compat51</B><DD>
14479
14480 <DL COMPACT><DT><DD>
14481 <DL COMPACT>
14482 <DT>*<DD>
14483 The <B>unset</B> builtin treats attempts to unset array subscripts <B>@</B>
14484 and <B>*</B> differently depending on whether the array is indexed or
14485 associative, and differently than in previous versions.
14486 </DL></DL>
14487
14488
14489
14490
14491 </DL>
14492 <A NAME="lbDD">&nbsp;</A>
14493 <H3>RESTRICTED SHELL</H3>
14494
14495
14496
14497 <P>
14498
14499 If
14500 <B>bash</B>
14501
14502 is started with the name
14503 <B>rbash</B>,
14504
14505 or the
14506 <B>-r</B>
14507
14508 option is supplied at invocation,
14509 the shell becomes restricted.
14510 A restricted shell is used to
14511 set up an environment more controlled than the standard shell.
14512 It behaves identically to
14513 <B>bash</B>
14514
14515 with the exception that the following are disallowed or not performed:
14516 <DL COMPACT>
14517 <DT>*<DD>
14518 changing directories with <B>cd</B>
14519 <DT>*<DD>
14520 setting or unsetting the values of
14521 <FONT SIZE=-1><B>SHELL</B>,
14522
14523 </FONT>
14524 <FONT SIZE=-1><B>PATH</B>,
14525
14526 </FONT>
14527 <FONT SIZE=-1><B>HISTFILE</B>,
14528
14529 </FONT>
14530 <FONT SIZE=-1><B>ENV</B>,
14531
14532 </FONT>
14533 or
14534 <FONT SIZE=-1><B>BASH_ENV</B>
14535
14536 </FONT>
14537 <DT>*<DD>
14538 specifying command names containing
14539 <B>/</B>
14540
14541 <DT>*<DD>
14542 specifying a filename containing a
14543 <B>/</B>
14544
14545 as an argument to the
14546 <B>.</B>
14547
14548 builtin command
14549 <DT>*<DD>
14550 specifying a filename containing a slash as an argument to the
14551 <B>history</B>
14552
14553 builtin command
14554 <DT>*<DD>
14555 specifying a filename containing a slash as an argument to the
14556 <B>-p</B>
14557
14558 option to the
14559 <B>hash</B>
14560
14561 builtin command
14562 <DT>*<DD>
14563 importing function definitions from the shell environment at startup
14564 <DT>*<DD>
14565 parsing the value of
14566 <FONT SIZE=-1><B>SHELLOPTS</B>
14567
14568 </FONT>
14569 from the shell environment at startup
14570 <DT>*<DD>
14571 redirecting output using the &gt;, &gt;|, &lt;&gt;, &gt;&amp;, &amp;&gt;, and &gt;&gt; redirection operators
14572 <DT>*<DD>
14573 using the
14574 <B>exec</B>
14575
14576 builtin command to replace the shell with another command
14577 <DT>*<DD>
14578 adding or deleting builtin commands with the
14579 <B>-f</B>
14580
14581 and
14582 <B>-d</B>
14583
14584 options to the
14585 <B>enable</B>
14586
14587 builtin command
14588 <DT>*<DD>
14589 using the <B>enable</B> builtin command to enable disabled shell builtins
14590 <DT>*<DD>
14591 specifying the
14592 <B>-p</B>
14593
14594 option to the
14595 <B>command</B>
14596
14597 builtin command
14598 <DT>*<DD>
14599 turning off restricted mode with
14600 <B>set +r</B> or <B>shopt -u restricted_shell</B>.
14601 </DL>
14602 <P>
14603
14604 These restrictions are enforced after any startup files are read.
14605 <P>
14606
14607
14608 When a command that is found to be a shell script is executed
14609 (see
14610 <FONT SIZE=-1><B>COMMAND EXECUTION</B>
14611
14612 </FONT>
14613
14614 above),
14615
14616 <B>rbash</B>
14617
14618 turns off any restrictions in the shell spawned to execute the
14619 script.
14620
14621
14622 <A NAME="lbDE">&nbsp;</A>
14623 <H3>SEE ALSO</H3>
14624
14625
14626 <DL COMPACT>
14627 <DT><I>Bash Reference Manual</I>, Brian Fox and Chet Ramey<DD>
14628 <DT><I>The Gnu Readline Library</I>, Brian Fox and Chet Ramey<DD>
14629 <DT><I>The Gnu History Library</I>, Brian Fox and Chet Ramey<DD>
14630 <DT><I>Portable Operating System Interface (POSIX) Part 2: Shell and Utilities</I>, IEEE --<DD>
14631 <A HREF="http://pubs.opengroup.org/onlinepubs/9699919799/">http://pubs.opengroup.org/onlinepubs/9699919799/</A>
14632 <DT><A HREF="http://tiswww.case.edu/~chet/bash/POSIX">http://tiswww.case.edu/~chet/bash/POSIX</A> -- a description of posix mode<DD>
14633 <DT><I>sh</I>(1), <I>ksh</I>(1), <I>csh</I>(1)<DD>
14634 <DT><I>emacs</I>(1), <I>vi</I>(1)<DD>
14635 <DT><I>readline</I>(3)<DD>
14636
14637 </DL>
14638 <A NAME="lbDF">&nbsp;</A>
14639 <H3>FILES</H3>
14640
14641
14642 <DL COMPACT>
14643 <DT>
14644 <A HREF="file:/bin/bash"><I>/bin/bash</I></A>
14645
14646 <DD>
14647 The <B>bash</B> executable
14648 <DT>
14649 <A HREF="file:/etc/profile"><I>/etc/profile</I></A>
14650
14651 <DD>
14652 The systemwide initialization file, executed for login shells
14653 <DT>
14654 <A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>
14655
14656 <DD>
14657 The personal initialization file, executed for login shells
14658 <DT>
14659 <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
14660
14661 <DD>
14662 The individual per-interactive-shell startup file
14663 <DT>
14664 <A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A>
14665
14666 <DD>
14667 The individual login shell cleanup file, executed when a login shell exits
14668 <DT>
14669 <A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>
14670
14671 <DD>
14672 The default value of <B>HISTFILE</B>, the file in which bash saves the
14673 command history
14674 <DT>
14675 <A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>
14676
14677 <DD>
14678 Individual <I>readline</I> initialization file
14679
14680 </DL>
14681 <A NAME="lbDG">&nbsp;</A>
14682 <H3>AUTHORS</H3>
14683
14684 Brian Fox, Free Software Foundation
14685 <BR>
14686
14687 <A HREF="mailto:bfox@gnu.org">bfox@gnu.org</A>
14688 <P>
14689
14690 Chet Ramey, Case Western Reserve University
14691 <BR>
14692
14693 <A HREF="mailto:chet.ramey@case.edu">chet.ramey@case.edu</A>
14694 <A NAME="lbDH">&nbsp;</A>
14695 <H3>BUG REPORTS</H3>
14696
14697 If you find a bug in
14698 <B>bash,</B>
14699
14700 you should report it. But first, you should
14701 make sure that it really is a bug, and that it appears in the latest
14702 version of
14703 <B>bash</B>.
14704
14705 The latest version is always available from
14706 <I><A HREF="ftp://ftp.gnu.org/pub/gnu/bash/">ftp://ftp.gnu.org/pub/gnu/bash/</A></I> and
14707 <I><A HREF="http://git.savannah.gnu.org/cgit/bash.git/snapshot/bash-master.tar.gz">http://git.savannah.gnu.org/cgit/bash.git/snapshot/bash-master.tar.gz</A></I>.
14708 <P>
14709
14710 Once you have determined that a bug actually exists, use the
14711 <I>bashbug</I>
14712
14713 command to submit a bug report.
14714 If you have a fix, you are encouraged to mail that as well!
14715 Suggestions and `philosophical' bug reports may be mailed
14716 to <I><A HREF="mailto:bug-bash@gnu.org">bug-bash@gnu.org</A></I> or posted to the Usenet
14717 newsgroup
14718 <A HREF="news:gnu.bash.bug">gnu.bash.bug</A>.
14719
14720 <P>
14721
14722 ALL bug reports should include:
14723 <P>
14724
14725
14726 <DL COMPACT>
14727 <DT>The version number of <B>bash</B><DD>
14728 <DT>The hardware and operating system<DD>
14729 <DT>The compiler used to compile<DD>
14730 <DT>A description of the bug behaviour<DD>
14731 <DT>A short script or `recipe' which exercises the bug<DD>
14732
14733 </DL>
14734 <P>
14735
14736 <I>bashbug</I>
14737
14738 inserts the first three items automatically into the template
14739 it provides for filing a bug report.
14740 <P>
14741
14742 Comments and bug reports concerning
14743 this manual page should be directed to
14744 <I><A HREF="mailto:chet.ramey@case.edu">chet.ramey@case.edu</A></I>.
14745
14746 <A NAME="lbDI">&nbsp;</A>
14747 <H3>BUGS</H3>
14748
14749 It's too big and too slow.
14750 <P>
14751
14752 There are some subtle differences between
14753 <B>bash</B>
14754
14755 and traditional versions of
14756 <B>sh</B>,
14757
14758 mostly because of the
14759 <FONT SIZE=-1><B>POSIX</B>
14760
14761 </FONT>
14762 specification.
14763 <P>
14764
14765 Aliases are confusing in some uses.
14766 <P>
14767
14768 Shell builtin commands and functions are not stoppable/restartable.
14769 <P>
14770
14771 Compound commands and command sequences of the form `a ; b ; c'
14772 are not handled gracefully when process suspension is attempted.
14773 When a process is stopped, the shell immediately executes the next
14774 command in the sequence.
14775 It suffices to place the sequence of commands between
14776 parentheses to force it into a subshell, which may be stopped as
14777 a unit.
14778 <P>
14779
14780 Array variables may not (yet) be exported.
14781 <P>
14782
14783 There may be only one active coprocess at a time.
14784
14785
14786
14787 <HR>
14788 <TABLE WIDTH=100%>
14789 <TR>
14790 <TH ALIGN=LEFT width=33%>GNU Bash 5.2<TH ALIGN=CENTER width=33%>2022 September 19<TH ALIGN=RIGHT width=33%>BASH(1)
14791 </TR>
14792 </TABLE>
14793 <HR>
14794 <A NAME="index">&nbsp;</A><H2>Index</H2>
14795 <DL>
14796 <DT><A HREF="#lbAB">NAME</A><DD>
14797 <DT><A HREF="#lbAC">SYNOPSIS</A><DD>
14798 <DT><A HREF="#lbAD">COPYRIGHT</A><DD>
14799 <DT><A HREF="#lbAE">DESCRIPTION</A><DD>
14800 <DT><A HREF="#lbAF">OPTIONS</A><DD>
14801 <DT><A HREF="#lbAG">ARGUMENTS</A><DD>
14802 <DT><A HREF="#lbAH">INVOCATION</A><DD>
14803 <DT><A HREF="#lbAI">DEFINITIONS</A><DD>
14804 <DT><A HREF="#lbAJ">RESERVED WORDS</A><DD>
14805 <DT><A HREF="#lbAK">SHELL GRAMMAR</A><DD>
14806 <DL>
14807 <DT><A HREF="#lbAL">Simple Commands</A><DD>
14808 <DT><A HREF="#lbAM">Pipelines</A><DD>
14809 <DT><A HREF="#lbAN">Lists</A><DD>
14810 <DT><A HREF="#lbAO">Compound Commands</A><DD>
14811 <DT><A HREF="#lbAP">Coprocesses</A><DD>
14812 <DT><A HREF="#lbAQ">Shell Function Definitions</A><DD>
14813 </DL>
14814 <DT><A HREF="#lbAR">COMMENTS</A><DD>
14815 <DT><A HREF="#lbAS">QUOTING</A><DD>
14816 <DT><A HREF="#lbAT">PARAMETERS</A><DD>
14817 <DL>
14818 <DT><A HREF="#lbAU">Positional Parameters</A><DD>
14819 <DT><A HREF="#lbAV">Special Parameters</A><DD>
14820 <DT><A HREF="#lbAW">Shell Variables</A><DD>
14821 <DT><A HREF="#lbAX">Arrays</A><DD>
14822 </DL>
14823 <DT><A HREF="#lbAY">EXPANSION</A><DD>
14824 <DL>
14825 <DT><A HREF="#lbAZ">Brace Expansion</A><DD>
14826 <DT><A HREF="#lbBA">Tilde Expansion</A><DD>
14827 <DT><A HREF="#lbBB">Parameter Expansion</A><DD>
14828 <DT><A HREF="#lbBC">Command Substitution</A><DD>
14829 <DT><A HREF="#lbBD">Arithmetic Expansion</A><DD>
14830 <DT><A HREF="#lbBE">Process Substitution</A><DD>
14831 <DT><A HREF="#lbBF">Word Splitting</A><DD>
14832 <DT><A HREF="#lbBG">Pathname Expansion</A><DD>
14833 <DT><A HREF="#lbBH">Quote Removal</A><DD>
14834 </DL>
14835 <DT><A HREF="#lbBI">REDIRECTION</A><DD>
14836 <DL>
14837 <DT><A HREF="#lbBJ">Redirecting Input</A><DD>
14838 <DT><A HREF="#lbBK">Redirecting Output</A><DD>
14839 <DT><A HREF="#lbBL">Appending Redirected Output</A><DD>
14840 <DT><A HREF="#lbBM">Redirecting Standard Output and Standard Error</A><DD>
14841 <DT><A HREF="#lbBN">Appending Standard Output and Standard Error</A><DD>
14842 <DT><A HREF="#lbBO">Here Documents</A><DD>
14843 <DT><A HREF="#lbBP">Here Strings</A><DD>
14844 <DT><A HREF="#lbBQ">Duplicating File Descriptors</A><DD>
14845 <DT><A HREF="#lbBR">Moving File Descriptors</A><DD>
14846 <DT><A HREF="#lbBS">Opening File Descriptors for Reading and Writing</A><DD>
14847 </DL>
14848 <DT><A HREF="#lbBT">ALIASES</A><DD>
14849 <DT><A HREF="#lbBU">FUNCTIONS</A><DD>
14850 <DT><A HREF="#lbBV">ARITHMETIC EVALUATION</A><DD>
14851 <DT><A HREF="#lbBW">CONDITIONAL EXPRESSIONS</A><DD>
14852 <DT><A HREF="#lbBX">SIMPLE COMMAND EXPANSION</A><DD>
14853 <DT><A HREF="#lbBY">COMMAND EXECUTION</A><DD>
14854 <DT><A HREF="#lbBZ">COMMAND EXECUTION ENVIRONMENT</A><DD>
14855 <DT><A HREF="#lbCA">ENVIRONMENT</A><DD>
14856 <DT><A HREF="#lbCB">EXIT STATUS</A><DD>
14857 <DT><A HREF="#lbCC">SIGNALS</A><DD>
14858 <DT><A HREF="#lbCD">JOB CONTROL</A><DD>
14859 <DT><A HREF="#lbCE">PROMPTING</A><DD>
14860 <DT><A HREF="#lbCF">READLINE</A><DD>
14861 <DL>
14862 <DT><A HREF="#lbCG">Readline Notation</A><DD>
14863 <DT><A HREF="#lbCH">Readline Initialization</A><DD>
14864 <DT><A HREF="#lbCI">Readline Key Bindings</A><DD>
14865 <DT><A HREF="#lbCJ">Readline Variables</A><DD>
14866 <DT><A HREF="#lbCK">Readline Conditional Constructs</A><DD>
14867 <DT><A HREF="#lbCL">Searching</A><DD>
14868 <DT><A HREF="#lbCM">Readline Command Names</A><DD>
14869 <DT><A HREF="#lbCN">Commands for Moving</A><DD>
14870 <DT><A HREF="#lbCO">Commands for Manipulating the History</A><DD>
14871 <DT><A HREF="#lbCP">Commands for Changing Text</A><DD>
14872 <DT><A HREF="#lbCQ">Killing and Yanking</A><DD>
14873 <DT><A HREF="#lbCR">Numeric Arguments</A><DD>
14874 <DT><A HREF="#lbCS">Completing</A><DD>
14875 <DT><A HREF="#lbCT">Keyboard Macros</A><DD>
14876 <DT><A HREF="#lbCU">Miscellaneous</A><DD>
14877 <DT><A HREF="#lbCV">Programmable Completion</A><DD>
14878 </DL>
14879 <DT><A HREF="#lbCW">HISTORY</A><DD>
14880 <DT><A HREF="#lbCX">HISTORY EXPANSION</A><DD>
14881 <DL>
14882 <DT><A HREF="#lbCY">Event Designators</A><DD>
14883 <DT><A HREF="#lbCZ">Word Designators</A><DD>
14884 <DT><A HREF="#lbDA">Modifiers</A><DD>
14885 </DL>
14886 <DT><A HREF="#lbDB">SHELL BUILTIN COMMANDS</A><DD>
14887 <DT><A HREF="#lbDC">SHELL COMPATIBILITY MODE</A><DD>
14888 <DT><A HREF="#lbDD">RESTRICTED SHELL</A><DD>
14889 <DT><A HREF="#lbDE">SEE ALSO</A><DD>
14890 <DT><A HREF="#lbDF">FILES</A><DD>
14891 <DT><A HREF="#lbDG">AUTHORS</A><DD>
14892 <DT><A HREF="#lbDH">BUG REPORTS</A><DD>
14893 <DT><A HREF="#lbDI">BUGS</A><DD>
14894 </DL>
14895 <HR>
14896 This document was created by man2html from /usr/local/src/bash/bash-20220907/doc/bash.1.<BR>
14897 Time: 19 September 2022 12:02:51 EDT
14898 </BODY>
14899 </HTML>