]> git.ipfire.org Git - thirdparty/bash.git/blob - doc/bash.html
commit bash-20120204 snapshot
[thirdparty/bash.git] / doc / bash.html
1 <HTML><HEAD>
2 <TITLE>BASH(1) Manual Page</TITLE>
3 </HEAD>
4 <BODY><TABLE WIDTH=100%>
5 <TR>
6 <TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2012 January 29<TH ALIGN=RIGHT width=33%>BASH(1)
7 </TR>
8 </TABLE>
9 <BR><A HREF="#index">Index</A>
10 <HR>
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 <A NAME="lbAB">&nbsp;</A>
31 <H3>NAME</H3>
32
33 bash - GNU Bourne-Again SHell
34 <A NAME="lbAC">&nbsp;</A>
35 <H3>SYNOPSIS</H3>
36
37 <B>bash</B>
38
39 [options]
40 [command_string | file]
41 <A NAME="lbAD">&nbsp;</A>
42 <H3>COPYRIGHT</H3>
43
44
45 Bash is Copyright &#169; 1989-2012 by the Free Software Foundation, Inc.
46 <A NAME="lbAE">&nbsp;</A>
47 <H3>DESCRIPTION</H3>
48
49 <B>Bash</B>
50
51 is an <B>sh</B>-compatible command language interpreter that
52 executes commands read from the standard input or from a file.
53 <B>Bash</B>
54
55 also incorporates useful features from the <I>Korn</I> and <I>C</I>
56 shells (<B>ksh</B> and <B>csh</B>).
57 <P>
58
59 <B>Bash</B>
60
61 is intended to be a conformant implementation of the
62 Shell and Utilities portion of the IEEE POSIX specification
63 (IEEE Standard 1003.1).
64 <B>Bash</B>
65
66 can be configured to be POSIX-conformant by default.
67 <A NAME="lbAF">&nbsp;</A>
68 <H3>OPTIONS</H3>
69
70 All of the single-character shell options documented in the
71 description of the <B>set</B> builtin command can be used as options
72 when the shell is invoked.
73 In addition, <B>bash</B>
74 interprets the following options when it is invoked:
75 <P>
76
77
78 <DL COMPACT>
79 <DT><B>-c</B>
80
81 <DD>
82 If the
83 <B>-c</B>
84
85 option is present, then commands are read from the first non-option argument
86 <I>command_string</I>.
87
88 If there are arguments after the
89 <I>command_string</I>,
90
91 they are assigned to the positional parameters, starting with
92 <B>$0</B>.
93
94 <DT><B>-i</B>
95
96 <DD>
97 If the
98 <B>-i</B>
99
100 option is present, the shell is
101 <I>interactive</I>.
102
103 <DT><B>-l</B>
104
105 <DD>
106 Make
107 <B>bash</B>
108
109 act as if it had been invoked as a login shell (see
110 <FONT SIZE=-1><B>INVOCATION</B>
111
112 </FONT>
113 below).
114 <DT><B>-r</B>
115
116 <DD>
117 If the
118 <B>-r</B>
119
120 option is present, the shell becomes
121 <I>restricted</I>
122
123 (see
124 <FONT SIZE=-1><B>RESTRICTED SHELL</B>
125
126 </FONT>
127 below).
128 <DT><B>-s</B>
129
130 <DD>
131 If the
132 <B>-s</B>
133
134 option is present, or if no arguments remain after option
135 processing, then commands are read from the standard input.
136 This option allows the positional parameters to be set
137 when invoking an interactive shell.
138 <DT><B>-D</B>
139
140 <DD>
141 A list of all double-quoted strings preceded by <B>$</B>
142 is printed on the standard output.
143 These are the strings that
144 are subject to language translation when the current locale
145 is not <B>C</B> or <B>POSIX</B>.
146 This implies the <B>-n</B> option; no commands will be executed.
147 <DT><B>[-+]O [</B><I>shopt_option</I>]
148
149 <DD>
150 <I>shopt_option</I> is one of the shell options accepted by the
151 <B>shopt</B> builtin (see
152 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
153
154 </FONT>
155 below).
156 If <I>shopt_option</I> is present, <B>-O</B> sets the value of that option;
157 <B>+O</B> unsets it.
158 If <I>shopt_option</I> is not supplied, the names and values of the shell
159 options accepted by <B>shopt</B> are printed on the standard output.
160 If the invocation option is <B>+O</B>, the output is displayed in a format
161 that may be reused as input.
162 <DT><B>--</B>
163
164 <DD>
165 A
166 <B>--</B>
167
168 signals the end of options and disables further option processing.
169 Any arguments after the
170 <B>--</B>
171
172 are treated as filenames and arguments. An argument of
173 <B>-</B>
174
175 is equivalent to <B>--</B>.
176
177 </DL>
178 <P>
179
180 <B>Bash</B>
181
182 also interprets a number of multi-character options.
183 These options must appear on the command line before the
184 single-character options to be recognized.
185 <P>
186
187
188 <DL COMPACT>
189 <DT><B>--debugger</B>
190
191 <DD>
192 Arrange for the debugger profile to be executed before the shell
193 starts.
194 Turns on extended debugging mode (see the description of the
195 <B>extdebug</B>
196
197 option to the
198 <B>shopt</B>
199
200 builtin below).
201 <DT><B>--dump-po-strings</B>
202
203 <DD>
204 Equivalent to <B>-D</B>, but the output is in the GNU <I>gettext</I>
205 <B>po</B> (portable object) file format.
206 <DT><B>--dump-strings</B>
207
208 <DD>
209 Equivalent to <B>-D</B>.
210 <DT><B>--help</B>
211
212 <DD>
213 Display a usage message on standard output and exit successfully.
214 <DT><B>--init-file</B> <I>file</I><DD>
215
216 <DT><B>--rcfile</B> <I>file</I><DD>
217
218 Execute commands from
219 <I>file</I>
220
221 instead of the standard personal initialization file
222 <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
223
224 if the shell is interactive (see
225 <FONT SIZE=-1><B>INVOCATION</B>
226
227 </FONT>
228 below).
229 <DT><B>--login</B>
230
231 <DD>
232 Equivalent to <B>-l</B>.
233 <DT><B>--noediting</B>
234
235 <DD>
236 Do not use the GNU
237 <B>readline</B>
238
239 library to read command lines when the shell is interactive.
240 <DT><B>--noprofile</B>
241
242 <DD>
243 Do not read either the system-wide startup file
244
245 <A HREF="file:/etc/profile"><I>/etc/profile</I></A>
246
247 or any of the personal initialization files
248 <A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>,
249
250 <A HREF="file:~/.bash_login"><I>~/.bash_login</I></A>,
251
252 or
253 <A HREF="file:~/.profile"><I>~/.profile</I></A>.
254
255 By default,
256 <B>bash</B>
257
258 reads these files when it is invoked as a login shell (see
259 <FONT SIZE=-1><B>INVOCATION</B>
260
261 </FONT>
262 below).
263 <DT><B>--norc</B>
264
265 <DD>
266 Do not read and execute the personal initialization file
267 <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
268
269 if the shell is interactive.
270 This option is on by default if the shell is invoked as
271 <B>sh</B>.
272
273 <DT><B>--posix</B>
274
275 <DD>
276 Change the behavior of <B>bash</B> where the default operation differs
277 from the POSIX standard to match the standard (<I>posix mode</I>).
278 <DT><B>--restricted</B>
279
280 <DD>
281 The shell becomes restricted (see
282 <FONT SIZE=-1><B>RESTRICTED SHELL</B>
283
284 </FONT>
285 below).
286 <DT><B>--verbose</B>
287
288 <DD>
289 Equivalent to <B>-v</B>.
290 <DT><B>--version</B>
291
292 <DD>
293 Show version information for this instance of
294 <B>bash</B>
295
296 on the standard output and exit successfully.
297
298 </DL>
299 <A NAME="lbAG">&nbsp;</A>
300 <H3>ARGUMENTS</H3>
301
302 If arguments remain after option processing, and neither the
303 <B>-c</B>
304
305 nor the
306 <B>-s</B>
307
308 option has been supplied, the first argument is assumed to
309 be the name of a file containing shell commands.
310 If
311 <B>bash</B>
312
313 is invoked in this fashion,
314 <B>$0</B>
315
316 is set to the name of the file, and the positional parameters
317 are set to the remaining arguments.
318 <B>Bash</B>
319
320 reads and executes commands from this file, then exits.
321 <B>Bash</B>'s exit status is the exit status of the last command
322 executed in the script.
323 If no commands are executed, the exit status is 0.
324 An attempt is first made to open the file in the current directory, and,
325 if no file is found, then the shell searches the directories in
326 <FONT SIZE=-1><B>PATH</B>
327
328 </FONT>
329 for the script.
330 <A NAME="lbAH">&nbsp;</A>
331 <H3>INVOCATION</H3>
332
333 A <I>login shell</I> is one whose first character of argument zero is a
334 <B>-</B>,
335
336 or one started with the
337 <B>--login</B>
338
339 option.
340 <P>
341
342 An <I>interactive</I> shell is one started without non-option arguments
343 and without the
344 <B>-c</B>
345
346 option
347 whose standard input and error are
348 both connected to terminals (as determined by
349 <I>isatty</I>(3)),
350
351 or one started with the
352 <B>-i</B>
353
354 option.
355 <FONT SIZE=-1><B>PS1</B>
356
357 </FONT>
358 is set and
359 <B>$-</B>
360
361 includes
362 <B>i</B>
363
364 if
365 <B>bash</B>
366
367 is interactive,
368 allowing a shell script or a startup file to test this state.
369 <P>
370
371 The following paragraphs describe how
372 <B>bash</B>
373
374 executes its startup files.
375 If any of the files exist but cannot be read,
376 <B>bash</B>
377
378 reports an error.
379 Tildes are expanded in filenames as described below under
380 <B>Tilde Expansion</B>
381
382 in the
383 <FONT SIZE=-1><B>EXPANSION</B>
384
385 </FONT>
386 section.
387 <P>
388
389 When
390 <B>bash</B>
391
392 is invoked as an interactive login shell, or as a non-interactive shell
393 with the <B>--login</B> option, it first reads and
394 executes commands from the file <A HREF="file:/etc/profile"><I>/etc/profile</I></A>, if that
395 file exists.
396 After reading that file, it looks for <A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>,
397 <A HREF="file:~/.bash_login"><I>~/.bash_login</I></A>, and <A HREF="file:~/.profile"><I>~/.profile</I></A>, in that order, and reads
398 and executes commands from the first one that exists and is readable.
399 The
400 <B>--noprofile</B>
401
402 option may be used when the shell is started to inhibit this behavior.
403 <P>
404
405 When a login shell exits,
406 <B>bash</B>
407
408 reads and executes commands from the file <A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A>, if it
409 exists.
410 <P>
411
412 When an interactive shell that is not a login shell is started,
413 <B>bash</B>
414
415 reads and executes commands from <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>, if that file exists.
416 This may be inhibited by using the
417 <B>--norc</B>
418
419 option.
420 The <B>--rcfile</B> <I>file</I> option will force
421 <B>bash</B>
422
423 to read and execute commands from <I>file</I> instead of <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>.
424 <P>
425
426 When
427 <B>bash</B>
428
429 is started non-interactively, to run a shell script, for example, it
430 looks for the variable
431 <FONT SIZE=-1><B>BASH_ENV</B>
432
433 </FONT>
434 in the environment, expands its value if it appears there, and uses the
435 expanded value as the name of a file to read and execute.
436 <B>Bash</B>
437
438 behaves as if the following command were executed:
439 <P>
440 <DL COMPACT><DT><DD>
441 <TT>if [ -n &quot;$BASH_ENV&quot; ]; then . &quot;$BASH_ENV&quot;; fi</TT>
442
443 </DL>
444
445 <P>
446 but the value of the
447 <FONT SIZE=-1><B>PATH</B>
448
449 </FONT>
450 variable is not used to search for the filename.
451 <P>
452
453 If
454 <B>bash</B>
455
456 is invoked with the name
457 <B>sh</B>,
458
459 it tries to mimic the startup behavior of historical versions of
460 <B>sh</B>
461
462 as closely as possible,
463 while conforming to the POSIX standard as well.
464 When invoked as an interactive login shell, or a non-interactive
465 shell with the <B>--login</B> option, it first attempts to
466 read and execute commands from
467 <A HREF="file:/etc/profile"><I>/etc/profile</I></A>
468
469 and
470 <A HREF="file:~/.profile"><I>~/.profile</I></A>,
471
472 in that order.
473 The
474 <B>--noprofile</B>
475
476 option may be used to inhibit this behavior.
477 When invoked as an interactive shell with the name
478 <B>sh</B>,
479
480 <B>bash</B>
481
482 looks for the variable
483 <FONT SIZE=-1><B>ENV</B>,
484
485 </FONT>
486 expands its value if it is defined, and uses the
487 expanded value as the name of a file to read and execute.
488 Since a shell invoked as
489 <B>sh</B>
490
491 does not attempt to read and execute commands from any other startup
492 files, the
493 <B>--rcfile</B>
494
495 option has no effect.
496 A non-interactive shell invoked with the name
497 <B>sh</B>
498
499 does not attempt to read any other startup files.
500 When invoked as
501 <B>sh</B>,
502
503 <B>bash</B>
504
505 enters
506 <I>posix</I>
507
508 mode after the startup files are read.
509 <P>
510
511 When
512 <B>bash</B>
513
514 is started in
515 <I>posix</I>
516
517 mode, as with the
518 <B>--posix</B>
519
520 command line option, it follows the POSIX standard for startup files.
521 In this mode, interactive shells expand the
522 <FONT SIZE=-1><B>ENV</B>
523
524 </FONT>
525 variable and commands are read and executed from the file
526 whose name is the expanded value.
527 No other startup files are read.
528 <P>
529
530 <B>Bash</B>
531
532 attempts to determine when it is being run with its standard input
533 connected to a network connection, as when executed by the remote shell
534 daemon, usually <I>rshd</I>, or the secure shell daemon <I>sshd</I>.
535 If
536 <B>bash</B>
537
538 determines it is being run in this fashion, it reads and executes
539 commands from <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>, if that file exists and is readable.
540 It will not do this if invoked as <B>sh</B>.
541 The
542 <B>--norc</B>
543
544 option may be used to inhibit this behavior, and the
545 <B>--rcfile</B>
546
547 option may be used to force another file to be read, but
548 <I>rshd</I> does not generally invoke the shell with those options
549 or allow them to be specified.
550 <P>
551
552 If the shell is started with the effective user (group) id not equal to the
553 real user (group) id, and the <B>-p</B> option is not supplied, no startup
554 files are read, shell functions are not inherited from the environment, the
555 <FONT SIZE=-1><B>SHELLOPTS</B>,
556
557 </FONT>
558 <FONT SIZE=-1><B>BASHOPTS</B>,
559
560 </FONT>
561 <FONT SIZE=-1><B>CDPATH</B>,
562
563 </FONT>
564 and
565 <FONT SIZE=-1><B>GLOBIGNORE</B>
566
567 </FONT>
568 variables, if they appear in the environment, are ignored,
569 and the effective user id is set to the real user id.
570 If the <B>-p</B> option is supplied at invocation, the startup behavior is
571 the same, but the effective user id is not reset.
572 <A NAME="lbAI">&nbsp;</A>
573 <H3>DEFINITIONS</H3>
574
575 <P>
576
577 The following definitions are used throughout the rest of this
578 document.
579
580 <DL COMPACT>
581 <DT><B>blank </B>
582
583 <DD>
584 A space or tab.
585 <DT><B>word</B>
586
587 <DD>
588 A sequence of characters considered as a single unit by the shell.
589 Also known as a
590 <B>token</B>.
591
592 <DT><B>name</B>
593
594 <DD>
595 A
596 <I>word</I>
597
598 consisting only of alphanumeric characters and underscores, and
599 beginning with an alphabetic character or an underscore. Also
600 referred to as an
601 <B>identifier</B>.
602
603 <DT><B>metacharacter</B>
604
605 <DD>
606 A character that, when unquoted, separates words. One of the following:
607 <BR>
608
609 <DL COMPACT><DT><DD>
610 <P>
611
612 <B>| &amp; ; ( ) &lt; &gt; space tab</B>
613
614 </DL>
615
616 </DL>
617 <P>
618
619 <DL COMPACT>
620 <DT><B>control operator</B>
621
622 <DD>
623 A <I>token</I> that performs a control function. It is one of the following
624 symbols:
625 <DL COMPACT><DT><DD>
626 <P>
627
628 <B>|| &amp; &amp;&amp; ; ;; ( ) | |&amp; &lt;newline&gt;</B>
629
630 </DL>
631
632
633 </DL>
634 <A NAME="lbAJ">&nbsp;</A>
635 <H3>RESERVED WORDS</H3>
636
637 <I>Reserved words</I> are words that have a special meaning to the shell.
638 The following words are recognized as reserved when unquoted and either
639 the first word of a simple command (see
640 <FONT SIZE=-1><B>SHELL GRAMMAR</B>
641
642 </FONT>
643 below) or the third word of a
644 <B>case </B>
645
646 or
647 <B>for</B>
648
649 command:
650 <DL COMPACT><DT><DD>
651
652 <P>
653
654 <B>
655 </B>
656
657 ! case do done elif else esac fi for function if in select then until while { } time [[ ]]
658 </DL>
659
660
661 <A NAME="lbAK">&nbsp;</A>
662 <H3>SHELL GRAMMAR</H3>
663
664 <A NAME="lbAL">&nbsp;</A>
665 <H4>Simple Commands</H4>
666
667 <P>
668
669 A <I>simple command</I> is a sequence of optional variable assignments
670 followed by <B>blank</B>-separated words and redirections, and
671 terminated by a <I>control operator</I>. The first word
672 specifies the command to be executed, and is passed as argument zero.
673 The remaining words are passed as arguments to the invoked command.
674 <P>
675
676 The return value of a <I>simple command</I> is its exit status, or
677 128+<I>n</I> if the command is terminated by signal
678 <I>n</I>.
679
680 <A NAME="lbAM">&nbsp;</A>
681 <H4>Pipelines</H4>
682
683 <P>
684
685 A <I>pipeline</I> is a sequence of one or more commands separated by
686 one of the control operators
687 <B>|</B>
688
689 or <B>|&amp;</B>.
690 The format for a pipeline is:
691 <DL COMPACT><DT><DD>
692 <P>
693
694 [<B>time</B> [<B>-p</B>]] [ ! ] <I>command</I> [ [<B>|</B>|<B>|&amp;</B>] <I>command2</I> ... ]
695 </DL>
696
697 <P>
698
699 The standard output of
700 <I>command</I>
701
702 is connected via a pipe to the standard input of
703 <I>command2</I>.
704
705 This connection is performed before any redirections specified by the
706 command (see
707 <FONT SIZE=-1><B>REDIRECTION</B>
708
709 </FONT>
710 below).
711 If <B>|&amp;</B> is used, <I>command</I>'s standard output and standard error
712 are connected to
713 <I>command2</I>'s standard input through the pipe;
714 it is shorthand for <B>2&gt;&amp;1 |</B>.
715 This implicit redirection of the standard error is
716 performed after any redirections specified by the command.
717 <P>
718
719 The return status of a pipeline is the exit status of the last
720 command, unless the <B>pipefail</B> option is enabled.
721 If <B>pipefail</B> is enabled, the pipeline's return status is the
722 value of the last (rightmost) command to exit with a non-zero status,
723 or zero if all commands exit successfully.
724 If the reserved word
725 <B>!</B>
726
727 precedes a pipeline, the exit status of that pipeline is the logical
728 negation of the exit status as described above.
729 The shell waits for all commands in the pipeline to
730 terminate before returning a value.
731 <P>
732
733 If the
734 <B>time</B>
735
736 reserved word precedes a pipeline, the elapsed as well as user and
737 system time consumed by its execution are reported when the pipeline
738 terminates.
739 The <B>-p</B> option changes the output format to that specified by POSIX.
740 When the shell is in <I>posix mode</I>, it does not recognize
741 <B>time</B> as a reserved word if the next token begins with a `-'.
742 The
743 <FONT SIZE=-1><B>TIMEFORMAT</B>
744
745 </FONT>
746 variable may be set to a format string that specifies how the timing
747 information should be displayed; see the description of
748 <FONT SIZE=-1><B>TIMEFORMAT</B>
749
750 </FONT>
751 under
752 <B>Shell Variables</B>
753
754 below.
755 <P>
756
757 When the shell is in <I>posix mode</I>, <B>time</B>
758 may be followed by a newline. In this case, the shell displays the
759 total user and system time consumed by the shell and its children.
760 The
761 <FONT SIZE=-1><B>TIMEFORMAT</B>
762
763 </FONT>
764 variable may be used to specify the format of
765 the time information.
766 <P>
767
768 Each command in a pipeline is executed as a separate process (i.e., in a
769 subshell).
770 <A NAME="lbAN">&nbsp;</A>
771 <H4>Lists</H4>
772
773 <P>
774
775 A <I>list</I> is a sequence of one or more pipelines separated by one
776 of the operators
777 <B>;</B>,
778
779 <B>&amp;</B>,
780
781 <B>&amp;&amp;</B>,
782
783 or
784 <B>||</B>,
785
786 and optionally terminated by one of
787 <B>;</B>,
788
789 <B>&amp;</B>,
790
791 or
792 <B>&lt;newline&gt;</B>.
793
794 <P>
795
796 Of these list operators,
797 <B>&amp;&amp;</B>
798
799 and
800 <B>||</B>
801
802 have equal precedence, followed by
803 <B>;</B>
804
805 and
806 <B>&amp;</B>,
807
808 which have equal precedence.
809 <P>
810
811 A sequence of one or more newlines may appear in a <I>list</I> instead
812 of a semicolon to delimit commands.
813 <P>
814
815 If a command is terminated by the control operator
816 <B>&amp;</B>,
817
818 the shell executes the command in the <I>background</I>
819 in a subshell. The shell does not wait for the command to
820 finish, and the return status is 0. Commands separated by a
821 <B>;</B>
822
823 are executed sequentially; the shell waits for each
824 command to terminate in turn. The return status is the
825 exit status of the last command executed.
826 <P>
827
828 AND and OR lists are sequences of one of more pipelines separated by the
829 <B>&amp;&amp;</B> and <B>||</B> control operators, respectively.
830 AND and OR lists are executed with left associativity.
831 An AND list has the form
832 <DL COMPACT><DT><DD>
833 <P>
834
835 <I>command1</I> <B>&amp;&amp;</B> <I>command2</I>
836 </DL>
837
838 <P>
839
840 <I>command2</I>
841
842 is executed if, and only if,
843 <I>command1</I>
844
845 returns an exit status of zero.
846 <P>
847
848 An OR list has the form
849 <DL COMPACT><DT><DD>
850 <P>
851
852 <I>command1</I> <B>||</B> <I>command2</I>
853 <P>
854
855 </DL>
856
857 <P>
858
859 <I>command2</I>
860
861 is executed if and only if
862 <I>command1</I>
863
864 returns a non-zero exit status.
865 The return status of
866 AND and OR lists is the exit status of the last command
867 executed in the list.
868 <A NAME="lbAO">&nbsp;</A>
869 <H4>Compound Commands</H4>
870
871 <P>
872
873 A <I>compound command</I> is one of the following.
874 In most cases a <I>list</I> in a command's description may be separated from
875 the rest of the command by one or more newlines, and may be followed by a
876 newline in place of a semicolon.
877 <DL COMPACT>
878 <DT>(<I>list</I>)<DD>
879 <I>list</I> is executed in a subshell environment (see
880 <FONT SIZE=-1><B>COMMAND EXECUTION ENVIRONMENT</B></FONT>
881 below).
882 Variable assignments and builtin
883 commands that affect the shell's environment do not remain in effect
884 after the command completes. The return status is the exit status of
885 <I>list</I>.
886 <DT>{ <I>list</I>; }<DD>
887 <I>list</I> is simply executed in the current shell environment.
888 <I>list</I> must be terminated with a newline or semicolon.
889 This is known as a <I>group command</I>.
890 The return status is the exit status of
891 <I>list</I>.
892 Note that unlike the metacharacters <B>(</B> and <B>)</B>, <B>{</B> and
893 <B>}</B> are <I>reserved words</I> and must occur where a reserved
894 word is permitted to be recognized. Since they do not cause a word
895 break, they must be separated from <I>list</I> by whitespace or another
896 shell metacharacter.
897 <DT>((<I>expression</I>))<DD>
898 The <I>expression</I> is evaluated according to the rules described
899 below under
900 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
901
902 </FONT>
903 If the value of the expression is non-zero, the return status is 0;
904 otherwise the return status is 1. This is exactly equivalent to
905 <B>let &quot;</B><I>expression</I>&quot;.
906 <DT><B>[[</B> <I>expression</I> <B>]]</B><DD>
907 Return a status of 0 or 1 depending on the evaluation of
908 the conditional expression <I>expression</I>.
909 Expressions are composed of the primaries described below under
910 <FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>.
911
912 </FONT>
913 Word splitting and pathname expansion are not performed on the words
914 between the <B>[[</B> and <B>]]</B>; tilde expansion,
915 parameter and variable expansion,
916 arithmetic expansion, command substitution, process
917 substitution, and quote removal are performed.
918 Conditional operators such as <B>-f</B> must be unquoted to be recognized
919 as primaries.
920 <P>
921
922
923 When used with <B>[[</B>, the <B>&lt;</B> and <B>&gt;</B> operators sort
924 lexicographically using the current locale.
925 <P>
926
927
928 When the <B>==</B> and <B>!=</B> operators are used, the string to the
929 right of the operator is considered a pattern and matched according
930 to the rules described below under <B>Pattern Matching</B>.
931 If the shell option
932 <B>nocasematch</B>
933
934 is enabled, the match is performed without regard to the case
935 of alphabetic characters.
936 The return value is 0 if the string matches (<B>==</B>) or does not match
937 (<B>!=</B>) the pattern, and 1 otherwise.
938 Any part of the pattern may be quoted to force the quoted portion
939 to be matched as a string.
940 <P>
941
942
943 An additional binary operator, <B>=~</B>, is available, with the same
944 precedence as <B>==</B> and <B>!=</B>.
945 When it is used, the string to the right of the operator is considered
946 an extended regular expression and matched accordingly (as in <I>regex</I>(3)).
947 The return value is 0 if the string matches
948 the pattern, and 1 otherwise.
949 If the regular expression is syntactically incorrect, the conditional
950 expression's return value is 2.
951 If the shell option
952 <B>nocasematch</B>
953
954 is enabled, the match is performed without regard to the case
955 of alphabetic characters.
956 Any part of the pattern may be quoted to force the quoted portion
957 to be matched as a string.
958 Bracket expressions in regular expressions must be treated carefully,
959 since normal quoting characters lose their meanings between brackets.
960 If the pattern is stored in a shell variable, quoting the variable
961 expansion forces the entire pattern to be matched as a string.
962 Substrings matched by parenthesized subexpressions within the regular
963 expression are saved in the array variable
964 <FONT SIZE=-1><B>BASH_REMATCH</B>.
965
966 </FONT>
967 The element of
968 <FONT SIZE=-1><B>BASH_REMATCH</B>
969
970 </FONT>
971 with index 0 is the portion of the string
972 matching the entire regular expression.
973 The element of
974 <FONT SIZE=-1><B>BASH_REMATCH</B>
975
976 </FONT>
977 with index <I>n</I> is the portion of the
978 string matching the <I>n</I>th parenthesized subexpression.
979 <P>
980
981
982 Expressions may be combined using the following operators, listed
983 in decreasing order of precedence:
984 <P>
985
986
987 <DL COMPACT><DT><DD>
988
989 <DL COMPACT>
990 <DT><B>( </B><I>expression</I> )
991
992 <DD>
993 Returns the value of <I>expression</I>.
994 This may be used to override the normal precedence of operators.
995 <DT><B>! </B><I>expression</I>
996
997 <DD>
998 True if
999 <I>expression</I>
1000
1001 is false.
1002 <DT><I>expression1</I> <B>&amp;&amp;</B> <I>expression2</I><DD>
1003 True if both
1004 <I>expression1</I>
1005
1006 and
1007 <I>expression2</I>
1008
1009 are true.
1010 <DT><I>expression1</I> <B>||</B> <I>expression2</I><DD>
1011 True if either
1012 <I>expression1</I>
1013
1014 or
1015 <I>expression2</I>
1016
1017 is true.
1018
1019 </DL>
1020 <P>
1021
1022 The <B>&amp;&amp;</B> and <B>||</B>
1023 operators do not evaluate <I>expression2</I> if the value of
1024 <I>expression1</I> is sufficient to determine the return value of
1025 the entire conditional expression.
1026 </DL>
1027
1028 <DT><B>for</B> <I>name</I> [ [ <B>in</B> [ <I>word ...</I> ] ] ; ] <B>do</B> <I>list</I> ; <B>done</B><DD>
1029 The list of words following <B>in</B> is expanded, generating a list
1030 of items.
1031 The variable <I>name</I> is set to each element of this list
1032 in turn, and <I>list</I> is executed each time.
1033 If the <B>in</B> <I>word</I> is omitted, the <B>for</B> command executes
1034 <I>list</I> once for each positional parameter that is set (see
1035 <FONT SIZE=-1><B>PARAMETERS</B>
1036
1037 </FONT>
1038 below).
1039 The return status is the exit status of the last command that executes.
1040 If the expansion of the items following <B>in</B> results in an empty
1041 list, no commands are executed, and the return status is 0.
1042 <DT><B>for</B> (( <I>expr1</I> ; <I>expr2</I> ; <I>expr3</I> )) ; <B>do</B> <I>list</I> ; <B>done</B><DD>
1043 First, the arithmetic expression <I>expr1</I> is evaluated according
1044 to the rules described below under
1045 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
1046
1047 </FONT>
1048 The arithmetic expression <I>expr2</I> is then evaluated repeatedly
1049 until it evaluates to zero.
1050 Each time <I>expr2</I> evaluates to a non-zero value, <I>list</I> is
1051 executed and the arithmetic expression <I>expr3</I> is evaluated.
1052 If any expression is omitted, it behaves as if it evaluates to 1.
1053 The return value is the exit status of the last command in <I>list</I>
1054 that is executed, or false if any of the expressions is invalid.
1055 <DT><B>select</B> <I>name</I> [ <B>in</B> <I>word</I> ] ; <B>do</B> <I>list</I> ; <B>done</B><DD>
1056 The list of words following <B>in</B> is expanded, generating a list
1057 of items. The set of expanded words is printed on the standard
1058 error, each preceded by a number. If the <B>in</B>
1059 <I>word</I> is omitted, the positional parameters are printed (see
1060 <FONT SIZE=-1><B>PARAMETERS</B>
1061
1062 </FONT>
1063 below). The
1064 <FONT SIZE=-1><B>PS3</B>
1065
1066 </FONT>
1067 prompt is then displayed and a line read from the standard input.
1068 If the line consists of a number corresponding to one of
1069 the displayed words, then the value of
1070 <I>name</I>
1071
1072 is set to that word. If the line is empty, the words and prompt
1073 are displayed again. If EOF is read, the command completes. Any
1074 other value read causes
1075 <I>name</I>
1076
1077 to be set to null. The line read is saved in the variable
1078 <FONT SIZE=-1><B>REPLY</B>.
1079
1080 </FONT>
1081 The
1082 <I>list</I>
1083
1084 is executed after each selection until a
1085 <B>break</B>
1086
1087 command is executed.
1088 The exit status of
1089 <B>select</B>
1090
1091 is the exit status of the last command executed in
1092 <I>list</I>,
1093
1094 or zero if no commands were executed.
1095 <DT><B>case</B> <I>word</I> <B>in</B> [ [(] <I>pattern</I> [ <B>|</B> <I>pattern</I> ]
1096 <DD>
1097 A <B>case</B> command first expands <I>word</I>, and tries to match
1098 it against each <I>pattern</I> in turn, using the same matching rules
1099 as for pathname expansion (see
1100 <B>Pathname Expansion</B>
1101
1102 below).
1103 The <I>word</I> is expanded using tilde
1104 expansion, parameter and variable expansion, arithmetic substitution,
1105 command substitution, process substitution and quote removal.
1106 Each <I>pattern</I> examined is expanded using tilde
1107 expansion, parameter and variable expansion, arithmetic substitution,
1108 command substitution, and process substitution.
1109 If the shell option
1110 <B>nocasematch</B>
1111
1112 is enabled, the match is performed without regard to the case
1113 of alphabetic characters.
1114 When a match is found, the corresponding <I>list</I> is executed.
1115 If the <B>;;</B> operator is used, no subsequent matches are attempted after
1116 the first pattern match.
1117 Using <B>;&amp;</B> in place of <B>;;</B> causes execution to continue with
1118 the <I>list</I> associated with the next set of patterns.
1119 Using <B>;;&amp;</B> in place of <B>;;</B> causes the shell to test the next
1120 pattern list in the statement, if any, and execute any associated <I>list</I>
1121 on a successful match.
1122 The exit status is zero if no
1123 pattern matches. Otherwise, it is the exit status of the
1124 last command executed in <I>list</I>.
1125 <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>
1126 The
1127 <B>if </B>
1128
1129 <I>list</I>
1130
1131 is executed. If its exit status is zero, the
1132 <B>then</B> <I>list</I> is executed. Otherwise, each <B>elif</B>
1133 <I>list</I> is executed in turn, and if its exit status is zero,
1134 the corresponding <B>then</B> <I>list</I> is executed and the
1135 command completes. Otherwise, the <B>else</B> <I>list</I> is
1136 executed, if present. The exit status is the exit status of the
1137 last command executed, or zero if no condition tested true.
1138 <DT><B>while</B> <I>list-1</I>; <B>do</B> <I>list-2</I>; <B>done</B><DD>
1139
1140 <DT><B>until</B> <I>list-1</I>; <B>do</B> <I>list-2</I>; <B>done</B><DD>
1141
1142 The <B>while</B> command continuously executes the list
1143 <I>list-2</I> as long as the last command in the list <I>list-1</I> returns
1144 an exit status of zero. The <B>until</B> command is identical
1145 to the <B>while</B> command, except that the test is negated;
1146 <I>list-2</I>
1147
1148 is executed as long as the last command in
1149 <I>list-1</I>
1150
1151 returns a non-zero exit status.
1152 The exit status of the <B>while</B> and <B>until</B> commands
1153 is the exit status
1154 of the last command executed in <I>list-2</I>, or zero if
1155 none was executed.
1156 </DL>
1157 <A NAME="lbAP">&nbsp;</A>
1158 <H4>Coprocesses</H4>
1159
1160 <P>
1161
1162 A <I>coprocess</I> is a shell command preceded by the <B>coproc</B> reserved
1163 word.
1164 A coprocess is executed asynchronously in a subshell, as if the command
1165 had been terminated with the <B>&amp;</B> control operator, with a two-way pipe
1166 established between the executing shell and the coprocess.
1167 <P>
1168
1169 The format for a coprocess is:
1170 <DL COMPACT><DT><DD>
1171 <P>
1172
1173 <B>coproc</B> [<I>NAME</I>] <I>command</I> [<I>redirections</I>]
1174 </DL>
1175
1176 <P>
1177
1178 This creates a coprocess named <I>NAME</I>.
1179 If <I>NAME</I> is not supplied, the default name is <B>COPROC</B>.
1180 <I>NAME</I> must not be supplied if <I>command</I> is a <I>simple
1181 command</I> (see above); otherwise, it is interpreted as the first word
1182 of the simple command.
1183 When the coprocess is executed, the shell creates an array variable (see
1184 <B>Arrays</B>
1185
1186 below) named <I>NAME</I> in the context of the executing shell.
1187 The standard output of
1188 <I>command</I>
1189
1190 is connected via a pipe to a file descriptor in the executing shell,
1191 and that file descriptor is assigned to <I>NAME</I>[0].
1192 The standard input of
1193 <I>command</I>
1194
1195 is connected via a pipe to a file descriptor in the executing shell,
1196 and that file descriptor is assigned to <I>NAME</I>[1].
1197 This pipe is established before any redirections specified by the
1198 command (see
1199 <FONT SIZE=-1><B>REDIRECTION</B>
1200
1201 </FONT>
1202 below).
1203 The file descriptors can be utilized as arguments to shell commands
1204 and redirections using standard word expansions.
1205 The process ID of the shell spawned to execute the coprocess is
1206 available as the value of the variable <I>NAME</I>_PID.
1207 The <B>wait</B>
1208 builtin command may be used to wait for the coprocess to terminate.
1209 <P>
1210
1211 The return status of a coprocess is the exit status of <I>command</I>.
1212 <A NAME="lbAQ">&nbsp;</A>
1213 <H4>Shell Function Definitions</H4>
1214
1215 <P>
1216
1217 A shell function is an object that is called like a simple command and
1218 executes a compound command with a new set of positional parameters.
1219 Shell functions are declared as follows:
1220 <DL COMPACT>
1221 <DT><I>name</I> () <I>compound-command</I> [<I>redirection</I>]<DD>
1222
1223 <DT><B>function</B> <I>name</I> [()] <I>compound-command</I> [<I>redirection</I>]<DD>
1224
1225 This defines a function named <I>name</I>.
1226 The reserved word <B>function</B> is optional.
1227 If the <B>function</B> reserved word is supplied, the parentheses are optional.
1228 The <I>body</I> of the function is the compound command
1229 <I>compound-command </I>
1230
1231 (see <B>Compound Commands</B> above).
1232 That command is usually a <I>list</I> of commands between { and }, but
1233 may be any command listed under <B>Compound Commands</B> above.
1234 <I>compound-command</I> is executed whenever <I>name</I> is specified as the
1235 name of a simple command.
1236 When in <I>posix mode</I>, <I>name</I> may not be the name of one of the
1237 POSIX <I>special builtins</I>.
1238 Any redirections (see
1239 <FONT SIZE=-1><B>REDIRECTION</B>
1240
1241 </FONT>
1242 below) specified when a function is defined are performed
1243 when the function is executed.
1244 The exit status of a function definition is zero unless a syntax error
1245 occurs or a readonly function with the same name already exists.
1246 When executed, the exit status of a function is the exit status of the
1247 last command executed in the body. (See
1248 <FONT SIZE=-1><B>FUNCTIONS</B>
1249
1250 </FONT>
1251 below.)
1252 </DL>
1253 <A NAME="lbAR">&nbsp;</A>
1254 <H3>COMMENTS</H3>
1255
1256 In a non-interactive shell, or an interactive shell in which the
1257 <B>interactive_comments</B>
1258
1259 option to the
1260 <B>shopt</B>
1261
1262 builtin is enabled (see
1263 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
1264
1265 </FONT>
1266 below), a word beginning with
1267 <B>#</B>
1268
1269 causes that word and all remaining characters on that line to
1270 be ignored. An interactive shell without the
1271 <B>interactive_comments</B>
1272
1273 option enabled does not allow comments. The
1274 <B>interactive_comments</B>
1275
1276 option is on by default in interactive shells.
1277 <A NAME="lbAS">&nbsp;</A>
1278 <H3>QUOTING</H3>
1279
1280 <I>Quoting</I> is used to remove the special meaning of certain
1281 characters or words to the shell. Quoting can be used to
1282 disable special treatment for special characters, to prevent
1283 reserved words from being recognized as such, and to prevent
1284 parameter expansion.
1285 <P>
1286
1287 Each of the <I>metacharacters</I> listed above under
1288 <FONT SIZE=-1><B>DEFINITIONS</B>
1289
1290 </FONT>
1291 has special meaning to the shell and must be quoted if it is to
1292 represent itself.
1293 <P>
1294
1295 When the command history expansion facilities are being used
1296 (see
1297 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
1298
1299 </FONT>
1300 below), the
1301 <I>history expansion</I> character, usually <B>!</B>, must be quoted
1302 to prevent history expansion.
1303 <P>
1304
1305 There are three quoting mechanisms: the
1306 <I>escape character</I>,
1307
1308 single quotes, and double quotes.
1309 <P>
1310
1311 A non-quoted backslash (<B>\</B>) is the
1312 <I>escape character</I>.
1313
1314 It preserves the literal value of the next character that follows,
1315 with the exception of &lt;newline&gt;. If a <B>\</B>&lt;newline&gt; pair
1316 appears, and the backslash is not itself quoted, the <B>\</B>&lt;newline&gt;
1317 is treated as a line continuation (that is, it is removed from the
1318 input stream and effectively ignored).
1319 <P>
1320
1321 Enclosing characters in single quotes preserves the literal value
1322 of each character within the quotes. A single quote may not occur
1323 between single quotes, even when preceded by a backslash.
1324 <P>
1325
1326 Enclosing characters in double quotes preserves the literal value
1327 of all characters within the quotes, with the exception of
1328 <B>$</B>,
1329
1330 <B>`</B>,
1331
1332 <B>\</B>,
1333
1334 and, when history expansion is enabled,
1335 <B>!</B>.
1336
1337 The characters
1338 <B>$</B>
1339
1340 and
1341 <B>`</B>
1342
1343 retain their special meaning within double quotes. The backslash
1344 retains its special meaning only when followed by one of the following
1345 characters:
1346 <B>$</B>,
1347
1348 <B>`</B>,
1349
1350 <B>&quot;</B>,
1351 <B>\</B>,
1352
1353 or
1354 <B>&lt;newline&gt;</B>.
1355
1356 A double quote may be quoted within double quotes by preceding it with
1357 a backslash.
1358 If enabled, history expansion will be performed unless an
1359 <B>!</B>
1360
1361 appearing in double quotes is escaped using a backslash.
1362 The backslash preceding the
1363 <B>!</B>
1364
1365 is not removed.
1366 <P>
1367
1368 The special parameters
1369 <B>*</B>
1370
1371 and
1372 <B>@</B>
1373
1374 have special meaning when in double
1375 quotes (see
1376 <FONT SIZE=-1><B>PARAMETERS</B>
1377
1378 </FONT>
1379 below).
1380 <P>
1381
1382 Words of the form <B>$</B>aq<I>string</I>aq are treated specially. The
1383 word expands to <I>string</I>, with backslash-escaped characters replaced
1384 as specified by the ANSI C standard. Backslash escape sequences, if
1385 present, are decoded as follows:
1386 <DL COMPACT><DT><DD>
1387
1388 <DL COMPACT>
1389 <DT><B>\a</B>
1390
1391 <DD>
1392 alert (bell)
1393 <DT><B>\b</B>
1394
1395 <DD>
1396 backspace
1397 <DT><B>\e</B>
1398
1399 <DD>
1400 <DT><B>\E</B>
1401
1402 <DD>
1403 an escape character
1404 <DT><B>\f</B>
1405
1406 <DD>
1407 form feed
1408 <DT><B>\n</B>
1409
1410 <DD>
1411 new line
1412 <DT><B>\r</B>
1413
1414 <DD>
1415 carriage return
1416 <DT><B>\t</B>
1417
1418 <DD>
1419 horizontal tab
1420 <DT><B>\v</B>
1421
1422 <DD>
1423 vertical tab
1424 <DT><B>\\</B>
1425
1426 <DD>
1427 backslash
1428 <DT><B>\aq</B>
1429
1430 <DD>
1431 single quote
1432 <DT><B>\dq</B>
1433
1434 <DD>
1435 double quote
1436 <DT><B>\</B><I>nnn</I>
1437
1438 <DD>
1439 the eight-bit character whose value is the octal value <I>nnn</I>
1440 (one to three digits)
1441 <DT><B>\x</B><I>HH</I>
1442
1443 <DD>
1444 the eight-bit character whose value is the hexadecimal value <I>HH</I>
1445 (one or two hex digits)
1446 <DT><B>\u</B><I>HHHH</I>
1447
1448 <DD>
1449 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
1450 <I>HHHH</I> (one to four hex digits)
1451 <DT><B>\U</B><I>HHHHHHHH</I>
1452
1453 <DD>
1454 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
1455 <I>HHHHHHHH</I> (one to eight hex digits)
1456 <DT><B>\c</B><I>x</I>
1457
1458 <DD>
1459 a control-<I>x</I> character
1460
1461 </DL></DL>
1462
1463 <P>
1464
1465 The expanded result is single-quoted, as if the dollar sign had
1466 not been present.
1467 <P>
1468
1469 A double-quoted string preceded by a dollar sign (<B>$</B>dq<I>string</I>dq)
1470 will cause the string to be translated according to the current locale.
1471 If the current locale is <B>C</B> or <B>POSIX</B>, the dollar sign
1472 is ignored.
1473 If the string is translated and replaced, the replacement is
1474 double-quoted.
1475 <A NAME="lbAT">&nbsp;</A>
1476 <H3>PARAMETERS</H3>
1477
1478 A
1479 <I>parameter</I>
1480
1481 is an entity that stores values.
1482 It can be a
1483 <I>name</I>,
1484
1485 a number, or one of the special characters listed below under
1486 <B>Special Parameters</B>.
1487
1488 A
1489 <I>variable</I>
1490
1491 is a parameter denoted by a
1492 <I>name</I>.
1493
1494 A variable has a <I>value</I> and zero or more <I>attributes</I>.
1495 Attributes are assigned using the
1496 <B>declare</B>
1497
1498 builtin command (see
1499 <B>declare</B>
1500
1501 below in
1502 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>).
1503
1504 </FONT>
1505 <P>
1506
1507 A parameter is set if it has been assigned a value. The null string is
1508 a valid value. Once a variable is set, it may be unset only by using
1509 the
1510 <B>unset</B>
1511
1512 builtin command (see
1513 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
1514
1515 </FONT>
1516 below).
1517 <P>
1518
1519 A
1520 <I>variable</I>
1521
1522 may be assigned to by a statement of the form
1523 <DL COMPACT><DT><DD>
1524 <P>
1525
1526 <I>name</I>=[<I>value</I>]
1527 </DL>
1528
1529 <P>
1530
1531 If
1532 <I>value</I>
1533
1534 is not given, the variable is assigned the null string. All
1535 <I>values</I>
1536
1537 undergo tilde expansion, parameter and variable expansion,
1538 command substitution, arithmetic expansion, and quote
1539 removal (see
1540 <FONT SIZE=-1><B>EXPANSION</B>
1541
1542 </FONT>
1543 below). If the variable has its
1544 <B>integer</B>
1545
1546 attribute set, then
1547 <I>value</I>
1548
1549 is evaluated as an arithmetic expression even if the $((...)) expansion is
1550 not used (see
1551 <B>Arithmetic Expansion</B>
1552
1553 below).
1554 Word splitting is not performed, with the exception
1555 of <B>&quot;$@&quot;</B> as explained below under
1556 <B>Special Parameters</B>.
1557
1558 Pathname expansion is not performed.
1559 Assignment statements may also appear as arguments to the
1560 <B>alias</B>,
1561
1562 <B>declare</B>,
1563
1564 <B>typeset</B>,
1565
1566 <B>export</B>,
1567
1568 <B>readonly</B>,
1569
1570 and
1571 <B>local</B>
1572
1573 builtin commands.
1574 When in <I>posix mode</I>, these builtins may appear in a command after
1575 one or more instances of the <B>command</B> builtin and retain these
1576 assignment statement properties.
1577 <P>
1578
1579 In the context where an assignment statement is assigning a value
1580 to a shell variable or array index, the += operator can be used to
1581 append to or add to the variable's previous value.
1582 When += is applied to a variable for which the <I>integer</I> attribute has been
1583 set, <I>value</I> is evaluated as an arithmetic expression and added to the
1584 variable's current value, which is also evaluated.
1585 When += is applied to an array variable using compound assignment (see
1586 <B>Arrays</B>
1587
1588 below), the
1589 variable's value is not unset (as it is when using =), and new values are
1590 appended to the array beginning at one greater than the array's maximum index
1591 (for indexed arrays) or added as additional key-value pairs in an
1592 associative array.
1593 When applied to a string-valued variable, <I>value</I> is expanded and
1594 appended to the variable's value.
1595 <A NAME="lbAU">&nbsp;</A>
1596 <H4>Positional Parameters</H4>
1597
1598 <P>
1599
1600 A
1601 <I>positional parameter</I>
1602
1603 is a parameter denoted by one or more
1604 digits, other than the single digit 0. Positional parameters are
1605 assigned from the shell's arguments when it is invoked,
1606 and may be reassigned using the
1607 <B>set</B>
1608
1609 builtin command. Positional parameters may not be assigned to
1610 with assignment statements. The positional parameters are
1611 temporarily replaced when a shell function is executed (see
1612 <FONT SIZE=-1><B>FUNCTIONS</B>
1613
1614 </FONT>
1615 below).
1616 <P>
1617
1618 When a positional parameter consisting of more than a single
1619 digit is expanded, it must be enclosed in braces (see
1620 <FONT SIZE=-1><B>EXPANSION</B>
1621
1622 </FONT>
1623 below).
1624 <A NAME="lbAV">&nbsp;</A>
1625 <H4>Special Parameters</H4>
1626
1627 <P>
1628
1629 The shell treats several parameters specially. These parameters may
1630 only be referenced; assignment to them is not allowed.
1631
1632 <DL COMPACT>
1633 <DT><B>*</B>
1634
1635 <DD>
1636 Expands to the positional parameters, starting from one. When the
1637 expansion occurs within double quotes, it expands to a single word
1638 with the value of each parameter separated by the first character
1639 of the
1640 <FONT SIZE=-1><B>IFS</B>
1641
1642 </FONT>
1643 special variable. That is, &quot;<B>$*</B>&quot; is equivalent
1644 to &quot;<B>$1</B><I>c</I><B>$2</B><I>c</I><B>...</B>&quot;, where
1645 <I>c</I>
1646
1647 is the first character of the value of the
1648 <FONT SIZE=-1><B>IFS</B>
1649
1650 </FONT>
1651 variable. If
1652 <FONT SIZE=-1><B>IFS</B>
1653
1654 </FONT>
1655 is unset, the parameters are separated by spaces.
1656 If
1657 <FONT SIZE=-1><B>IFS</B>
1658
1659 </FONT>
1660 is null, the parameters are joined without intervening separators.
1661 <DT><B>@</B>
1662
1663 <DD>
1664 Expands to the positional parameters, starting from one. When the
1665 expansion occurs within double quotes, each parameter expands to a
1666 separate word. That is, &quot;<B>$@</B>&quot; is equivalent to
1667 &quot;<B>$1</B>&quot; &quot;<B>$2</B>&quot; ...
1668 If the double-quoted expansion occurs within a word, the expansion of
1669 the first parameter is joined with the beginning part of the original
1670 word, and the expansion of the last parameter is joined with the last
1671 part of the original word.
1672 When there are no positional parameters, &quot;<B>$@</B>&quot; and
1673 <B>$@</B>
1674
1675 expand to nothing (i.e., they are removed).
1676 <DT><B>#</B>
1677
1678 <DD>
1679 Expands to the number of positional parameters in decimal.
1680 <DT><B>?</B>
1681
1682 <DD>
1683 Expands to the exit status of the most recently executed foreground
1684 pipeline.
1685 <DT><B>-</B>
1686
1687 <DD>
1688 Expands to the current option flags as specified upon invocation,
1689 by the
1690 <B>set</B>
1691
1692 builtin command, or those set by the shell itself
1693 (such as the
1694 <B>-i</B>
1695
1696 option).
1697 <DT><B>$</B>
1698
1699 <DD>
1700 Expands to the process ID of the shell. In a () subshell, it
1701 expands to the process ID of the current shell, not the
1702 subshell.
1703 <DT><B>!</B>
1704
1705 <DD>
1706 Expands to the process ID of the most recently executed background
1707 (asynchronous) command.
1708 <DT><B>0</B>
1709
1710 <DD>
1711 Expands to the name of the shell or shell script. This is set at
1712 shell initialization. If
1713 <B>bash</B>
1714
1715 is invoked with a file of commands,
1716 <B>$0</B>
1717
1718 is set to the name of that file. If
1719 <B>bash</B>
1720
1721 is started with the
1722 <B>-c</B>
1723
1724 option, then
1725 <B>$0</B>
1726
1727 is set to the first argument after the string to be
1728 executed, if one is present. Otherwise, it is set
1729 to the filename used to invoke
1730 <B>bash</B>,
1731
1732 as given by argument zero.
1733 <DT><B>_</B>
1734
1735 <DD>
1736 At shell startup, set to the absolute pathname used to invoke the
1737 shell or shell script being executed as passed in the environment
1738 or argument list.
1739 Subsequently, expands to the last argument to the previous command,
1740 after expansion.
1741 Also set to the full pathname used to invoke each command executed
1742 and placed in the environment exported to that command.
1743 When checking mail, this parameter holds the name of the mail file
1744 currently being checked.
1745
1746 </DL>
1747 <A NAME="lbAW">&nbsp;</A>
1748 <H4>Shell Variables</H4>
1749
1750 <P>
1751
1752 The following variables are set by the shell:
1753 <P>
1754
1755
1756 <DL COMPACT>
1757 <DT><B>BASH</B>
1758
1759 <DD>
1760 Expands to the full filename used to invoke this instance of
1761 <B>bash</B>.
1762
1763 <DT><B>BASHOPTS</B>
1764
1765 <DD>
1766 A colon-separated list of enabled shell options. Each word in
1767 the list is a valid argument for the
1768 <B>-s</B>
1769
1770 option to the
1771 <B>shopt</B>
1772
1773 builtin command (see
1774 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
1775
1776 </FONT>
1777 below). The options appearing in
1778 <FONT SIZE=-1><B>BASHOPTS</B>
1779
1780 </FONT>
1781 are those reported as
1782 <I>on</I>
1783
1784 by <B>shopt</B>.
1785 If this variable is in the environment when
1786 <B>bash</B>
1787
1788 starts up, each shell option in the list will be enabled before
1789 reading any startup files.
1790 This variable is read-only.
1791 <DT><B>BASHPID</B>
1792
1793 <DD>
1794 Expands to the process ID of the current <B>bash</B> process.
1795 This differs from <B>$$</B> under certain circumstances, such as subshells
1796 that do not require <B>bash</B> to be re-initialized.
1797 <DT><B>BASH_ALIASES</B>
1798
1799 <DD>
1800 An associative array variable whose members correspond to the internal
1801 list of aliases as maintained by the <B>alias</B> builtin.
1802 Elements added to this array appear in the alias list; unsetting array
1803 elements cause aliases to be removed from the alias list.
1804 <DT><B>BASH_ARGC</B>
1805
1806 <DD>
1807 An array variable whose values are the number of parameters in each
1808 frame of the current <B>bash</B> execution call stack.
1809 The number of
1810 parameters to the current subroutine (shell function or script executed
1811 with <B>.</B> or <B>source</B>) is at the top of the stack.
1812 When a subroutine is executed, the number of parameters passed is pushed onto
1813 <FONT SIZE=-1><B>BASH_ARGC</B>.
1814
1815 </FONT>
1816 The shell sets
1817 <FONT SIZE=-1><B>BASH_ARGC</B>
1818
1819 </FONT>
1820 only when in extended debugging mode (see the description of the
1821 <B>extdebug</B>
1822
1823 option to the
1824 <B>shopt</B>
1825
1826 builtin below)
1827 <DT><B>BASH_ARGV</B>
1828
1829 <DD>
1830 An array variable containing all of the parameters in the current <B>bash</B>
1831 execution call stack. The final parameter of the last subroutine call
1832 is at the top of the stack; the first parameter of the initial call is
1833 at the bottom. When a subroutine is executed, the parameters supplied
1834 are pushed onto
1835 <FONT SIZE=-1><B>BASH_ARGV</B>.
1836
1837 </FONT>
1838 The shell sets
1839 <FONT SIZE=-1><B>BASH_ARGV</B>
1840
1841 </FONT>
1842 only when in extended debugging mode
1843 (see the description of the
1844 <B>extdebug</B>
1845
1846 option to the
1847 <B>shopt</B>
1848
1849 builtin below)
1850 <DT><B>BASH_CMDS</B>
1851
1852 <DD>
1853 An associative array variable whose members correspond to the internal
1854 hash table of commands as maintained by the <B>hash</B> builtin.
1855 Elements added to this array appear in the hash table; unsetting array
1856 elements cause commands to be removed from the hash table.
1857 <DT><B>BASH_COMMAND</B>
1858
1859 <DD>
1860 The command currently being executed or about to be executed, unless the
1861 shell is executing a command as the result of a trap,
1862 in which case it is the command executing at the time of the trap.
1863 <DT><B>BASH_EXECUTION_STRING</B>
1864
1865 <DD>
1866 The command argument to the <B>-c</B> invocation option.
1867 <DT><B>BASH_LINENO</B>
1868
1869 <DD>
1870 An array variable whose members are the line numbers in source files
1871 where each corresponding member of
1872 <FONT SIZE=-1><B>FUNCNAME</B>
1873
1874 </FONT>
1875 was invoked.
1876 <B>${BASH_LINENO[</B><I>$i</I><B>]}</B> is the line number in the source
1877 file (<B>${BASH_SOURCE[</B><I>$i+1</I><B>]}</B>) where
1878 <B>${FUNCNAME[</B><I>$i</I><B>]}</B> was called
1879 (or <B>${BASH_LINENO[</B><I>$i-1</I><B>]}</B> if referenced within another
1880 shell function).
1881 Use
1882 <FONT SIZE=-1><B>LINENO</B>
1883
1884 </FONT>
1885 to obtain the current line number.
1886 <DT><B>BASH_REMATCH</B>
1887
1888 <DD>
1889 An array variable whose members are assigned by the <B>=~</B> binary
1890 operator to the <B>[[</B> conditional command.
1891 The element with index 0 is the portion of the string
1892 matching the entire regular expression.
1893 The element with index <I>n</I> is the portion of the
1894 string matching the <I>n</I>th parenthesized subexpression.
1895 This variable is read-only.
1896 <DT><B>BASH_SOURCE</B>
1897
1898 <DD>
1899 An array variable whose members are the source filenames
1900 where the corresponding shell function names in the
1901 <FONT SIZE=-1><B>FUNCNAME</B>
1902
1903 </FONT>
1904 array variable are defined.
1905 The shell function
1906 <B>${FUNCNAME[</B><I>$i</I><B>]}</B> is defined in the file
1907 <B>${BASH_SOURCE[</B><I>$i</I><B>]}</B> and called from
1908 <B>${BASH_SOURCE[</B><I>$i+1</I><B>]}</B>.
1909 <DT><B>BASH_SUBSHELL</B>
1910
1911 <DD>
1912 Incremented by one within each subshell or subshell environment when
1913 the shell begins executing in that environment.
1914 The initial value is 0.
1915 <DT><B>BASH_VERSINFO</B>
1916
1917 <DD>
1918 A readonly array variable whose members hold version information for
1919 this instance of
1920 <B>bash</B>.
1921
1922 The values assigned to the array members are as follows:
1923 <P>
1924 <DL COMPACT><DT><DD>
1925 <DL COMPACT>
1926 <DT><B>BASH_VERSINFO[</B>0]
1927
1928 <DD>
1929 The major version number (the <I>release</I>).
1930 <DT><B>BASH_VERSINFO[</B>1]
1931
1932 <DD>
1933 The minor version number (the <I>version</I>).
1934 <DT><B>BASH_VERSINFO[</B>2]
1935
1936 <DD>
1937 The patch level.
1938 <DT><B>BASH_VERSINFO[</B>3]
1939
1940 <DD>
1941 The build version.
1942 <DT><B>BASH_VERSINFO[</B>4]
1943
1944 <DD>
1945 The release status (e.g., <I>beta1</I>).
1946 <DT><B>BASH_VERSINFO[</B>5]
1947
1948 <DD>
1949 The value of
1950 <FONT SIZE=-1><B>MACHTYPE</B>.
1951
1952 </FONT>
1953 </DL></DL>
1954
1955 <DT><B>BASH_VERSION</B>
1956
1957 <DD>
1958 Expands to a string describing the version of this instance of
1959 <B>bash</B>.
1960
1961 <DT><B>COMP_CWORD</B>
1962
1963 <DD>
1964 An index into <B>${COMP_WORDS}</B> of the word containing the current
1965 cursor position.
1966 This variable is available only in shell functions invoked by the
1967 programmable completion facilities (see <B>Programmable Completion</B>
1968 below).
1969 <DT><B>COMP_KEY</B>
1970
1971 <DD>
1972 The key (or final key of a key sequence) used to invoke the current
1973 completion function.
1974 <DT><B>COMP_LINE</B>
1975
1976 <DD>
1977 The current command line.
1978 This variable is available only in shell functions and external
1979 commands invoked by the
1980 programmable completion facilities (see <B>Programmable Completion</B>
1981 below).
1982 <DT><B>COMP_POINT</B>
1983
1984 <DD>
1985 The index of the current cursor position relative to the beginning of
1986 the current command.
1987 If the current cursor position is at the end of the current command,
1988 the value of this variable is equal to <B>${#COMP_LINE}</B>.
1989 This variable is available only in shell functions and external
1990 commands invoked by the
1991 programmable completion facilities (see <B>Programmable Completion</B>
1992 below).
1993 <DT><B>COMP_TYPE</B>
1994
1995 <DD>
1996 Set to an integer value corresponding to the type of completion attempted
1997 that caused a completion function to be called:
1998 <I>TAB</I>, for normal completion,
1999 <I>?</I>, for listing completions after successive tabs,
2000 <I>!</I>, for listing alternatives on partial word completion,
2001 <I>@</I>, to list completions if the word is not unmodified,
2002 or
2003 <I>%</I>, for menu completion.
2004 This variable is available only in shell functions and external
2005 commands invoked by the
2006 programmable completion facilities (see <B>Programmable Completion</B>
2007 below).
2008 <DT><B>COMP_WORDBREAKS</B>
2009
2010 <DD>
2011 The set of characters that the <B>readline</B> library treats as word
2012 separators when performing word completion.
2013 If
2014 <FONT SIZE=-1><B>COMP_WORDBREAKS</B>
2015
2016 </FONT>
2017 is unset, it loses its special properties, even if it is
2018 subsequently reset.
2019 <DT><B>COMP_WORDS</B>
2020
2021 <DD>
2022 An array variable (see <B>Arrays</B> below) consisting of the individual
2023 words in the current command line.
2024 The line is split into words as <B>readline</B> would split it, using
2025 <FONT SIZE=-1><B>COMP_WORDBREAKS</B>
2026
2027 </FONT>
2028 as described above.
2029 This variable is available only in shell functions invoked by the
2030 programmable completion facilities (see <B>Programmable Completion</B>
2031 below).
2032 <DT><B>COPROC</B>
2033
2034 <DD>
2035 An array variable (see <B>Arrays</B> below) created to hold the file descriptors
2036 for output from and input to an unnamed coprocess (see <B>Coprocesses</B>
2037 above).
2038 <DT><B>DIRSTACK</B>
2039
2040 <DD>
2041 An array variable (see
2042 <B>Arrays</B>
2043
2044 below) containing the current contents of the directory stack.
2045 Directories appear in the stack in the order they are displayed by the
2046 <B>dirs</B>
2047
2048 builtin.
2049 Assigning to members of this array variable may be used to modify
2050 directories already in the stack, but the
2051 <B>pushd</B>
2052
2053 and
2054 <B>popd</B>
2055
2056 builtins must be used to add and remove directories.
2057 Assignment to this variable will not change the current directory.
2058 If
2059 <FONT SIZE=-1><B>DIRSTACK</B>
2060
2061 </FONT>
2062 is unset, it loses its special properties, even if it is
2063 subsequently reset.
2064 <DT><B>EUID</B>
2065
2066 <DD>
2067 Expands to the effective user ID of the current user, initialized at
2068 shell startup. This variable is readonly.
2069 <DT><B>FUNCNAME</B>
2070
2071 <DD>
2072 An array variable containing the names of all shell functions
2073 currently in the execution call stack.
2074 The element with index 0 is the name of any currently-executing
2075 shell function.
2076 The bottom-most element (the one with the highest index) is
2077 <TT>&quot;main&quot;</TT>.
2078
2079 This variable exists only when a shell function is executing.
2080 Assignments to
2081 <FONT SIZE=-1><B>FUNCNAME</B>
2082
2083 </FONT>
2084 have no effect and return an error status.
2085 If
2086 <FONT SIZE=-1><B>FUNCNAME</B>
2087
2088 </FONT>
2089 is unset, it loses its special properties, even if it is
2090 subsequently reset.
2091 <P>
2092
2093
2094 This variable can be used with <B>BASH_LINENO</B> and <B>BASH_SOURCE</B>.
2095 Each element of <B>FUNCNAME</B> has corresponding elements in
2096 <B>BASH_LINENO</B> and <B>BASH_SOURCE</B> to describe the call stack.
2097 For instance, <B>${FUNCNAME[</B><I>$i</I><B>]}</B> was called from the file
2098 <B>${BASH_SOURCE[</B><I>$i+1</I><B>]}</B> at line number
2099 <B>${BASH_LINENO[</B><I>$i</I><B>]}</B>.
2100 The <B>caller</B> builtin displays the current call stack using this
2101 information.
2102 <DT><B>GROUPS</B>
2103
2104 <DD>
2105 An array variable containing the list of groups of which the current
2106 user is a member.
2107 Assignments to
2108 <FONT SIZE=-1><B>GROUPS</B>
2109
2110 </FONT>
2111 have no effect and return an error status.
2112 If
2113 <FONT SIZE=-1><B>GROUPS</B>
2114
2115 </FONT>
2116 is unset, it loses its special properties, even if it is
2117 subsequently reset.
2118 <DT><B>HISTCMD</B>
2119
2120 <DD>
2121 The history number, or index in the history list, of the current
2122 command.
2123 If
2124 <FONT SIZE=-1><B>HISTCMD</B>
2125
2126 </FONT>
2127 is unset, it loses its special properties, even if it is
2128 subsequently reset.
2129 <DT><B>HOSTNAME</B>
2130
2131 <DD>
2132 Automatically set to the name of the current host.
2133 <DT><B>HOSTTYPE</B>
2134
2135 <DD>
2136 Automatically set to a string that uniquely
2137 describes the type of machine on which
2138 <B>bash</B>
2139
2140 is executing.
2141 The default is system-dependent.
2142 <DT><B>LINENO</B>
2143
2144 <DD>
2145 Each time this parameter is referenced, the shell substitutes
2146 a decimal number representing the current sequential line number
2147 (starting with 1) within a script or function. When not in a
2148 script or function, the value substituted is not guaranteed to
2149 be meaningful.
2150 If
2151 <FONT SIZE=-1><B>LINENO</B>
2152
2153 </FONT>
2154 is unset, it loses its special properties, even if it is
2155 subsequently reset.
2156 <DT><B>MACHTYPE</B>
2157
2158 <DD>
2159 Automatically set to a string that fully describes the system
2160 type on which
2161 <B>bash</B>
2162
2163 is executing, in the standard GNU <I>cpu-company-system</I> format.
2164 The default is system-dependent.
2165 <DT><B>MAPFILE</B>
2166
2167 <DD>
2168 An array variable (see <B>Arrays</B> below) created to hold the text
2169 read by the <B>mapfile</B> builtin when no variable name is supplied.
2170 <DT><B>OLDPWD</B>
2171
2172 <DD>
2173 The previous working directory as set by the
2174 <B>cd</B>
2175
2176 command.
2177 <DT><B>OPTARG</B>
2178
2179 <DD>
2180 The value of the last option argument processed by the
2181 <B>getopts</B>
2182
2183 builtin command (see
2184 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2185
2186 </FONT>
2187 below).
2188 <DT><B>OPTIND</B>
2189
2190 <DD>
2191 The index of the next argument to be processed by the
2192 <B>getopts</B>
2193
2194 builtin command (see
2195 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2196
2197 </FONT>
2198 below).
2199 <DT><B>OSTYPE</B>
2200
2201 <DD>
2202 Automatically set to a string that
2203 describes the operating system on which
2204 <B>bash</B>
2205
2206 is executing.
2207 The default is system-dependent.
2208 <DT><B>PIPESTATUS</B>
2209
2210 <DD>
2211 An array variable (see
2212 <B>Arrays</B>
2213
2214 below) containing a list of exit status values from the processes
2215 in the most-recently-executed foreground pipeline (which may
2216 contain only a single command).
2217 <DT><B>PPID</B>
2218
2219 <DD>
2220 The process ID of the shell's parent. This variable is readonly.
2221 <DT><B>PWD</B>
2222
2223 <DD>
2224 The current working directory as set by the
2225 <B>cd</B>
2226
2227 command.
2228 <DT><B>RANDOM</B>
2229
2230 <DD>
2231 Each time this parameter is referenced, a random integer between
2232 0 and 32767 is
2233 generated. The sequence of random numbers may be initialized by assigning
2234 a value to
2235 <FONT SIZE=-1><B>RANDOM</B>.
2236
2237 </FONT>
2238 If
2239 <FONT SIZE=-1><B>RANDOM</B>
2240
2241 </FONT>
2242 is unset, it loses its special properties, even if it is
2243 subsequently reset.
2244 <DT><B>READLINE_LINE</B>
2245
2246 <DD>
2247 The contents of the
2248 <B>readline</B>
2249
2250 line buffer, for use with
2251 <TT>bind -x</TT>
2252
2253 (see
2254 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2255
2256 </FONT>
2257 below).
2258 <DT><B>READLINE_POINT</B>
2259
2260 <DD>
2261 The position of the insertion point in the
2262 <B>readline</B>
2263
2264 line buffer, for use with
2265 <TT>bind -x</TT>
2266
2267 (see
2268 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2269
2270 </FONT>
2271 below).
2272 <DT><B>REPLY</B>
2273
2274 <DD>
2275 Set to the line of input read by the
2276 <B>read</B>
2277
2278 builtin command when no arguments are supplied.
2279 <DT><B>SECONDS</B>
2280
2281 <DD>
2282 Each time this parameter is
2283 referenced, the number of seconds since shell invocation is returned. If a
2284 value is assigned to
2285 <FONT SIZE=-1><B>SECONDS</B>,
2286
2287 </FONT>
2288 the value returned upon subsequent
2289 references is
2290 the number of seconds since the assignment plus the value assigned.
2291 If
2292 <FONT SIZE=-1><B>SECONDS</B>
2293
2294 </FONT>
2295 is unset, it loses its special properties, even if it is
2296 subsequently reset.
2297 <DT><B>SHELLOPTS</B>
2298
2299 <DD>
2300 A colon-separated list of enabled shell options. Each word in
2301 the list is a valid argument for the
2302 <B>-o</B>
2303
2304 option to the
2305 <B>set</B>
2306
2307 builtin command (see
2308 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2309
2310 </FONT>
2311 below). The options appearing in
2312 <FONT SIZE=-1><B>SHELLOPTS</B>
2313
2314 </FONT>
2315 are those reported as
2316 <I>on</I>
2317
2318 by <B>set -o</B>.
2319 If this variable is in the environment when
2320 <B>bash</B>
2321
2322 starts up, each shell option in the list will be enabled before
2323 reading any startup files.
2324 This variable is read-only.
2325 <DT><B>SHLVL</B>
2326
2327 <DD>
2328 Incremented by one each time an instance of
2329 <B>bash</B>
2330
2331 is started.
2332 <DT><B>UID</B>
2333
2334 <DD>
2335 Expands to the user ID of the current user, initialized at shell startup.
2336 This variable is readonly.
2337
2338 </DL>
2339 <P>
2340
2341 The following variables are used by the shell. In some cases,
2342 <B>bash</B>
2343
2344 assigns a default value to a variable; these cases are noted
2345 below.
2346 <P>
2347
2348
2349 <DL COMPACT>
2350 <DT><B>BASH_ENV</B>
2351
2352 <DD>
2353 If this parameter is set when <B>bash</B> is executing a shell script,
2354 its value is interpreted as a filename containing commands to
2355 initialize the shell, as in
2356 <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>.
2357
2358 The value of
2359 <FONT SIZE=-1><B>BASH_ENV</B>
2360
2361 </FONT>
2362 is subjected to parameter expansion, command substitution, and arithmetic
2363 expansion before being interpreted as a filename.
2364 <FONT SIZE=-1><B>PATH</B>
2365
2366 </FONT>
2367 is not used to search for the resultant filename.
2368 <DT><B>BASH_XTRACEFD</B>
2369
2370 <DD>
2371 If set to an integer corresponding to a valid file descriptor, <B>bash</B>
2372 will write the trace output generated when
2373 <TT>set -x</TT>
2374
2375 is enabled to that file descriptor.
2376 The file descriptor is closed when
2377 <FONT SIZE=-1><B>BASH_XTRACEFD</B>
2378
2379 </FONT>
2380 is unset or assigned a new value.
2381 Unsetting
2382 <FONT SIZE=-1><B>BASH_XTRACEFD</B>
2383
2384 </FONT>
2385 or assigning it the empty string causes the
2386 trace output to be sent to the standard error.
2387 Note that setting
2388 <FONT SIZE=-1><B>BASH_XTRACEFD</B>
2389
2390 </FONT>
2391 to 2 (the standard error file
2392 descriptor) and then unsetting it will result in the standard error
2393 being closed.
2394 <DT><B>CDPATH</B>
2395
2396 <DD>
2397 The search path for the
2398 <B>cd</B>
2399
2400 command.
2401 This is a colon-separated list of directories in which the shell looks
2402 for destination directories specified by the
2403 <B>cd</B>
2404
2405 command.
2406 A sample value is
2407 <TT>&quot;.:~:/usr&quot;</TT>.
2408
2409 <DT><B>COLUMNS</B>
2410
2411 <DD>
2412 Used by the <B>select</B> compound command to determine the terminal width
2413 when printing selection lists. Automatically set in an interactive shell
2414 upon receipt of a
2415 <FONT SIZE=-1><B>SIGWINCH</B>.
2416
2417 </FONT>
2418 <DT><B>COMPREPLY</B>
2419
2420 <DD>
2421 An array variable from which <B>bash</B> reads the possible completions
2422 generated by a shell function invoked by the programmable completion
2423 facility (see <B>Programmable Completion</B> below).
2424 Each array element contains one possible completion.
2425 <DT><B>EMACS</B>
2426
2427 <DD>
2428 If <B>bash</B> finds this variable in the environment when the shell starts
2429 with value
2430 <TT>t</TT>,
2431
2432 it assumes that the shell is running in an Emacs shell buffer and disables
2433 line editing.
2434 <DT><B>ENV</B>
2435
2436 <DD>
2437 Similar to
2438 <FONT SIZE=-1><B>BASH_ENV</B>;
2439
2440 </FONT>
2441 used when the shell is invoked in POSIX mode.
2442 <DT><B>FCEDIT</B>
2443
2444 <DD>
2445 The default editor for the
2446 <B>fc</B>
2447
2448 builtin command.
2449 <DT><B>FIGNORE</B>
2450
2451 <DD>
2452 A colon-separated list of suffixes to ignore when performing
2453 filename completion (see
2454 <FONT SIZE=-1><B>READLINE</B>
2455
2456 </FONT>
2457 below).
2458 A filename whose suffix matches one of the entries in
2459 <FONT SIZE=-1><B>FIGNORE</B>
2460
2461 </FONT>
2462 is excluded from the list of matched filenames.
2463 A sample value is
2464 <TT>&quot;.o:~&quot;</TT>.
2465
2466 <DT><B>FUNCNEST</B>
2467
2468 <DD>
2469 If set to a numeric value greater than 0, defines a maximum function
2470 nesting level. Function invocations that exceed this nesting level
2471 will cause the current command to abort.
2472 <DT><B>GLOBIGNORE</B>
2473
2474 <DD>
2475 A colon-separated list of patterns defining the set of filenames to
2476 be ignored by pathname expansion.
2477 If a filename matched by a pathname expansion pattern also matches one
2478 of the patterns in
2479 <FONT SIZE=-1><B>GLOBIGNORE</B>,
2480
2481 </FONT>
2482 it is removed from the list of matches.
2483 <DT><B>HISTCONTROL</B>
2484
2485 <DD>
2486 A colon-separated list of values controlling how commands are saved on
2487 the history list.
2488 If the list of values includes
2489 <I>ignorespace</I>,
2490
2491 lines which begin with a
2492 <B>space</B>
2493
2494 character are not saved in the history list.
2495 A value of
2496 <I>ignoredups</I>
2497
2498 causes lines matching the previous history entry to not be saved.
2499 A value of
2500 <I>ignoreboth</I>
2501
2502 is shorthand for <I>ignorespace</I> and <I>ignoredups</I>.
2503 A value of
2504 <I>erasedups</I>
2505
2506 causes all previous lines matching the current line to be removed from
2507 the history list before that line is saved.
2508 Any value not in the above list is ignored.
2509 If
2510 <FONT SIZE=-1><B>HISTCONTROL</B>
2511
2512 </FONT>
2513 is unset, or does not include a valid value,
2514 all lines read by the shell parser are saved on the history list,
2515 subject to the value of
2516 <FONT SIZE=-1><B>HISTIGNORE</B>.
2517
2518 </FONT>
2519 The second and subsequent lines of a multi-line compound command are
2520 not tested, and are added to the history regardless of the value of
2521 <FONT SIZE=-1><B>HISTCONTROL</B>.
2522
2523 </FONT>
2524 <DT><B>HISTFILE</B>
2525
2526 <DD>
2527 The name of the file in which command history is saved (see
2528 <FONT SIZE=-1><B>HISTORY</B>
2529
2530 </FONT>
2531 below). The default value is <A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>. If unset, the
2532 command history is not saved when an interactive shell exits.
2533 <DT><B>HISTFILESIZE</B>
2534
2535 <DD>
2536 The maximum number of lines contained in the history file. When this
2537 variable is assigned a value, the history file is truncated, if
2538 necessary,
2539 to contain no more than that number of lines by removing the oldest entries.
2540 The history file is also truncated to this size after
2541 writing it when an interactive shell exits.
2542 If the value is 0, the history file is truncated to zero size.
2543 Non-numeric values and numeric values less than zero inhibit truncation.
2544 The shell sets the default value to the value of <B>HISTSIZE</B>
2545 after reading any startup files.
2546 <DT><B>HISTIGNORE</B>
2547
2548 <DD>
2549 A colon-separated list of patterns used to decide which command lines
2550 should be saved on the history list. Each pattern is anchored at the
2551 beginning of the line and must match the complete line (no implicit
2552 `<B>*</B>' is appended). Each pattern is tested against the line
2553 after the checks specified by
2554 <FONT SIZE=-1><B>HISTCONTROL</B>
2555
2556 </FONT>
2557 are applied.
2558 In addition to the normal shell pattern matching characters, `<B>&amp;</B>'
2559 matches the previous history line. `<B>&amp;</B>' may be escaped using a
2560 backslash; the backslash is removed before attempting a match.
2561 The second and subsequent lines of a multi-line compound command are
2562 not tested, and are added to the history regardless of the value of
2563 <FONT SIZE=-1><B>HISTIGNORE</B>.
2564
2565 </FONT>
2566 <DT><B>HISTSIZE</B>
2567
2568 <DD>
2569 The number of commands to remember in the command history (see
2570 <FONT SIZE=-1><B>HISTORY</B>
2571
2572 </FONT>
2573 below).
2574 If the value is 0, commands are not saved in the history list.
2575 Numeric values less than zero result in every command being saved
2576 on the history list (there is no limit).
2577 The shell sets the default value to 500 after reading any startup files.
2578 <DT><B>HISTTIMEFORMAT</B>
2579
2580 <DD>
2581 If this variable is set and not null, its value is used as a format string
2582 for <I>strftime</I>(3) to print the time stamp associated with each history
2583 entry displayed by the <B>history</B> builtin.
2584 If this variable is set, time stamps are written to the history file so
2585 they may be preserved across shell sessions.
2586 This uses the history comment character to distinguish timestamps from
2587 other history lines.
2588 <DT><B>HOME</B>
2589
2590 <DD>
2591 The home directory of the current user; the default argument for the
2592 <B>cd</B> builtin command.
2593 The value of this variable is also used when performing tilde expansion.
2594 <DT><B>HOSTFILE</B>
2595
2596 <DD>
2597 Contains the name of a file in the same format as
2598
2599 <I>/etc/hosts</I>
2600
2601 that should be read when the shell needs to complete a
2602 hostname.
2603 The list of possible hostname completions may be changed while the
2604 shell is running;
2605 the next time hostname completion is attempted after the
2606 value is changed,
2607 <B>bash</B>
2608
2609 adds the contents of the new file to the existing list.
2610 If
2611 <FONT SIZE=-1><B>HOSTFILE</B>
2612
2613 </FONT>
2614 is set, but has no value, or does not name a readable file,
2615 <B>bash</B> attempts to read
2616
2617 <I>/etc/hosts</I>
2618
2619 to obtain the list of possible hostname completions.
2620 When
2621 <FONT SIZE=-1><B>HOSTFILE</B>
2622
2623 </FONT>
2624 is unset, the hostname list is cleared.
2625 <DT><B>IFS</B>
2626
2627 <DD>
2628 The
2629 <I>Internal Field Separator</I>
2630
2631 that is used
2632 for word splitting after expansion and to
2633 split lines into words with the
2634 <B>read</B>
2635
2636 builtin command. The default value is
2637 ``&lt;space&gt;&lt;tab&gt;&lt;newline&gt;''.
2638 <DT><B>IGNOREEOF</B>
2639
2640 <DD>
2641 Controls the
2642 action of an interactive shell on receipt of an
2643 <FONT SIZE=-1><B>EOF</B>
2644
2645 </FONT>
2646 character as the sole input. If set, the value is the number of
2647 consecutive
2648 <FONT SIZE=-1><B>EOF</B>
2649
2650 </FONT>
2651 characters which must be
2652 typed as the first characters on an input line before
2653 <B>bash</B>
2654
2655 exits. If the variable exists but does not have a numeric value, or
2656 has no value, the default value is 10. If it does not exist,
2657 <FONT SIZE=-1><B>EOF</B>
2658
2659 </FONT>
2660 signifies the end of input to the shell.
2661 <DT><B>INPUTRC</B>
2662
2663 <DD>
2664 The filename for the
2665 <B>readline</B>
2666
2667 startup file, overriding the default of
2668
2669 <A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>
2670
2671 (see
2672 <FONT SIZE=-1><B>READLINE</B>
2673
2674 </FONT>
2675 below).
2676 <DT><B>LANG</B>
2677
2678 <DD>
2679 Used to determine the locale category for any category not specifically
2680 selected with a variable starting with <B>LC_</B>.
2681 <DT><B>LC_ALL</B>
2682
2683 <DD>
2684 This variable overrides the value of
2685 <FONT SIZE=-1><B>LANG</B>
2686
2687 </FONT>
2688 and any other
2689 <B>LC_</B> variable specifying a locale category.
2690 <DT><B>LC_COLLATE</B>
2691
2692 <DD>
2693 This variable determines the collation order used when sorting the
2694 results of pathname expansion, and determines the behavior of range
2695 expressions, equivalence classes, and collating sequences within
2696 pathname expansion and pattern matching.
2697 <DT><B>LC_CTYPE</B>
2698
2699 <DD>
2700 This variable determines the interpretation of characters and the
2701 behavior of character classes within pathname expansion and pattern
2702 matching.
2703 <DT><B>LC_MESSAGES</B>
2704
2705 <DD>
2706 This variable determines the locale used to translate double-quoted
2707 strings preceded by a <B>$</B>.
2708 <DT><B>LC_NUMERIC</B>
2709
2710 <DD>
2711 This variable determines the locale category used for number formatting.
2712 <DT><B>LINES</B>
2713
2714 <DD>
2715 Used by the <B>select</B> compound command to determine the column length
2716 for printing selection lists. Automatically set by an interactive shell
2717 upon receipt of a
2718 <FONT SIZE=-1><B>SIGWINCH</B>.
2719
2720 </FONT>
2721 <DT><B>MAIL</B>
2722
2723 <DD>
2724 If this parameter is set to a file or directory name and the
2725 <FONT SIZE=-1><B>MAILPATH</B>
2726
2727 </FONT>
2728 variable is not set,
2729 <B>bash</B>
2730
2731 informs the user of the arrival of mail in the specified file or
2732 Maildir-format directory.
2733 <DT><B>MAILCHECK</B>
2734
2735 <DD>
2736 Specifies how
2737 often (in seconds)
2738 <B>bash</B>
2739
2740 checks for mail. The default is 60 seconds. When it is time to check
2741 for mail, the shell does so before displaying the primary prompt.
2742 If this variable is unset, or set to a value that is not a number
2743 greater than or equal to zero, the shell disables mail checking.
2744 <DT><B>MAILPATH</B>
2745
2746 <DD>
2747 A colon-separated list of filenames to be checked for mail.
2748 The message to be printed when mail arrives in a particular file
2749 may be specified by separating the filename from the message with a `?'.
2750 When used in the text of the message, <B>$_</B> expands to the name of
2751 the current mailfile.
2752 Example:
2753 <DL COMPACT><DT><DD>
2754 <P>
2755
2756 <B>MAILPATH</B>=aq/var/mail/bfox?&quot;You have mail&quot;:~/shell-mail?&quot;$_ has mail!&quot;aq
2757 <P>
2758
2759 <B>Bash</B>
2760
2761 supplies a default value for this variable, but the location of the user
2762 mail files that it uses is system dependent (e.g., /var/mail/<B>$USER</B>).
2763 </DL>
2764
2765 <DT><B>OPTERR</B>
2766
2767 <DD>
2768 If set to the value 1,
2769 <B>bash</B>
2770
2771 displays error messages generated by the
2772 <B>getopts</B>
2773
2774 builtin command (see
2775 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2776
2777 </FONT>
2778 below).
2779 <FONT SIZE=-1><B>OPTERR</B>
2780
2781 </FONT>
2782 is initialized to 1 each time the shell is invoked or a shell
2783 script is executed.
2784 <DT><B>PATH</B>
2785
2786 <DD>
2787 The search path for commands. It
2788 is a colon-separated list of directories in which
2789 the shell looks for commands (see
2790 <FONT SIZE=-1><B>COMMAND EXECUTION</B>
2791
2792 </FONT>
2793 below).
2794 A zero-length (null) directory name in the value of
2795 <FONT SIZE=-1><B>PATH</B>
2796
2797 </FONT>
2798 indicates the current directory.
2799 A null directory name may appear as two adjacent colons, or as an initial
2800 or trailing colon.
2801 The default path is system-dependent,
2802 and is set by the administrator who installs
2803 <B>bash</B>.
2804
2805 A common value is
2806 <TT>/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin</TT>.
2807
2808 <DT><B>POSIXLY_CORRECT</B>
2809
2810 <DD>
2811 If this variable is in the environment when <B>bash</B> starts, the shell
2812 enters <I>posix mode</I> before reading the startup files, as if the
2813 <B>--posix</B>
2814
2815 invocation option had been supplied. If it is set while the shell is
2816 running, <B>bash</B> enables <I>posix mode</I>, as if the command
2817 <TT>set -o posix</TT>
2818
2819 had been executed.
2820 <DT><B>PROMPT_COMMAND</B>
2821
2822 <DD>
2823 If set, the value is executed as a command prior to issuing each primary
2824 prompt.
2825 <DT><B>PROMPT_DIRTRIM</B>
2826
2827 <DD>
2828 If set to a number greater than zero, the value is used as the number of
2829 trailing directory components to retain when expanding the <B>\w</B> and
2830 <B>\W</B> prompt string escapes (see
2831 <FONT SIZE=-1><B>PROMPTING</B>
2832
2833 </FONT>
2834 below). Characters removed are replaced with an ellipsis.
2835 <DT><B>PS1</B>
2836
2837 <DD>
2838 The value of this parameter is expanded (see
2839 <FONT SIZE=-1><B>PROMPTING</B>
2840
2841 </FONT>
2842 below) and used as the primary prompt string. The default value is
2843 ``<B>\s-\v\$ </B>''.
2844 <DT><B>PS2</B>
2845
2846 <DD>
2847 The value of this parameter is expanded as with
2848 <FONT SIZE=-1><B>PS1</B>
2849
2850 </FONT>
2851 and used as the secondary prompt string. The default is
2852 ``<B>&gt; </B>''.
2853 <DT><B>PS3</B>
2854
2855 <DD>
2856 The value of this parameter is used as the prompt for the
2857 <B>select</B>
2858
2859 command (see
2860 <FONT SIZE=-1><B>SHELL GRAMMAR</B>
2861
2862 </FONT>
2863 above).
2864 <DT><B>PS4</B>
2865
2866 <DD>
2867 The value of this parameter is expanded as with
2868 <FONT SIZE=-1><B>PS1</B>
2869
2870 </FONT>
2871 and the value is printed before each command
2872 <B>bash</B>
2873
2874 displays during an execution trace. The first character of
2875 <FONT SIZE=-1><B>PS4</B>
2876
2877 </FONT>
2878 is replicated multiple times, as necessary, to indicate multiple
2879 levels of indirection. The default is ``<B>+ </B>''.
2880 <DT><B>SHELL</B>
2881
2882 <DD>
2883 The full pathname to the shell is kept in this environment variable.
2884 If it is not set when the shell starts,
2885 <B>bash</B>
2886
2887 assigns to it the full pathname of the current user's login shell.
2888 <DT><B>TIMEFORMAT</B>
2889
2890 <DD>
2891 The value of this parameter is used as a format string specifying
2892 how the timing information for pipelines prefixed with the
2893 <B>time</B>
2894
2895 reserved word should be displayed.
2896 The <B>%</B> character introduces an escape sequence that is
2897 expanded to a time value or other information.
2898 The escape sequences and their meanings are as follows; the
2899 braces denote optional portions.
2900 <P>
2901 <DL COMPACT><DT><DD>
2902
2903 <DL COMPACT>
2904 <DT><B>%%</B>
2905
2906 <DD>
2907 A literal <B>%</B>.
2908 <DT><B>%[</B><I>p</I>][l]R
2909
2910 <DD>
2911 The elapsed time in seconds.
2912 <DT><B>%[</B><I>p</I>][l]U
2913
2914 <DD>
2915 The number of CPU seconds spent in user mode.
2916 <DT><B>%[</B><I>p</I>][l]S
2917
2918 <DD>
2919 The number of CPU seconds spent in system mode.
2920 <DT><B>%P</B>
2921
2922 <DD>
2923 The CPU percentage, computed as (%U + %S) / %R.
2924
2925 </DL></DL>
2926
2927 <DT><DD>
2928 The optional <I>p</I> is a digit specifying the <I>precision</I>,
2929 the number of fractional digits after a decimal point.
2930 A value of 0 causes no decimal point or fraction to be output.
2931 At most three places after the decimal point may be specified;
2932 values of <I>p</I> greater than 3 are changed to 3.
2933 If <I>p</I> is not specified, the value 3 is used.
2934 <DT><DD>
2935 The optional <B>l</B> specifies a longer format, including
2936 minutes, of the form <I>MM</I>m<I>SS</I>.<I>FF</I>s.
2937 The value of <I>p</I> determines whether or not the fraction is
2938 included.
2939 <DT><DD>
2940 If this variable is not set, <B>bash</B> acts as if it had the
2941 value <B>$aq\nreal\t%3lR\nuser\t%3lU\nsys %3lSaq</B>.
2942 If the value is null, no timing information is displayed.
2943 A trailing newline is added when the format string is displayed.
2944
2945 <DT><B>TMOUT</B>
2946
2947 <DD>
2948 If set to a value greater than zero,
2949 <FONT SIZE=-1><B>TMOUT</B>
2950
2951 </FONT>
2952 is treated as the
2953 default timeout for the <B>read</B> builtin.
2954 The <B>select</B> command terminates if input does not arrive
2955 after
2956 <FONT SIZE=-1><B>TMOUT</B>
2957
2958 </FONT>
2959 seconds when input is coming from a terminal.
2960 In an interactive shell, the value is interpreted as the
2961 number of seconds to wait for input after issuing the primary prompt.
2962 <B>Bash</B>
2963
2964 terminates after waiting for that number of seconds if input does
2965 not arrive.
2966 <DT><B>TMPDIR</B>
2967
2968 <DD>
2969 If set, <B>bash</B> uses its value as the name of a directory in which
2970 <B>bash</B> creates temporary files for the shell's use.
2971 <DT><B>auto_resume</B>
2972
2973 <DD>
2974 This variable controls how the shell interacts with the user and
2975 job control. If this variable is set, single word simple
2976 commands without redirections are treated as candidates for resumption
2977 of an existing stopped job. There is no ambiguity allowed; if there is
2978 more than one job beginning with the string typed, the job most recently
2979 accessed is selected. The
2980 <I>name</I>
2981
2982 of a stopped job, in this context, is the command line used to
2983 start it.
2984 If set to the value
2985 <I>exact</I>,
2986
2987 the string supplied must match the name of a stopped job exactly;
2988 if set to
2989 <I>substring</I>,
2990
2991 the string supplied needs to match a substring of the name of a
2992 stopped job. The
2993 <I>substring</I>
2994
2995 value provides functionality analogous to the
2996 <B>%?</B>
2997
2998 job identifier (see
2999 <FONT SIZE=-1><B>JOB CONTROL</B>
3000
3001 </FONT>
3002 below). If set to any other value, the supplied string must
3003 be a prefix of a stopped job's name; this provides functionality
3004 analogous to the <B>%</B><I>string</I> job identifier.
3005 <DT><B>histchars</B>
3006
3007 <DD>
3008 The two or three characters which control history expansion
3009 and tokenization (see
3010 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
3011
3012 </FONT>
3013 below). The first character is the <I>history expansion</I> character,
3014 the character which signals the start of a history
3015 expansion, normally `<B>!</B>'.
3016 The second character is the <I>quick substitution</I>
3017 character, which is used as shorthand for re-running the previous
3018 command entered, substituting one string for another in the command.
3019 The default is `<B>^</B>'.
3020 The optional third character is the character
3021 which indicates that the remainder of the line is a comment when found
3022 as the first character of a word, normally `<B>#</B>'. The history
3023 comment character causes history substitution to be skipped for the
3024 remaining words on the line. It does not necessarily cause the shell
3025 parser to treat the rest of the line as a comment.
3026
3027 </DL>
3028 <A NAME="lbAX">&nbsp;</A>
3029 <H4>Arrays</H4>
3030
3031 <B>Bash</B>
3032
3033 provides one-dimensional indexed and associative array variables.
3034 Any variable may be used as an indexed array; the
3035 <B>declare</B>
3036
3037 builtin will explicitly declare an array.
3038 There is no maximum
3039 limit on the size of an array, nor any requirement that members
3040 be indexed or assigned contiguously.
3041 Indexed arrays are referenced using integers (including arithmetic
3042 expressions) and are zero-based; associative arrays are referenced
3043 using arbitrary strings.
3044 <P>
3045
3046 An indexed array is created automatically if any variable is assigned to
3047 using the syntax <I>name</I>[<I>subscript</I>]=<I>value</I>. The
3048 <I>subscript</I>
3049
3050 is treated as an arithmetic expression that must evaluate to a number.
3051 To explicitly declare an indexed array, use
3052 <B>declare -a </B><I>name</I>
3053
3054 (see
3055 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
3056
3057 </FONT>
3058 below).
3059 <B>declare -a </B><I>name</I>[<I>subscript</I>]
3060
3061 is also accepted; the <I>subscript</I> is ignored.
3062 <P>
3063
3064 Associative arrays are created using
3065 <B>declare -A </B><I>name</I>.
3066
3067 <P>
3068
3069 Attributes may be
3070 specified for an array variable using the
3071 <B>declare</B>
3072
3073 and
3074 <B>readonly</B>
3075
3076 builtins. Each attribute applies to all members of an array.
3077 <P>
3078
3079 Arrays are assigned to using compound assignments of the form
3080 <I>name</I>=<B>(</B>value<I>1</I> ... value<I>n</I><B>)</B>, where each
3081 <I>value</I> is of the form [<I>subscript</I>]=<I>string</I>.
3082 Indexed array assignments do not require anything but <I>string</I>.
3083 When assigning to indexed arrays, if the optional brackets and subscript
3084 are supplied, that index is assigned to;
3085 otherwise the index of the element assigned is the last index assigned
3086 to by the statement plus one. Indexing starts at zero.
3087 <P>
3088
3089 When assigning to an associative array, the subscript is required.
3090 <P>
3091
3092 This syntax is also accepted by the
3093 <B>declare</B>
3094
3095 builtin. Individual array elements may be assigned to using the
3096 <I>name</I>[<I>subscript</I>]=<I>value</I> syntax introduced above.
3097 <P>
3098
3099 Any element of an array may be referenced using
3100 ${<I>name</I>[<I>subscript</I>]}. The braces are required to avoid
3101 conflicts with pathname expansion. If
3102 <I>subscript</I> is <B>@</B> or <B>*</B>, the word expands to
3103 all members of <I>name</I>. These subscripts differ only when the
3104 word appears within double quotes. If the word is double-quoted,
3105 ${<I>name</I>[*]} expands to a single
3106 word with the value of each array member separated by the first
3107 character of the
3108 <FONT SIZE=-1><B>IFS</B>
3109
3110 </FONT>
3111 special variable, and ${<I>name</I>[@]} expands each element of
3112 <I>name</I> to a separate word. When there are no array members,
3113 ${<I>name</I>[@]} expands to nothing.
3114 If the double-quoted expansion occurs within a word, the expansion of
3115 the first parameter is joined with the beginning part of the original
3116 word, and the expansion of the last parameter is joined with the last
3117 part of the original word.
3118 This is analogous to the expansion
3119 of the special parameters <B>*</B> and <B>@</B> (see
3120 <B>Special Parameters</B>
3121
3122 above). ${#<I>name</I>[<I>subscript</I>]} expands to the length of
3123 ${<I>name</I>[<I>subscript</I>]}. If <I>subscript</I> is <B>*</B> or
3124 <B>@</B>, the expansion is the number of elements in the array.
3125 Referencing an array variable without a subscript is equivalent to
3126 referencing the array with a subscript of 0.
3127 If the
3128 <I>subscript</I>
3129
3130 used to reference an element of an indexed array
3131 evaluates to a number less than zero, it is used as
3132 an offset from one greater than the array's maximum index (so a subcript
3133 of -1 refers to the last element of the array).
3134 <P>
3135
3136 An array variable is considered set if a subscript has been assigned a
3137 value. The null string is a valid value.
3138 <P>
3139
3140 The
3141 <B>unset</B>
3142
3143 builtin is used to destroy arrays. <B>unset</B> <I>name</I>[<I>subscript</I>]
3144 destroys the array element at index <I>subscript</I>.
3145 Care must be taken to avoid unwanted side effects caused by pathname
3146 expansion.
3147 <B>unset</B> <I>name</I>, where <I>name</I> is an array, or
3148 <B>unset</B> <I>name</I>[<I>subscript</I>], where
3149 <I>subscript</I> is <B>*</B> or <B>@</B>, removes the entire array.
3150 <P>
3151
3152 The
3153 <B>declare</B>,
3154
3155 <B>local</B>,
3156
3157 and
3158 <B>readonly</B>
3159
3160 builtins each accept a
3161 <B>-a</B>
3162
3163 option to specify an indexed array and a
3164 <B>-A</B>
3165
3166 option to specify an associative array.
3167 If both options are supplied,
3168 <B>-A</B>
3169
3170 takes precedence.
3171 The
3172 <B>read</B>
3173
3174 builtin accepts a
3175 <B>-a</B>
3176
3177 option to assign a list of words read from the standard input
3178 to an array. The
3179 <B>set</B>
3180
3181 and
3182 <B>declare</B>
3183
3184 builtins display array values in a way that allows them to be
3185 reused as assignments.
3186 <A NAME="lbAY">&nbsp;</A>
3187 <H3>EXPANSION</H3>
3188
3189 Expansion is performed on the command line after it has been split into
3190 words. There are seven kinds of expansion performed:
3191 <I>brace expansion</I>,
3192
3193 <I>tilde expansion</I>,
3194
3195 <I>parameter and variable expansion</I>,
3196
3197 <I>command substitution</I>,
3198
3199 <I>arithmetic expansion</I>,
3200
3201 <I>word splitting</I>,
3202
3203 and
3204 <I>pathname expansion</I>.
3205
3206 <P>
3207
3208 The order of expansions is: brace expansion, tilde expansion,
3209 parameter, variable and arithmetic expansion and
3210 command substitution
3211 (done in a left-to-right fashion), word splitting, and pathname
3212 expansion.
3213 <P>
3214
3215 On systems that can support it, there is an additional expansion
3216 available: <I>process substitution</I>.
3217 <P>
3218
3219 Only brace expansion, word splitting, and pathname expansion
3220 can change the number of words of the expansion; other expansions
3221 expand a single word to a single word.
3222 The only exceptions to this are the expansions of
3223 &quot;<B>$@</B>&quot; and &quot;<B>${</B><I>name</I><B>[@]}</B>&quot;
3224 as explained above (see
3225 <FONT SIZE=-1><B>PARAMETERS</B>).
3226
3227 </FONT>
3228 <A NAME="lbAZ">&nbsp;</A>
3229 <H4>Brace Expansion</H4>
3230
3231 <P>
3232
3233 <I>Brace expansion</I>
3234
3235 is a mechanism by which arbitrary strings
3236 may be generated. This mechanism is similar to
3237 <I>pathname expansion</I>, but the filenames generated
3238 need not exist. Patterns to be brace expanded take
3239 the form of an optional
3240 <I>preamble</I>,
3241
3242 followed by either a series of comma-separated strings or
3243 a sequence expression between a pair of braces, followed by
3244 an optional
3245 <I>postscript</I>.
3246
3247 The preamble is prefixed to each string contained
3248 within the braces, and the postscript is then appended
3249 to each resulting string, expanding left to right.
3250 <P>
3251
3252 Brace expansions may be nested. The results of each expanded
3253 string are not sorted; left to right order is preserved.
3254 For example, a<B>{</B>d,c,b<B>}</B>e expands into `ade ace abe'.
3255 <P>
3256
3257 A sequence expression takes the form
3258 <B>{</B><I>x</I><B>..</B><I>y</I><B>[..</B><I>incr</I><B>]}</B>,
3259 where <I>x</I> and <I>y</I> are either integers or single characters,
3260 and <I>incr</I>, an optional increment, is an integer.
3261 When integers are supplied, the expression expands to each number between
3262 <I>x</I> and <I>y</I>, inclusive.
3263 Supplied integers may be prefixed with <I>0</I> to force each term to have the
3264 same width. When either <I>x</I> or y begins with a zero, the shell
3265 attempts to force all generated terms to contain the same number of digits,
3266 zero-padding where necessary.
3267 When characters are supplied, the expression expands to each character
3268 lexicographically between <I>x</I> and <I>y</I>, inclusive. Note that
3269 both <I>x</I> and <I>y</I> must be of the same type.
3270 When the increment is supplied, it is used as the difference between
3271 each term. The default increment is 1 or -1 as appropriate.
3272 <P>
3273
3274 Brace expansion is performed before any other expansions,
3275 and any characters special to other expansions are preserved
3276 in the result. It is strictly textual.
3277 <B>Bash</B>
3278
3279 does not apply any syntactic interpretation to the context of the
3280 expansion or the text between the braces.
3281 <P>
3282
3283 A correctly-formed brace expansion must contain unquoted opening
3284 and closing braces, and at least one unquoted comma or a valid
3285 sequence expression.
3286 Any incorrectly formed brace expansion is left unchanged.
3287 A <B>{</B> or <B>,</B> may be quoted with a backslash to prevent its
3288 being considered part of a brace expression.
3289 To avoid conflicts with parameter expansion, the string <B>${</B>
3290 is not considered eligible for brace expansion.
3291 <P>
3292
3293 This construct is typically used as shorthand when the common
3294 prefix of the strings to be generated is longer than in the
3295 above example:
3296 <DL COMPACT><DT><DD>
3297 <P>
3298
3299 mkdir /usr/local/src/bash/{old,new,dist,bugs}
3300 </DL>
3301
3302 or
3303 <DL COMPACT><DT><DD>
3304 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
3305 </DL>
3306
3307 <P>
3308
3309 Brace expansion introduces a slight incompatibility with
3310 historical versions of
3311 <B>sh</B>.
3312
3313 <B>sh</B>
3314
3315 does not treat opening or closing braces specially when they
3316 appear as part of a word, and preserves them in the output.
3317 <B>Bash</B>
3318
3319 removes braces from words as a consequence of brace
3320 expansion. For example, a word entered to
3321 <B>sh</B>
3322
3323 as <I>file{1,2}</I>
3324 appears identically in the output. The same word is
3325 output as
3326 <I>file1 file2</I>
3327
3328 after expansion by
3329 <B>bash</B>.
3330
3331 If strict compatibility with
3332 <B>sh</B>
3333
3334 is desired, start
3335 <B>bash</B>
3336
3337 with the
3338 <B>+B </B>
3339
3340 option or disable brace expansion with the
3341 <B>+B</B>
3342
3343 option to the
3344 <B>set</B>
3345
3346 command (see
3347 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
3348
3349 </FONT>
3350 below).
3351 <A NAME="lbBA">&nbsp;</A>
3352 <H4>Tilde Expansion</H4>
3353
3354 <P>
3355
3356 If a word begins with an unquoted tilde character (`<B>~</B>'), all of
3357 the characters preceding the first unquoted slash (or all characters,
3358 if there is no unquoted slash) are considered a <I>tilde-prefix</I>.
3359 If none of the characters in the tilde-prefix are quoted, the
3360 characters in the tilde-prefix following the tilde are treated as a
3361 possible <I>login name</I>.
3362 If this login name is the null string, the tilde is replaced with the
3363 value of the shell parameter
3364 <FONT SIZE=-1><B>HOME</B>.
3365
3366 </FONT>
3367 If
3368 <FONT SIZE=-1><B>HOME</B>
3369
3370 </FONT>
3371 is unset, the home directory of the user executing the shell is
3372 substituted instead.
3373 Otherwise, the tilde-prefix is replaced with the home directory
3374 associated with the specified login name.
3375 <P>
3376
3377 If the tilde-prefix is a `~+', the value of the shell variable
3378 <FONT SIZE=-1><B>PWD</B>
3379
3380 </FONT>
3381 replaces the tilde-prefix.
3382 If the tilde-prefix is a `~-', the value of the shell variable
3383 <FONT SIZE=-1><B>OLDPWD</B>,
3384
3385 </FONT>
3386 if it is set, is substituted.
3387 If the characters following the tilde in the tilde-prefix consist
3388 of a number <I>N</I>, optionally prefixed
3389 by a `+' or a `-', the tilde-prefix is replaced with the corresponding
3390 element from the directory stack, as it would be displayed by the
3391 <B>dirs</B>
3392
3393 builtin invoked with the tilde-prefix as an argument.
3394 If the characters following the tilde in the tilde-prefix consist of a
3395 number without a leading `+' or `-', `+' is assumed.
3396 <P>
3397
3398 If the login name is invalid, or the tilde expansion fails, the word
3399 is unchanged.
3400 <P>
3401
3402 Each variable assignment is checked for unquoted tilde-prefixes immediately
3403 following a
3404 <B>:</B>
3405
3406 or the first
3407 <B>=</B>.
3408
3409 In these cases, tilde expansion is also performed.
3410 Consequently, one may use filenames with tildes in assignments to
3411 <FONT SIZE=-1><B>PATH</B>,
3412
3413 </FONT>
3414 <FONT SIZE=-1><B>MAILPATH</B>,
3415
3416 </FONT>
3417 and
3418 <FONT SIZE=-1><B>CDPATH</B>,
3419
3420 </FONT>
3421 and the shell assigns the expanded value.
3422 <A NAME="lbBB">&nbsp;</A>
3423 <H4>Parameter Expansion</H4>
3424
3425 <P>
3426
3427 The `<B>$</B>' character introduces parameter expansion,
3428 command substitution, or arithmetic expansion. The parameter name
3429 or symbol to be expanded may be enclosed in braces, which
3430 are optional but serve to protect the variable to be expanded from
3431 characters immediately following it which could be
3432 interpreted as part of the name.
3433 <P>
3434
3435 When braces are used, the matching ending brace is the first `<B>}</B>'
3436 not escaped by a backslash or within a quoted string, and not within an
3437 embedded arithmetic expansion, command substitution, or parameter
3438 expansion.
3439 <P>
3440
3441
3442 <DL COMPACT>
3443 <DT>${<I>parameter</I>}<DD>
3444 The value of <I>parameter</I> is substituted. The braces are required
3445 when
3446 <I>parameter</I>
3447
3448 is a positional parameter with more than one digit,
3449 or when
3450 <I>parameter</I>
3451
3452 is followed by a character which is not to be
3453 interpreted as part of its name.
3454
3455 </DL>
3456 <P>
3457
3458 If the first character of <I>parameter</I> is an exclamation point (<B>!</B>),
3459 a level of variable indirection is introduced.
3460 <B>Bash</B> uses the value of the variable formed from the rest of
3461 <I>parameter</I> as the name of the variable; this variable is then
3462 expanded and that value is used in the rest of the substitution, rather
3463 than the value of <I>parameter</I> itself.
3464 This is known as <I>indirect expansion</I>.
3465 The exceptions to this are the expansions of ${<B>!</B><I>prefix</I><B>*</B>} and
3466 ${<B>!</B><I>name</I>[<I>@</I>]} described below.
3467 The exclamation point must immediately follow the left brace in order to
3468 introduce indirection.
3469 <P>
3470
3471 In each of the cases below, <I>word</I> is subject to tilde expansion,
3472 parameter expansion, command substitution, and arithmetic expansion.
3473 <P>
3474
3475 When not performing substring expansion, using the forms documented below,
3476 <B>bash</B> tests for a parameter that is unset or null. Omitting the colon
3477 results in a test only for a parameter that is unset.
3478 <P>
3479
3480
3481 <DL COMPACT>
3482 <DT>${<I>parameter</I><B>:-</B><I>word</I>}<DD>
3483 <B>Use Default Values</B>. If
3484 <I>parameter</I>
3485
3486 is unset or null, the expansion of
3487 <I>word</I>
3488
3489 is substituted. Otherwise, the value of
3490 <I>parameter</I>
3491
3492 is substituted.
3493 <DT>${<I>parameter</I><B>:=</B><I>word</I>}<DD>
3494 <B>Assign Default Values</B>.
3495 If
3496 <I>parameter</I>
3497
3498 is unset or null, the expansion of
3499 <I>word</I>
3500
3501 is assigned to
3502 <I>parameter</I>.
3503
3504 The value of
3505 <I>parameter</I>
3506
3507 is then substituted. Positional parameters and special parameters may
3508 not be assigned to in this way.
3509 <DT>${<I>parameter</I><B>:?</B><I>word</I>}<DD>
3510 <B>Display Error if Null or Unset</B>.
3511 If
3512 <I>parameter</I>
3513
3514 is null or unset, the expansion of <I>word</I> (or a message to that effect
3515 if
3516 <I>word</I>
3517
3518 is not present) is written to the standard error and the shell, if it
3519 is not interactive, exits. Otherwise, the value of <I>parameter</I> is
3520 substituted.
3521 <DT>${<I>parameter</I><B>:+</B><I>word</I>}<DD>
3522 <B>Use Alternate Value</B>.
3523 If
3524 <I>parameter</I>
3525
3526 is null or unset, nothing is substituted, otherwise the expansion of
3527 <I>word</I>
3528
3529 is substituted.
3530 <DT>${<I>parameter</I><B>:</B><I>offset</I>}<DD>
3531
3532 <DT>${<I>parameter</I><B>:</B><I>offset</I><B>:</B><I>length</I>}<DD>
3533
3534 <B>Substring Expansion</B>.
3535 Expands to up to <I>length</I> characters of <I>parameter</I>
3536 starting at the character specified by <I>offset</I>.
3537 If <I>length</I> is omitted, expands to the substring of
3538 <I>parameter</I> starting at the character specified by <I>offset</I>.
3539 <I>length</I> and <I>offset</I> are arithmetic expressions (see
3540 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
3541
3542 </FONT>
3543 below).
3544 If <I>offset</I> evaluates to a number less than zero, the value
3545 is used as an offset from the end of the value of <I>parameter</I>.
3546 If <I>length</I> evaluates to a number less than zero, and <I>parameter</I>
3547 is not <B>@</B> and not an indexed or associative array, it is interpreted
3548 as an offset from the end of the value of <I>parameter</I> rather than
3549 a number of characters, and the expansion is the characters between the
3550 two offsets.
3551 If <I>parameter</I> is <B>@</B>, the result is <I>length</I> positional
3552 parameters beginning at <I>offset</I>.
3553 If <I>parameter</I> is an indexed array name subscripted by @ or *,
3554 the result is the <I>length</I>
3555 members of the array beginning with ${<I>parameter</I>[<I>offset</I>]}.
3556 A negative <I>offset</I> is taken relative to one greater than the maximum
3557 index of the specified array.
3558 Substring expansion applied to an associative array produces undefined
3559 results.
3560 Note that a negative offset must be separated from the colon by at least
3561 one space to avoid being confused with the :- expansion.
3562 Substring indexing is zero-based unless the positional parameters
3563 are used, in which case the indexing starts at 1 by default.
3564 If <I>offset</I> is 0, and the positional parameters are used, <B>$0</B> is
3565 prefixed to the list.
3566 <DT>${<B>!</B><I>prefix</I><B>*</B>}<DD>
3567
3568 <DT>${<B>!</B><I>prefix</I><B>@</B>}<DD>
3569
3570 <B>Names matching prefix</B>.
3571 Expands to the names of variables whose names begin with <I>prefix</I>,
3572 separated by the first character of the
3573 <FONT SIZE=-1><B>IFS</B>
3574
3575 </FONT>
3576 special variable.
3577 When <I>@</I> is used and the expansion appears within double quotes, each
3578 variable name expands to a separate word.
3579 <DT>${<B>!</B><I>name</I>[<I>@</I>]}<DD>
3580
3581 <DT>${<B>!</B><I>name</I>[<I>*</I>]}<DD>
3582
3583 <B>List of array keys</B>.
3584 If <I>name</I> is an array variable, expands to the list of array indices
3585 (keys) assigned in <I>name</I>.
3586 If <I>name</I> is not an array, expands to 0 if <I>name</I> is set and null
3587 otherwise.
3588 When <I>@</I> is used and the expansion appears within double quotes, each
3589 key expands to a separate word.
3590 <DT>${<B>#</B><I>parameter</I>}<DD>
3591 <B>Parameter length</B>.
3592 The length in characters of the value of <I>parameter</I> is substituted.
3593 If
3594 <I>parameter</I>
3595
3596 is
3597 <B>*</B>
3598
3599 or
3600 <B>@</B>,
3601
3602 the value substituted is the number of positional parameters.
3603 If
3604 <I>parameter</I>
3605
3606 is an array name subscripted by
3607 <B>*</B>
3608
3609 or
3610 <B>@</B>,
3611
3612 the value substituted is the number of elements in the array.
3613 <DT>${<I>parameter</I><B>#</B><I>word</I>}<DD>
3614
3615 <DT>${<I>parameter</I><B>##</B><I>word</I>}<DD>
3616
3617 <B>Remove matching prefix pattern</B>.
3618 The
3619 <I>word</I>
3620
3621 is expanded to produce a pattern just as in pathname
3622 expansion. If the pattern matches the beginning of
3623 the value of
3624 <I>parameter</I>,
3625
3626 then the result of the expansion is the expanded value of
3627 <I>parameter</I>
3628
3629 with the shortest matching pattern (the ``<B>#</B>'' case) or the
3630 longest matching pattern (the ``<B>##</B>'' case) deleted.
3631 If
3632 <I>parameter</I>
3633
3634 is
3635 <B>@</B>
3636
3637 or
3638 <B>*</B>,
3639
3640 the pattern removal operation is applied to each positional
3641 parameter in turn, and the expansion is the resultant list.
3642 If
3643 <I>parameter</I>
3644
3645 is an array variable subscripted with
3646 <B>@</B>
3647
3648 or
3649 <B>*</B>,
3650
3651 the pattern removal operation is applied to each member of the
3652 array in turn, and the expansion is the resultant list.
3653 <DT>${<I>parameter</I><B>%</B><I>word</I>}<DD>
3654
3655 <DT>${<I>parameter</I><B>%%</B><I>word</I>}<DD>
3656
3657 <B>Remove matching suffix pattern</B>.
3658 The <I>word</I> is expanded to produce a pattern just as in
3659 pathname expansion.
3660 If the pattern matches a trailing portion of the expanded value of
3661 <I>parameter</I>,
3662
3663 then the result of the expansion is the expanded value of
3664 <I>parameter</I>
3665
3666 with the shortest matching pattern (the ``<B>%</B>'' case) or the
3667 longest matching pattern (the ``<B>%%</B>'' case) deleted.
3668 If
3669 <I>parameter</I>
3670
3671 is
3672 <B>@</B>
3673
3674 or
3675 <B>*</B>,
3676
3677 the pattern removal operation is applied to each positional
3678 parameter in turn, and the expansion is the resultant list.
3679 If
3680 <I>parameter</I>
3681
3682 is an array variable subscripted with
3683 <B>@</B>
3684
3685 or
3686 <B>*</B>,
3687
3688 the pattern removal operation is applied to each member of the
3689 array in turn, and the expansion is the resultant list.
3690 <DT>${<I>parameter</I><B>/</B><I>pattern</I><B>/</B><I>string</I>}<DD>
3691 <B>Pattern substitution</B>.
3692 The <I>pattern</I> is expanded to produce a pattern just as in
3693 pathname expansion.
3694 <I>Parameter</I> is expanded and the longest match of <I>pattern</I>
3695 against its value is replaced with <I>string</I>.
3696 If <I>pattern</I> begins with <B>/</B>, all matches of <I>pattern</I> are
3697 replaced with <I>string</I>. Normally only the first match is replaced.
3698 If <I>pattern</I> begins with <B>#</B>, it must match at the beginning
3699 of the expanded value of <I>parameter</I>.
3700 If <I>pattern</I> begins with <B>%</B>, it must match at the end
3701 of the expanded value of <I>parameter</I>.
3702 If <I>string</I> is null, matches of <I>pattern</I> are deleted
3703 and the <B>/</B> following <I>pattern</I> may be omitted.
3704 If
3705 <I>parameter</I>
3706
3707 is
3708 <B>@</B>
3709
3710 or
3711 <B>*</B>,
3712
3713 the substitution operation is applied to each positional
3714 parameter in turn, and the expansion is the resultant list.
3715 If
3716 <I>parameter</I>
3717
3718 is an array variable subscripted with
3719 <B>@</B>
3720
3721 or
3722 <B>*</B>,
3723
3724 the substitution operation is applied to each member of the
3725 array in turn, and the expansion is the resultant list.
3726 <DT>${<I>parameter</I><B>^</B><I>pattern</I>}<DD>
3727
3728 <DT>${<I>parameter</I><B>^^</B><I>pattern</I>}<DD>
3729 <DT>${<I>parameter</I><B>,</B><I>pattern</I>}<DD>
3730 <DT>${<I>parameter</I><B>,,</B><I>pattern</I>}<DD>
3731
3732 <B>Case modification</B>.
3733 This expansion modifies the case of alphabetic characters in <I>parameter</I>.
3734 The <I>pattern</I> is expanded to produce a pattern just as in
3735 pathname expansion.
3736 Each character in the expanded value of <I>parameter</I> is tested against
3737 <I>pattern</I>, and, if it matches the pattern, its case is converted.
3738 The pattern should not attempt to match more than one character.
3739 The <B>^</B> operator converts lowercase letters matching <I>pattern</I>
3740 to uppercase; the <B>,</B> operator converts matching uppercase letters
3741 to lowercase.
3742 The <B>^^</B> and <B>,,</B> expansions convert each matched character in the
3743 expanded value; the <B>^</B> and <B>,</B> expansions match and convert only
3744 the first character in the expanded value.
3745 If <I>pattern</I> is omitted, it is treated like a <B>?</B>, which matches
3746 every character.
3747 If
3748 <I>parameter</I>
3749
3750 is
3751 <B>@</B>
3752
3753 or
3754 <B>*</B>,
3755
3756 the case modification operation is applied to each positional
3757 parameter in turn, and the expansion is the resultant list.
3758 If
3759 <I>parameter</I>
3760
3761 is an array variable subscripted with
3762 <B>@</B>
3763
3764 or
3765 <B>*</B>,
3766
3767 the case modification operation is applied to each member of the
3768 array in turn, and the expansion is the resultant list.
3769 </DL>
3770 <A NAME="lbBC">&nbsp;</A>
3771 <H4>Command Substitution</H4>
3772
3773 <P>
3774
3775 <I>Command substitution</I> allows the output of a command to replace
3776 the command name. There are two forms:
3777 <DL COMPACT><DT><DD>
3778 <P>
3779
3780 <B>$(</B><I>command</I><B>)</B>
3781 </DL>
3782
3783 or
3784 <DL COMPACT><DT><DD>
3785 <B>`</B><I>command</I><B>`</B>
3786 </DL>
3787
3788 <P>
3789
3790 <B>Bash</B>
3791
3792 performs the expansion by executing <I>command</I> and
3793 replacing the command substitution with the standard output of the
3794 command, with any trailing newlines deleted.
3795 Embedded newlines are not deleted, but they may be removed during
3796 word splitting.
3797 The command substitution <B>$(cat </B><I>file</I>) can be replaced by
3798 the equivalent but faster <B>$(&lt; </B><I>file</I>).
3799 <P>
3800
3801 When the old-style backquote form of substitution is used,
3802 backslash retains its literal meaning except when followed by
3803 <B>$</B>,
3804
3805 <B>`</B>,
3806
3807 or
3808 <B>\</B>.
3809
3810 The first backquote not preceded by a backslash terminates the
3811 command substitution.
3812 When using the $(<I>command</I>) form, all characters between the
3813 parentheses make up the command; none are treated specially.
3814 <P>
3815
3816 Command substitutions may be nested. To nest when using the backquoted form,
3817 escape the inner backquotes with backslashes.
3818 <P>
3819
3820 If the substitution appears within double quotes, word splitting and
3821 pathname expansion are not performed on the results.
3822 <A NAME="lbBD">&nbsp;</A>
3823 <H4>Arithmetic Expansion</H4>
3824
3825 <P>
3826
3827 Arithmetic expansion allows the evaluation of an arithmetic expression
3828 and the substitution of the result. The format for arithmetic expansion is:
3829 <DL COMPACT><DT><DD>
3830 <P>
3831
3832 <B>$((</B><I>expression</I><B>))</B>
3833 </DL>
3834
3835 <P>
3836
3837 The
3838 <I>expression</I>
3839
3840 is treated as if it were within double quotes, but a double quote
3841 inside the parentheses is not treated specially.
3842 All tokens in the expression undergo parameter expansion, string
3843 expansion, command substitution, and quote removal.
3844 Arithmetic expansions may be nested.
3845 <P>
3846
3847 The evaluation is performed according to the rules listed below under
3848 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
3849
3850 </FONT>
3851 If
3852 <I>expression</I>
3853
3854 is invalid,
3855 <B>bash</B>
3856
3857 prints a message indicating failure and no substitution occurs.
3858 <A NAME="lbBE">&nbsp;</A>
3859 <H4>Process Substitution</H4>
3860
3861 <P>
3862
3863 <I>Process substitution</I> is supported on systems that support named
3864 pipes (<I>FIFOs</I>) or the <B>/dev/fd</B> method of naming open files.
3865 It takes the form of
3866 <B>&lt;(</B><I>list</I><B>)</B>
3867 or
3868 <B>&gt;(</B><I>list</I><B>)</B>.
3869 The process <I>list</I> is run with its input or output connected to a
3870 <I>FIFO</I> or some file in <B>/dev/fd</B>. The name of this file is
3871 passed as an argument to the current command as the result of the
3872 expansion. If the <B>&gt;(</B><I>list</I><B>)</B> form is used, writing to
3873 the file will provide input for <I>list</I>. If the
3874 <B>&lt;(</B><I>list</I><B>)</B> form is used, the file passed as an
3875 argument should be read to obtain the output of <I>list</I>.
3876 <P>
3877
3878 When available, process substitution is performed
3879 simultaneously with parameter and variable expansion,
3880 command substitution,
3881 and arithmetic expansion.
3882 <A NAME="lbBF">&nbsp;</A>
3883 <H4>Word Splitting</H4>
3884
3885 <P>
3886
3887 The shell scans the results of
3888 parameter expansion,
3889 command substitution,
3890 and
3891 arithmetic expansion
3892 that did not occur within double quotes for
3893 <I>word splitting</I>.
3894
3895 <P>
3896
3897 The shell treats each character of
3898 <FONT SIZE=-1><B>IFS</B>
3899
3900 </FONT>
3901 as a delimiter, and splits the results of the other
3902 expansions into words on these characters. If
3903 <FONT SIZE=-1><B>IFS</B>
3904
3905 </FONT>
3906 is unset, or its
3907 value is exactly
3908 <B>&lt;space&gt;&lt;tab&gt;&lt;newline&gt;</B>,
3909
3910 the default, then
3911 sequences of
3912 <B>&lt;space&gt;</B>,
3913
3914 <B>&lt;tab&gt;</B>,
3915
3916 and
3917 <B>&lt;newline&gt;</B>
3918
3919 at the beginning and end of the results of the previous
3920 expansions are ignored, and
3921 any sequence of
3922 <FONT SIZE=-1><B>IFS</B>
3923
3924 </FONT>
3925 characters not at the beginning or end serves to delimit words.
3926 If
3927 <FONT SIZE=-1><B>IFS</B>
3928
3929 </FONT>
3930 has a value other than the default, then sequences of
3931 the whitespace characters
3932 <B>space</B>
3933
3934 and
3935 <B>tab</B>
3936
3937 are ignored at the beginning and end of the
3938 word, as long as the whitespace character is in the
3939 value of
3940 <FONT SIZE=-1><B>IFS</B>
3941
3942 </FONT>
3943 (an
3944 <FONT SIZE=-1><B>IFS</B>
3945
3946 </FONT>
3947 whitespace character).
3948 Any character in
3949 <FONT SIZE=-1><B>IFS</B>
3950
3951 </FONT>
3952 that is not
3953 <FONT SIZE=-1><B>IFS</B>
3954
3955 </FONT>
3956 whitespace, along with any adjacent
3957 <FONT SIZE=-1><B>IFS</B>
3958
3959 </FONT>
3960 whitespace characters, delimits a field.
3961 A sequence of
3962 <FONT SIZE=-1><B>IFS</B>
3963
3964 </FONT>
3965 whitespace characters is also treated as a delimiter.
3966 If the value of
3967 <FONT SIZE=-1><B>IFS</B>
3968
3969 </FONT>
3970 is null, no word splitting occurs.
3971 <P>
3972
3973 Explicit null arguments (<B>&quot;&quot;</B> or <B>aqaq</B>) are retained.
3974 Unquoted implicit null arguments, resulting from the expansion of
3975 parameters that have no values, are removed.
3976 If a parameter with no value is expanded within double quotes, a
3977 null argument results and is retained.
3978 <P>
3979
3980 Note that if no expansion occurs, no splitting
3981 is performed.
3982 <A NAME="lbBG">&nbsp;</A>
3983 <H4>Pathname Expansion</H4>
3984
3985 <P>
3986
3987 After word splitting,
3988 unless the
3989 <B>-f</B>
3990
3991 option has been set,
3992 <B>bash</B>
3993
3994 scans each word for the characters
3995 <B>*</B>,
3996
3997 <B>?</B>,
3998
3999 and
4000 <B>[</B>.
4001
4002 If one of these characters appears, then the word is
4003 regarded as a
4004 <I>pattern</I>,
4005
4006 and replaced with an alphabetically sorted list of
4007 filenames matching the pattern
4008 (see
4009 <FONT SIZE=-1><B>Pattern Matching</B>
4010
4011 </FONT>
4012 below).
4013 If no matching filenames are found,
4014 and the shell option
4015 <B>nullglob</B>
4016
4017 is not enabled, the word is left unchanged.
4018 If the
4019 <B>nullglob</B>
4020
4021 option is set, and no matches are found,
4022 the word is removed.
4023 If the
4024 <B>failglob</B>
4025
4026 shell option is set, and no matches are found, an error message
4027 is printed and the command is not executed.
4028 If the shell option
4029 <B>nocaseglob</B>
4030
4031 is enabled, the match is performed without regard to the case
4032 of alphabetic characters.
4033 When a pattern is used for pathname expansion,
4034 the character
4035 <B>``.''</B>
4036
4037 at the start of a name or immediately following a slash
4038 must be matched explicitly, unless the shell option
4039 <B>dotglob</B>
4040
4041 is set.
4042 When matching a pathname, the slash character must always be
4043 matched explicitly.
4044 In other cases, the
4045 <B>``.''</B>
4046
4047 character is not treated specially.
4048 See the description of
4049 <B>shopt</B>
4050
4051 below under
4052 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
4053
4054 </FONT>
4055 for a description of the
4056 <B>nocaseglob</B>,
4057
4058 <B>nullglob</B>,
4059
4060 <B>failglob</B>,
4061
4062 and
4063 <B>dotglob</B>
4064
4065 shell options.
4066 <P>
4067
4068 The
4069 <FONT SIZE=-1><B>GLOBIGNORE</B>
4070
4071 </FONT>
4072 shell variable may be used to restrict the set of filenames matching a
4073 <I>pattern</I>.
4074
4075 If
4076 <FONT SIZE=-1><B>GLOBIGNORE</B>
4077
4078 </FONT>
4079 is set, each matching filename that also matches one of the patterns in
4080 <FONT SIZE=-1><B>GLOBIGNORE</B>
4081
4082 </FONT>
4083 is removed from the list of matches.
4084 The filenames
4085 <B>``.''</B>
4086
4087 and
4088 <B>``..''</B>
4089
4090 are always ignored when
4091 <FONT SIZE=-1><B>GLOBIGNORE</B>
4092
4093 </FONT>
4094 is set and not null. However, setting
4095 <FONT SIZE=-1><B>GLOBIGNORE</B>
4096
4097 </FONT>
4098 to a non-null value has the effect of enabling the
4099 <B>dotglob</B>
4100
4101 shell option, so all other filenames beginning with a
4102 <B>``.''</B>
4103
4104 will match.
4105 To get the old behavior of ignoring filenames beginning with a
4106 <B>``.''</B>,
4107
4108 make
4109 <B>``.*''</B>
4110
4111 one of the patterns in
4112 <FONT SIZE=-1><B>GLOBIGNORE</B>.
4113
4114 </FONT>
4115 The
4116 <B>dotglob</B>
4117
4118 option is disabled when
4119 <FONT SIZE=-1><B>GLOBIGNORE</B>
4120
4121 </FONT>
4122 is unset.
4123 <P>
4124
4125 <B>Pattern Matching</B>
4126 <P>
4127
4128 Any character that appears in a pattern, other than the special pattern
4129 characters described below, matches itself. The NUL character may not
4130 occur in a pattern. A backslash escapes the following character; the
4131 escaping backslash is discarded when matching.
4132 The special pattern characters must be quoted if
4133 they are to be matched literally.
4134 <P>
4135
4136 The special pattern characters have the following meanings:
4137 <P>
4138
4139
4140 <DL COMPACT><DT><DD>
4141 <DL COMPACT>
4142 <DT><B>*</B>
4143
4144 <DD>
4145 Matches any string, including the null string.
4146 When the <B>globstar</B> shell option is enabled, and <B>*</B> is used in
4147 a pathname expansion context, two adjacent <B>*</B>s used as a single
4148 pattern will match all files and zero or more directories and
4149 subdirectories.
4150 If followed by a <B>/</B>, two adjacent <B>*</B>s will match only directories
4151 and subdirectories.
4152 <DT><B>?</B>
4153
4154 <DD>
4155 Matches any single character.
4156 <DT><B>[...]</B>
4157
4158 <DD>
4159 Matches any one of the enclosed characters. A pair of characters
4160 separated by a hyphen denotes a
4161 <I>range expression</I>;
4162 any character that sorts between those two characters, inclusive,
4163 using the current locale's collating sequence and character set,
4164 is matched. If the first character following the
4165 <B>[</B>
4166
4167 is a
4168 <B>!</B>
4169
4170 or a
4171 <B>^</B>
4172
4173 then any character not enclosed is matched.
4174 The sorting order of characters in range expressions is determined by
4175 the current locale and the values of the
4176 <FONT SIZE=-1><B>LC_COLLATE</B>
4177
4178 </FONT>
4179 or
4180 <FONT SIZE=-1><B>LC_ALL</B>
4181
4182 </FONT>
4183 shell variables, if set.
4184 To obtain the traditional interpretation of range expressions, where
4185 <B>[a-d]</B>
4186
4187 is equivalent to
4188 <B>[abcd]</B>,
4189
4190 set value of the
4191 <B>LC_ALL</B>
4192
4193 shell variable to
4194 <B>C</B>,
4195
4196 or enable the
4197 <B>globasciiranges</B>
4198
4199 shell option.
4200 A
4201 <B>-</B>
4202
4203 may be matched by including it as the first or last character
4204 in the set.
4205 A
4206 <B>]</B>
4207
4208 may be matched by including it as the first character
4209 in the set.
4210 <BR>
4211
4212 <P>
4213
4214
4215 Within
4216 <B>[</B>
4217
4218 and
4219 <B>]</B>,
4220
4221 <I>character classes</I> can be specified using the syntax
4222 <B>[:</B><I>class</I><B>:]</B>, where <I>class</I> is one of the
4223 following classes defined in the POSIX standard:
4224 </DL>
4225 <P>
4226
4227 <DL COMPACT><DT><DD>
4228 <B>
4229 </B>
4230
4231 alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
4232 <BR>
4233
4234 A character class matches any character belonging to that class.
4235 The <B>word</B> character class matches letters, digits, and the character _.
4236 <BR>
4237
4238 <P>
4239
4240
4241 Within
4242 <B>[</B>
4243
4244 and
4245 <B>]</B>,
4246
4247 an <I>equivalence class</I> can be specified using the syntax
4248 <B>[=</B><I>c</I><B>=]</B>, which matches all characters with the
4249 same collation weight (as defined by the current locale) as
4250 the character <I>c</I>.
4251 <BR>
4252
4253 <P>
4254
4255
4256 Within
4257 <B>[</B>
4258
4259 and
4260 <B>]</B>,
4261
4262 the syntax <B>[.</B><I>symbol</I><B>.]</B> matches the collating symbol
4263 <I>symbol</I>.
4264 </DL>
4265
4266 </DL>
4267
4268
4269 <P>
4270
4271 If the <B>extglob</B> shell option is enabled using the <B>shopt</B>
4272 builtin, several extended pattern matching operators are recognized.
4273 In the following description, a <I>pattern-list</I> is a list of one
4274 or more patterns separated by a <B>|</B>.
4275 Composite patterns may be formed using one or more of the following
4276 sub-patterns:
4277 <P>
4278
4279 <DL COMPACT><DT><DD>
4280 <DL COMPACT>
4281 <DT><B>?(</B><I>pattern-list</I><B>)</B><DD>
4282 Matches zero or one occurrence of the given patterns
4283 <DT><B>*(</B><I>pattern-list</I><B>)</B><DD>
4284 Matches zero or more occurrences of the given patterns
4285 <DT><B>+(</B><I>pattern-list</I><B>)</B><DD>
4286 Matches one or more occurrences of the given patterns
4287 <DT><B>@(</B><I>pattern-list</I><B>)</B><DD>
4288 Matches one of the given patterns
4289 <DT><B>!(</B><I>pattern-list</I><B>)</B><DD>
4290 Matches anything except one of the given patterns
4291 </DL></DL>
4292
4293
4294 <A NAME="lbBH">&nbsp;</A>
4295 <H4>Quote Removal</H4>
4296
4297 <P>
4298
4299 After the preceding expansions, all unquoted occurrences of the
4300 characters
4301 <B>\</B>,
4302
4303 <B>aq</B>,
4304
4305 and <B>&quot;</B> that did not result from one of the above
4306 expansions are removed.
4307 <A NAME="lbBI">&nbsp;</A>
4308 <H3>REDIRECTION</H3>
4309
4310 Before a command is executed, its input and output
4311 may be
4312 <I>redirected</I>
4313
4314 using a special notation interpreted by the shell.
4315 Redirection allows commands' file handles to be
4316 duplicated, opened, closed,
4317 made to refer to different files,
4318 and can change the files the command reads from and writes to.
4319 Redirection may also be used to modify file handles in the
4320 current shell execution environment.
4321 The following redirection
4322 operators may precede or appear anywhere within a
4323 <I>simple command</I>
4324
4325 or may follow a
4326 <I>command</I>.
4327
4328 Redirections are processed in the order they appear, from
4329 left to right.
4330 <P>
4331
4332 Each redirection that may be preceded by a file descriptor number
4333 may instead be preceded by a word of the form {<I>varname</I>}.
4334 In this case, for each redirection operator except
4335 &gt;&amp;- and &lt;&amp;-, the shell will allocate a file descriptor greater
4336 than or equal to 10 and assign it to <I>varname</I>.
4337 If &gt;&amp;- or &lt;&amp;- is preceded
4338 by {<I>varname</I>}, the value of <I>varname</I> defines the file
4339 descriptor to close.
4340 <P>
4341
4342 In the following descriptions, if the file descriptor number is
4343 omitted, and the first character of the redirection operator is
4344 <B>&lt;</B>,
4345
4346 the redirection refers to the standard input (file descriptor
4347 0). If the first character of the redirection operator is
4348 <B>&gt;</B>,
4349
4350 the redirection refers to the standard output (file descriptor
4351 1).
4352 <P>
4353
4354 The word following the redirection operator in the following
4355 descriptions, unless otherwise noted, is subjected to
4356 brace expansion, tilde expansion, parameter and variable expansion,
4357 command substitution, arithmetic expansion, quote removal,
4358 pathname expansion, and word splitting.
4359 If it expands to more than one word,
4360 <B>bash</B>
4361
4362 reports an error.
4363 <P>
4364
4365 Note that the order of redirections is significant. For example,
4366 the command
4367 <DL COMPACT><DT><DD>
4368 <P>
4369
4370 ls <B>&gt;</B> dirlist 2<B>&gt;&amp;</B>1
4371 </DL>
4372
4373 <P>
4374
4375 directs both standard output and standard error to the file
4376 <I>dirlist</I>,
4377
4378 while the command
4379 <DL COMPACT><DT><DD>
4380 <P>
4381
4382 ls 2<B>&gt;&amp;</B>1 <B>&gt;</B> dirlist
4383 </DL>
4384
4385 <P>
4386
4387 directs only the standard output to file
4388 <I>dirlist</I>,
4389
4390 because the standard error was duplicated from the standard output
4391 before the standard output was redirected to
4392 <I>dirlist</I>.
4393
4394 <P>
4395
4396 <B>Bash</B> handles several filenames specially when they are used in
4397 redirections, as described in the following table:
4398 <DL COMPACT><DT><DD>
4399 <P>
4400
4401
4402 <DL COMPACT>
4403 <DT><B>/dev/fd/</B><I>fd</I>
4404
4405 <DD>
4406 If <I>fd</I> is a valid integer, file descriptor <I>fd</I> is duplicated.
4407 <DT><B>/dev/stdin</B>
4408
4409 <DD>
4410 File descriptor 0 is duplicated.
4411 <DT><B>/dev/stdout</B>
4412
4413 <DD>
4414 File descriptor 1 is duplicated.
4415 <DT><B>/dev/stderr</B>
4416
4417 <DD>
4418 File descriptor 2 is duplicated.
4419 <DT><B>/dev/tcp/</B><I>host</I>/<I>port</I>
4420
4421 <DD>
4422 If <I>host</I> is a valid hostname or Internet address, and <I>port</I>
4423 is an integer port number or service name, <B>bash</B> attempts to open
4424 a TCP connection to the corresponding socket.
4425 <DT><B>/dev/udp/</B><I>host</I>/<I>port</I>
4426
4427 <DD>
4428 If <I>host</I> is a valid hostname or Internet address, and <I>port</I>
4429 is an integer port number or service name, <B>bash</B> attempts to open
4430 a UDP connection to the corresponding socket.
4431
4432 </DL></DL>
4433
4434 <P>
4435
4436 A failure to open or create a file causes the redirection to fail.
4437 <P>
4438
4439 Redirections using file descriptors greater than 9 should be used with
4440 care, as they may conflict with file descriptors the shell uses
4441 internally.
4442 <A NAME="lbBJ">&nbsp;</A>
4443 <H4>Redirecting Input</H4>
4444
4445 <P>
4446
4447 Redirection of input causes the file whose name results from
4448 the expansion of
4449 <I>word</I>
4450
4451 to be opened for reading on file descriptor
4452 <I>n</I>,
4453
4454 or the standard input (file descriptor 0) if
4455 <I>n</I>
4456
4457 is not specified.
4458 <P>
4459
4460 The general format for redirecting input is:
4461 <DL COMPACT><DT><DD>
4462 <P>
4463
4464 [<I>n</I>]<B>&lt;</B><I>word</I>
4465 </DL>
4466
4467 <A NAME="lbBK">&nbsp;</A>
4468 <H4>Redirecting Output</H4>
4469
4470 <P>
4471
4472 Redirection of output causes the file whose name results from
4473 the expansion of
4474 <I>word</I>
4475
4476 to be opened for writing on file descriptor
4477 <I>n</I>,
4478
4479 or the standard output (file descriptor 1) if
4480 <I>n</I>
4481
4482 is not specified. If the file does not exist it is created;
4483 if it does exist it is truncated to zero size.
4484 <P>
4485
4486 The general format for redirecting output is:
4487 <DL COMPACT><DT><DD>
4488 <P>
4489
4490 [<I>n</I>]<B>&gt;</B><I>word</I>
4491 </DL>
4492
4493 <P>
4494
4495 If the redirection operator is
4496 <B>&gt;</B>,
4497
4498 and the
4499 <B>noclobber</B>
4500
4501 option to the
4502 <B>set</B>
4503
4504 builtin has been enabled, the redirection will fail if the file
4505 whose name results from the expansion of <I>word</I> exists and is
4506 a regular file.
4507 If the redirection operator is
4508 <B>&gt;|</B>,
4509
4510 or the redirection operator is
4511 <B>&gt;</B>
4512
4513 and the
4514 <B>noclobber</B>
4515
4516 option to the
4517 <B>set</B>
4518
4519 builtin command is not enabled, the redirection is attempted even
4520 if the file named by <I>word</I> exists.
4521 <A NAME="lbBL">&nbsp;</A>
4522 <H4>Appending Redirected Output</H4>
4523
4524 <P>
4525
4526 Redirection of output in this fashion
4527 causes the file whose name results from
4528 the expansion of
4529 <I>word</I>
4530
4531 to be opened for appending on file descriptor
4532 <I>n</I>,
4533
4534 or the standard output (file descriptor 1) if
4535 <I>n</I>
4536
4537 is not specified. If the file does not exist it is created.
4538 <P>
4539
4540 The general format for appending output is:
4541 <DL COMPACT><DT><DD>
4542 <P>
4543
4544 [<I>n</I>]<B>&gt;&gt;</B><I>word</I>
4545 </DL>
4546
4547 <P>
4548
4549 <A NAME="lbBM">&nbsp;</A>
4550 <H4>Redirecting Standard Output and Standard Error</H4>
4551
4552 <P>
4553
4554 This construct allows both the
4555 standard output (file descriptor 1) and
4556 the standard error output (file descriptor 2)
4557 to be redirected to the file whose name is the
4558 expansion of
4559 <I>word</I>.
4560
4561 <P>
4562
4563 There are two formats for redirecting standard output and
4564 standard error:
4565 <DL COMPACT><DT><DD>
4566 <P>
4567
4568 <B>&amp;&gt;</B><I>word</I>
4569 </DL>
4570
4571 and
4572 <DL COMPACT><DT><DD>
4573 <B>&gt;&amp;</B><I>word</I>
4574 </DL>
4575
4576 <P>
4577
4578 Of the two forms, the first is preferred.
4579 This is semantically equivalent to
4580 <DL COMPACT><DT><DD>
4581 <P>
4582
4583 <B>&gt;</B><I>word</I> 2<B>&gt;&amp;</B>1
4584 </DL>
4585
4586 <P>
4587
4588 When using the second form, <I>word</I> may not expand to a number or
4589 <B>-</B>. If it does, other redirection operators apply
4590 (see <B>Duplicating File Descriptors</B> below) for compatibility
4591 reasons.
4592 <A NAME="lbBN">&nbsp;</A>
4593 <H4>Appending Standard Output and Standard Error</H4>
4594
4595 <P>
4596
4597 This construct allows both the
4598 standard output (file descriptor 1) and
4599 the standard error output (file descriptor 2)
4600 to be appended to the file whose name is the
4601 expansion of
4602 <I>word</I>.
4603
4604 <P>
4605
4606 The format for appending standard output and standard error is:
4607 <DL COMPACT><DT><DD>
4608 <P>
4609
4610 <B>&amp;&gt;&gt;</B><I>word</I>
4611 </DL>
4612
4613 <P>
4614
4615 This is semantically equivalent to
4616 <DL COMPACT><DT><DD>
4617 <P>
4618
4619 <B>&gt;&gt;</B><I>word</I> 2<B>&gt;&amp;</B>1
4620 </DL>
4621
4622 <P>
4623
4624 (see <B>Duplicating File Descriptors</B> below).
4625 <A NAME="lbBO">&nbsp;</A>
4626 <H4>Here Documents</H4>
4627
4628 <P>
4629
4630 This type of redirection instructs the shell to read input from the
4631 current source until a line containing only
4632 <I>delimiter</I>
4633
4634 (with no trailing blanks)
4635 is seen. All of
4636 the lines read up to that point are then used as the standard
4637 input for a command.
4638 <P>
4639
4640 The format of here-documents is:
4641 <DL COMPACT><DT><DD>
4642 <P>
4643
4644 <PRE>
4645 <B>&lt;&lt;</B>[<B>-</B>]<I>word</I>
4646 <I>here-document</I>
4647 <I>delimiter</I>
4648 </PRE>
4649
4650 </DL>
4651
4652 <P>
4653
4654 No parameter and variable expansion, command substitution,
4655 arithmetic expansion, or pathname expansion is performed on
4656 <I>word</I>.
4657
4658 If any characters in
4659 <I>word</I>
4660
4661 are quoted, the
4662 <I>delimiter</I>
4663
4664 is the result of quote removal on
4665 <I>word</I>,
4666
4667 and the lines in the here-document are not expanded.
4668 If <I>word</I> is unquoted,
4669 all lines of the here-document are subjected to parameter expansion,
4670 command substitution, and arithmetic expansion. In the latter
4671 case, the character sequence
4672 <B>\&lt;newline&gt;</B>
4673
4674 is ignored, and
4675 <B>\</B>
4676
4677 must be used to quote the characters
4678 <B>\</B>,
4679
4680 <B>$</B>,
4681
4682 and
4683 <B>`</B>.
4684
4685 <P>
4686
4687 If the redirection operator is
4688 <B>&lt;&lt;-</B>,
4689
4690 then all leading tab characters are stripped from input lines and the
4691 line containing
4692 <I>delimiter</I>.
4693
4694 This allows
4695 here-documents within shell scripts to be indented in a
4696 natural fashion.
4697 <A NAME="lbBP">&nbsp;</A>
4698 <H4>Here Strings</H4>
4699
4700 A variant of here documents, the format is:
4701 <DL COMPACT><DT><DD>
4702 <P>
4703
4704 <PRE>
4705 <B>&lt;&lt;&lt;</B><I>word</I>
4706 </PRE>
4707
4708 </DL>
4709
4710 <P>
4711
4712 The <I>word</I> undergoes
4713 brace expansion, tilde expansion, parameter and variable expansion,
4714 command substitution, arithmetic expansion, and quote removal.
4715 Pathname expansion word splitting are not performed.
4716 The result is supplied as a single string to the command on its
4717 standard input.
4718 <A NAME="lbBQ">&nbsp;</A>
4719 <H4>Duplicating File Descriptors</H4>
4720
4721 <P>
4722
4723 The redirection operator
4724 <DL COMPACT><DT><DD>
4725 <P>
4726
4727 [<I>n</I>]<B>&lt;&amp;</B><I>word</I>
4728 </DL>
4729
4730 <P>
4731
4732 is used to duplicate input file descriptors.
4733 If
4734 <I>word</I>
4735
4736 expands to one or more digits, the file descriptor denoted by
4737 <I>n</I>
4738
4739 is made to be a copy of that file descriptor.
4740 If the digits in
4741 <I>word</I>
4742
4743 do not specify a file descriptor open for input, a redirection error occurs.
4744 If
4745 <I>word</I>
4746
4747 evaluates to
4748 <B>-</B>,
4749
4750 file descriptor
4751 <I>n</I>
4752
4753 is closed. If
4754 <I>n</I>
4755
4756 is not specified, the standard input (file descriptor 0) is used.
4757 <P>
4758
4759 The operator
4760 <DL COMPACT><DT><DD>
4761 <P>
4762
4763 [<I>n</I>]<B>&gt;&amp;</B><I>word</I>
4764 </DL>
4765
4766 <P>
4767
4768 is used similarly to duplicate output file descriptors. If
4769 <I>n</I>
4770
4771 is not specified, the standard output (file descriptor 1) is used.
4772 If the digits in
4773 <I>word</I>
4774
4775 do not specify a file descriptor open for output, a redirection error occurs.
4776 If
4777 <I>word</I>
4778
4779 evaluates to
4780 <B>-</B>,
4781
4782 file descriptor
4783 <I>n</I>
4784
4785 is closed.
4786 As a special case, if <I>n</I> is omitted, and <I>word</I> does not
4787 expand to one or more digits or <B>-</B>, the standard output and standard
4788 error are redirected as described previously.
4789 <A NAME="lbBR">&nbsp;</A>
4790 <H4>Moving File Descriptors</H4>
4791
4792 <P>
4793
4794 The redirection operator
4795 <DL COMPACT><DT><DD>
4796 <P>
4797
4798 [<I>n</I>]<B>&lt;&amp;</B><I>digit</I><B>-</B>
4799 </DL>
4800
4801 <P>
4802
4803 moves the file descriptor <I>digit</I> to file descriptor
4804 <I>n</I>,
4805
4806 or the standard input (file descriptor 0) if <I>n</I> is not specified.
4807 <I>digit</I> is closed after being duplicated to <I>n</I>.
4808 <P>
4809
4810 Similarly, the redirection operator
4811 <DL COMPACT><DT><DD>
4812 <P>
4813
4814 [<I>n</I>]<B>&gt;&amp;</B><I>digit</I><B>-</B>
4815 </DL>
4816
4817 <P>
4818
4819 moves the file descriptor <I>digit</I> to file descriptor
4820 <I>n</I>,
4821
4822 or the standard output (file descriptor 1) if <I>n</I> is not specified.
4823 <A NAME="lbBS">&nbsp;</A>
4824 <H4>Opening File Descriptors for Reading and Writing</H4>
4825
4826 <P>
4827
4828 The redirection operator
4829 <DL COMPACT><DT><DD>
4830 <P>
4831
4832 [<I>n</I>]<B>&lt;&gt;</B><I>word</I>
4833 </DL>
4834
4835 <P>
4836
4837 causes the file whose name is the expansion of
4838 <I>word</I>
4839
4840 to be opened for both reading and writing on file descriptor
4841 <I>n</I>,
4842
4843 or on file descriptor 0 if
4844 <I>n</I>
4845
4846 is not specified. If the file does not exist, it is created.
4847 <A NAME="lbBT">&nbsp;</A>
4848 <H3>ALIASES</H3>
4849
4850 <I>Aliases</I> allow a string to be substituted for a word when it is used
4851 as the first word of a simple command.
4852 The shell maintains a list of aliases that may be set and unset with the
4853 <B>alias</B>
4854
4855 and
4856 <B>unalias</B>
4857
4858 builtin commands (see
4859 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
4860
4861 </FONT>
4862 below).
4863 The first word of each simple command, if unquoted,
4864 is checked to see if it has an
4865 alias. If so, that word is replaced by the text of the alias.
4866 The characters <B>/</B>, <B>$</B>, <B>`</B>, and <B>=</B> and
4867 any of the shell <I>metacharacters</I> or quoting characters
4868 listed above may not appear in an alias name.
4869 The replacement text may contain any valid shell input,
4870 including shell metacharacters.
4871 The first word of the replacement text is tested
4872 for aliases, but a word that is identical to an alias being expanded
4873 is not expanded a second time.
4874 This means that one may alias
4875 <B>ls</B>
4876
4877 to
4878 <B>ls -F</B>,
4879
4880 for instance, and
4881 <B>bash</B>
4882
4883 does not try to recursively expand the replacement text.
4884 If the last character of the alias value is a
4885 <I>blank</I>,
4886
4887 then the next command
4888 word following the alias is also checked for alias expansion.
4889 <P>
4890
4891 Aliases are created and listed with the
4892 <B>alias</B>
4893
4894 command, and removed with the
4895 <B>unalias</B>
4896
4897 command.
4898 <P>
4899
4900 There is no mechanism for using arguments in the replacement text.
4901 If arguments are needed, a shell function should be used (see
4902 <FONT SIZE=-1><B>FUNCTIONS</B>
4903
4904 </FONT>
4905 below).
4906 <P>
4907
4908 Aliases are not expanded when the shell is not interactive, unless
4909 the
4910 <B>expand_aliases</B>
4911
4912 shell option is set using
4913 <B>shopt</B>
4914
4915 (see the description of
4916 <B>shopt</B>
4917
4918 under
4919 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B></FONT>
4920 below).
4921 <P>
4922
4923 The rules concerning the definition and use of aliases are
4924 somewhat confusing.
4925 <B>Bash</B>
4926
4927 always reads at least one complete line
4928 of input before executing any
4929 of the commands on that line. Aliases are expanded when a
4930 command is read, not when it is executed. Therefore, an
4931 alias definition appearing on the same line as another
4932 command does not take effect until the next line of input is read.
4933 The commands following the alias definition
4934 on that line are not affected by the new alias.
4935 This behavior is also an issue when functions are executed.
4936 Aliases are expanded when a function definition is read,
4937 not when the function is executed, because a function definition
4938 is itself a compound command. As a consequence, aliases
4939 defined in a function are not available until after that
4940 function is executed. To be safe, always put
4941 alias definitions on a separate line, and do not use
4942 <B>alias</B>
4943
4944 in compound commands.
4945 <P>
4946
4947 For almost every purpose, aliases are superseded by
4948 shell functions.
4949 <A NAME="lbBU">&nbsp;</A>
4950 <H3>FUNCTIONS</H3>
4951
4952 A shell function, defined as described above under
4953 <FONT SIZE=-1><B>SHELL GRAMMAR</B>,
4954
4955 </FONT>
4956 stores a series of commands for later execution.
4957 When the name of a shell function is used as a simple command name,
4958 the list of commands associated with that function name is executed.
4959 Functions are executed in the context of the
4960 current shell; no new process is created to interpret
4961 them (contrast this with the execution of a shell script).
4962 When a function is executed, the arguments to the
4963 function become the positional parameters
4964 during its execution.
4965 The special parameter
4966 <B>#</B>
4967
4968 is updated to reflect the change. Special parameter <B>0</B>
4969 is unchanged.
4970 The first element of the
4971 <FONT SIZE=-1><B>FUNCNAME</B>
4972
4973 </FONT>
4974 variable is set to the name of the function while the function
4975 is executing.
4976 <P>
4977
4978 All other aspects of the shell execution
4979 environment are identical between a function and its caller
4980 with these exceptions: the
4981 <FONT SIZE=-1><B>DEBUG</B>
4982
4983 </FONT>
4984 and
4985 <B>RETURN</B>
4986
4987 traps (see the description of the
4988 <B>trap</B>
4989
4990 builtin under
4991 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
4992
4993 </FONT>
4994 below) are not inherited unless the function has been given the
4995 <B>trace</B> attribute (see the description of the
4996 <FONT SIZE=-1><B>declare</B>
4997
4998 </FONT>
4999 builtin below) or the
5000 <B>-o functrace</B> shell option has been enabled with
5001 the <B>set</B> builtin
5002 (in which case all functions inherit the <B>DEBUG</B> and <B>RETURN</B> traps),
5003 and the
5004 <FONT SIZE=-1><B>ERR</B>
5005
5006 </FONT>
5007 trap is not inherited unless the <B>-o errtrace</B> shell option has
5008 been enabled.
5009 <P>
5010
5011 Variables local to the function may be declared with the
5012 <B>local</B>
5013
5014 builtin command. Ordinarily, variables and their values
5015 are shared between the function and its caller.
5016 <P>
5017
5018 The <B>FUNCNEST</B> variable, if set to a numeric value greater
5019 than 0, defines a maximum function nesting level. Function
5020 invocations that exceed the limit cause the entire command to
5021 abort.
5022 <P>
5023
5024 If the builtin command
5025 <B>return</B>
5026
5027 is executed in a function, the function completes and
5028 execution resumes with the next command after the function
5029 call.
5030 Any command associated with the <B>RETURN</B> trap is executed
5031 before execution resumes.
5032 When a function completes, the values of the
5033 positional parameters and the special parameter
5034 <B>#</B>
5035
5036 are restored to the values they had prior to the function's
5037 execution.
5038 <P>
5039
5040 Function names and definitions may be listed with the
5041 <B>-f</B>
5042
5043 option to the
5044 <B>declare</B>
5045
5046 or
5047 <B>typeset</B>
5048
5049 builtin commands. The
5050 <B>-F</B>
5051
5052 option to
5053 <B>declare</B>
5054
5055 or
5056 <B>typeset</B>
5057
5058 will list the function names only
5059 (and optionally the source file and line number, if the <B>extdebug</B>
5060 shell option is enabled).
5061 Functions may be exported so that subshells
5062 automatically have them defined with the
5063 <B>-f</B>
5064
5065 option to the
5066 <B>export</B>
5067
5068 builtin.
5069 A function definition may be deleted using the <B>-f</B> option to
5070 the
5071 <B>unset</B>
5072
5073 builtin.
5074 Note that shell functions and variables with the same name may result
5075 in multiple identically-named entries in the environment passed to the
5076 shell's children.
5077 Care should be taken in cases where this may cause a problem.
5078 <P>
5079
5080 Functions may be recursive.
5081 The <B>FUNCNEST</B> variable may be used to limit the depth of the
5082 function call stack and restrict the number of function invocations.
5083 By default, no limit is imposed on the number of recursive calls.
5084 <A NAME="lbBV">&nbsp;</A>
5085 <H3>ARITHMETIC EVALUATION</H3>
5086
5087 The shell allows arithmetic expressions to be evaluated, under
5088 certain circumstances (see the <B>let</B> and <B>declare</B> builtin
5089 commands and <B>Arithmetic Expansion</B>).
5090 Evaluation is done in fixed-width integers with no check for overflow,
5091 though division by 0 is trapped and flagged as an error.
5092 The operators and their precedence, associativity, and values
5093 are the same as in the C language.
5094 The following list of operators is grouped into levels of
5095 equal-precedence operators.
5096 The levels are listed in order of decreasing precedence.
5097 <P>
5098
5099
5100 <DL COMPACT>
5101 <DT><B></B><I>id</I>++ <I>id</I>--
5102
5103 <DD>
5104 variable post-increment and post-decrement
5105 <DT><B>++</B><I>id</I> --<I>id</I>
5106
5107 <DD>
5108 variable pre-increment and pre-decrement
5109 <DT><B>- +</B>
5110
5111 <DD>
5112 unary minus and plus
5113 <DT><B>! ~</B>
5114
5115 <DD>
5116 logical and bitwise negation
5117 <DT><B>**</B>
5118
5119 <DD>
5120 exponentiation
5121 <DT><B>* / %</B>
5122
5123 <DD>
5124 multiplication, division, remainder
5125 <DT><B>+ -</B>
5126
5127 <DD>
5128 addition, subtraction
5129 <DT><B>&lt;&lt; &gt;&gt;</B>
5130
5131 <DD>
5132 left and right bitwise shifts
5133 <DT><B>&lt;= &gt;= &lt; &gt;</B>
5134
5135 <DD>
5136 comparison
5137 <DT><B>== !=</B>
5138
5139 <DD>
5140 equality and inequality
5141 <DT><B>&amp;</B>
5142
5143 <DD>
5144 bitwise AND
5145 <DT><B>^</B>
5146
5147 <DD>
5148 bitwise exclusive OR
5149 <DT><B>|</B>
5150
5151 <DD>
5152 bitwise OR
5153 <DT><B>&amp;&amp;</B>
5154
5155 <DD>
5156 logical AND
5157 <DT><B>||</B>
5158
5159 <DD>
5160 logical OR
5161 <DT><B></B><I>expr</I>?<I>expr</I>:<I>expr</I>
5162
5163 <DD>
5164 conditional operator
5165 <DT><B>= *= /= %= += -= &lt;&lt;= &gt;&gt;= &amp;= ^= |=</B>
5166
5167 <DD>
5168 assignment
5169 <DT><B></B><I>expr1</I> , <I>expr2</I>
5170
5171 <DD>
5172 comma
5173
5174 </DL>
5175 <P>
5176
5177 Shell variables are allowed as operands; parameter expansion is
5178 performed before the expression is evaluated.
5179 Within an expression, shell variables may also be referenced by name
5180 without using the parameter expansion syntax.
5181 A shell variable that is null or unset evaluates to 0 when referenced
5182 by name without using the parameter expansion syntax.
5183 The value of a variable is evaluated as an arithmetic expression
5184 when it is referenced, or when a variable which has been given the
5185 <I>integer</I> attribute using <B>declare -i</B> is assigned a value.
5186 A null value evaluates to 0.
5187 A shell variable need not have its <I>integer</I> attribute
5188 turned on to be used in an expression.
5189 <P>
5190
5191 Constants with a leading 0 are interpreted as octal numbers.
5192 A leading 0x or 0X denotes hexadecimal.
5193 Otherwise, numbers take the form [<I>base#</I>]n, where the optional <I>base</I>
5194 is a decimal number between 2 and 64 representing the arithmetic
5195 base, and <I>n</I> is a number in that base.
5196 If <I>base#</I> is omitted, then base 10 is used.
5197 When specifying <I>n</I>,
5198 the digits greater&lt; than 9 are represented by the lowercase letters,
5199 the uppercase letters, @, and _, in that order.
5200 If <I>base</I> is less than or equal to 36, lowercase and uppercase
5201 letters may be used interchangeably to represent numbers between 10
5202 and 35.
5203 <P>
5204
5205 Operators are evaluated in order of precedence. Sub-expressions in
5206 parentheses are evaluated first and may override the precedence
5207 rules above.
5208 <A NAME="lbBW">&nbsp;</A>
5209 <H3>CONDITIONAL EXPRESSIONS</H3>
5210
5211 Conditional expressions are used by the <B>[[</B> compound command and
5212 the <B>test</B> and <B>[</B> builtin commands to test file attributes
5213 and perform string and arithmetic comparisons.
5214 Expressions are formed from the following unary or binary primaries.
5215 If any <I>file</I> argument to one of the primaries is of the form
5216 <I>/dev/fd/n</I>, then file descriptor <I>n</I> is checked.
5217 If the <I>file</I> argument to one of the primaries is one of
5218 <I>/dev/stdin</I>, <I>/dev/stdout</I>, or <I>/dev/stderr</I>, file
5219 descriptor 0, 1, or 2, respectively, is checked.
5220 <P>
5221
5222 Unless otherwise specified, primaries that operate on files follow symbolic
5223 links and operate on the target of the link, rather than the link itself.
5224 <P>
5225
5226
5227 When used with <B>[[</B>, the <B>&lt;</B> and <B>&gt;</B> operators sort
5228 lexicographically using the current locale.
5229 The <B>test</B> command sorts using ASCII ordering.
5230 <P>
5231
5232 <DL COMPACT>
5233 <DT><B>-a </B><I>file</I>
5234
5235 <DD>
5236 True if <I>file</I> exists.
5237 <DT><B>-b </B><I>file</I>
5238
5239 <DD>
5240 True if <I>file</I> exists and is a block special file.
5241 <DT><B>-c </B><I>file</I>
5242
5243 <DD>
5244 True if <I>file</I> exists and is a character special file.
5245 <DT><B>-d </B><I>file</I>
5246
5247 <DD>
5248 True if <I>file</I> exists and is a directory.
5249 <DT><B>-e </B><I>file</I>
5250
5251 <DD>
5252 True if <I>file</I> exists.
5253 <DT><B>-f </B><I>file</I>
5254
5255 <DD>
5256 True if <I>file</I> exists and is a regular file.
5257 <DT><B>-g </B><I>file</I>
5258
5259 <DD>
5260 True if <I>file</I> exists and is set-group-id.
5261 <DT><B>-h </B><I>file</I>
5262
5263 <DD>
5264 True if <I>file</I> exists and is a symbolic link.
5265 <DT><B>-k </B><I>file</I>
5266
5267 <DD>
5268 True if <I>file</I> exists and its ``sticky'' bit is set.
5269 <DT><B>-p </B><I>file</I>
5270
5271 <DD>
5272 True if <I>file</I> exists and is a named pipe (FIFO).
5273 <DT><B>-r </B><I>file</I>
5274
5275 <DD>
5276 True if <I>file</I> exists and is readable.
5277 <DT><B>-s </B><I>file</I>
5278
5279 <DD>
5280 True if <I>file</I> exists and has a size greater than zero.
5281 <DT><B>-t </B><I>fd</I>
5282
5283 <DD>
5284 True if file descriptor
5285 <I>fd</I>
5286
5287 is open and refers to a terminal.
5288 <DT><B>-u </B><I>file</I>
5289
5290 <DD>
5291 True if <I>file</I> exists and its set-user-id bit is set.
5292 <DT><B>-w </B><I>file</I>
5293
5294 <DD>
5295 True if <I>file</I> exists and is writable.
5296 <DT><B>-x </B><I>file</I>
5297
5298 <DD>
5299 True if <I>file</I> exists and is executable.
5300 <DT><B>-G </B><I>file</I>
5301
5302 <DD>
5303 True if <I>file</I> exists and is owned by the effective group id.
5304 <DT><B>-L </B><I>file</I>
5305
5306 <DD>
5307 True if <I>file</I> exists and is a symbolic link.
5308 <DT><B>-N </B><I>file</I>
5309
5310 <DD>
5311 True if <I>file</I> exists and has been modified since it was last read.
5312 <DT><B>-O </B><I>file</I>
5313
5314 <DD>
5315 True if <I>file</I> exists and is owned by the effective user id.
5316 <DT><B>-S </B><I>file</I>
5317
5318 <DD>
5319 True if <I>file</I> exists and is a socket.
5320 <DT><I>file1</I> <B>-ef</B> <I>file2</I><DD>
5321 True if <I>file1</I> and <I>file2</I> refer to the same device and
5322 inode numbers.
5323 <DT><I>file1</I> -<B>nt</B> <I>file2</I><DD>
5324 True if <I>file1</I> is newer (according to modification date) than <I>file2</I>,
5325 or if <I>file1</I> exists and file2 does not.
5326 <DT><I>file1</I> -<B>ot</B> <I>file2</I><DD>
5327 True if <I>file1</I> is older than <I>file2</I>, or if <I>file2</I> exists
5328 and <I>file1</I> does not.
5329 <DT><B>-o </B><I>optname</I>
5330
5331 <DD>
5332 True if the shell option
5333 <I>optname</I>
5334
5335 is enabled.
5336 See the list of options under the description of the
5337 <B>-o</B>
5338
5339 option to the
5340 <B>set</B>
5341
5342 builtin below.
5343 <DT><B>-v </B><I>varname</I>
5344
5345 <DD>
5346 True if the shell variable
5347 <I>varname</I>
5348
5349 is set (has been assigned a value).
5350 <DT><B>-z </B><I>string</I>
5351
5352 <DD>
5353 True if the length of <I>string</I> is zero.
5354 <DT><I>string</I><DD>
5355
5356 <DT><B>-n </B><I>string</I>
5357
5358 <DD>
5359
5360 True if the length of
5361 <I>string</I>
5362
5363 is non-zero.
5364 <DT><I>string1</I> <B>==</B> <I>string2</I><DD>
5365
5366 <DT><I>string1</I> <B>=</B> <I>string2</I><DD>
5367
5368 True if the strings are equal. <B>=</B> should be used
5369 with the <B>test</B> command for POSIX conformance.
5370 <DT><I>string1</I> <B>!=</B> <I>string2</I><DD>
5371 True if the strings are not equal.
5372 <DT><I>string1</I> <B>&lt;</B> <I>string2</I><DD>
5373 True if <I>string1</I> sorts before <I>string2</I> lexicographically.
5374 <DT><I>string1</I> <B>&gt;</B> <I>string2</I><DD>
5375 True if <I>string1</I> sorts after <I>string2</I> lexicographically.
5376 <DT><I>arg1</I> <B>OP</B> <I>arg2</I>
5377
5378 <DD>
5379 <FONT SIZE=-1><B>OP</B>
5380
5381 </FONT>
5382 is one of
5383 <B>-eq</B>,
5384
5385 <B>-ne</B>,
5386
5387 <B>-lt</B>,
5388
5389 <B>-le</B>,
5390
5391 <B>-gt</B>,
5392
5393 or
5394 <B>-ge</B>.
5395
5396 These arithmetic binary operators return true if <I>arg1</I>
5397 is equal to, not equal to, less than, less than or equal to,
5398 greater than, or greater than or equal to <I>arg2</I>, respectively.
5399 <I>Arg1</I>
5400
5401 and
5402 <I>arg2</I>
5403
5404 may be positive or negative integers.
5405
5406 </DL>
5407 <A NAME="lbBX">&nbsp;</A>
5408 <H3>SIMPLE COMMAND EXPANSION</H3>
5409
5410 When a simple command is executed, the shell performs the following
5411 expansions, assignments, and redirections, from left to right.
5412 <DL COMPACT>
5413 <DT>1.<DD>
5414 The words that the parser has marked as variable assignments (those
5415 preceding the command name) and redirections are saved for later
5416 processing.
5417 <DT>2.<DD>
5418 The words that are not variable assignments or redirections are
5419 expanded. If any words remain after expansion, the first word
5420 is taken to be the name of the command and the remaining words are
5421 the arguments.
5422 <DT>3.<DD>
5423 Redirections are performed as described above under
5424 <FONT SIZE=-1><B>REDIRECTION</B>.
5425
5426 </FONT>
5427 <DT>4.<DD>
5428 The text after the <B>=</B> in each variable assignment undergoes tilde
5429 expansion, parameter expansion, command substitution, arithmetic expansion,
5430 and quote removal before being assigned to the variable.
5431 </DL>
5432 <P>
5433
5434 If no command name results, the variable assignments affect the current
5435 shell environment. Otherwise, the variables are added to the environment
5436 of the executed command and do not affect the current shell environment.
5437 If any of the assignments attempts to assign a value to a readonly variable,
5438 an error occurs, and the command exits with a non-zero status.
5439 <P>
5440
5441 If no command name results, redirections are performed, but do not
5442 affect the current shell environment. A redirection error causes the
5443 command to exit with a non-zero status.
5444 <P>
5445
5446 If there is a command name left after expansion, execution proceeds as
5447 described below. Otherwise, the command exits. If one of the expansions
5448 contained a command substitution, the exit status of the command is
5449 the exit status of the last command substitution performed. If there
5450 were no command substitutions, the command exits with a status of zero.
5451 <A NAME="lbBY">&nbsp;</A>
5452 <H3>COMMAND EXECUTION</H3>
5453
5454 After a command has been split into words, if it results in a
5455 simple command and an optional list of arguments, the following
5456 actions are taken.
5457 <P>
5458
5459 If the command name contains no slashes, the shell attempts to
5460 locate it. If there exists a shell function by that name, that
5461 function is invoked as described above in
5462 <FONT SIZE=-1><B>FUNCTIONS</B>.
5463
5464 </FONT>
5465 If the name does not match a function, the shell searches for
5466 it in the list of shell builtins. If a match is found, that
5467 builtin is invoked.
5468 <P>
5469
5470 If the name is neither a shell function nor a builtin,
5471 and contains no slashes,
5472 <B>bash</B>
5473
5474 searches each element of the
5475 <FONT SIZE=-1><B>PATH</B>
5476
5477 </FONT>
5478 for a directory containing an executable file by that name.
5479 <B>Bash</B>
5480
5481 uses a hash table to remember the full pathnames of executable
5482 files (see
5483 <B>hash</B>
5484
5485 under
5486 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
5487
5488 </FONT>
5489 below).
5490 A full search of the directories in
5491 <FONT SIZE=-1><B>PATH</B>
5492
5493 </FONT>
5494 is performed only if the command is not found in the hash table.
5495 If the search is unsuccessful, the shell searches for a defined shell
5496 function named <B>command_not_found_handle</B>.
5497 If that function exists, it is invoked with the original command and
5498 the original command's arguments as its arguments, and the function's
5499 exit status becomes the exit status of the shell.
5500 If that function is not defined, the shell prints an error
5501 message and returns an exit status of 127.
5502 <P>
5503
5504 If the search is successful, or if the command name contains
5505 one or more slashes, the shell executes the named program in a
5506 separate execution environment.
5507 Argument 0 is set to the name given, and the remaining arguments
5508 to the command are set to the arguments given, if any.
5509 <P>
5510
5511 If this execution fails because the file is not in executable
5512 format, and the file is not a directory, it is assumed to be
5513 a <I>shell script</I>, a file
5514 containing shell commands. A subshell is spawned to execute
5515 it. This subshell reinitializes itself, so
5516 that the effect is as if a new shell had been invoked
5517 to handle the script, with the exception that the locations of
5518 commands remembered by the parent (see
5519 <B>hash</B>
5520
5521 below under
5522 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>)</FONT>
5523 are retained by the child.
5524 <P>
5525
5526 If the program is a file beginning with
5527 <B>#!</B>,
5528
5529 the remainder of the first line specifies an interpreter
5530 for the program. The shell executes the
5531 specified interpreter on operating systems that do not
5532 handle this executable format themselves. The arguments to the
5533 interpreter consist of a single optional argument following the
5534 interpreter name on the first line of the program, followed
5535 by the name of the program, followed by the command
5536 arguments, if any.
5537 <A NAME="lbBZ">&nbsp;</A>
5538 <H3>COMMAND EXECUTION ENVIRONMENT</H3>
5539
5540 The shell has an <I>execution environment</I>, which consists of the
5541 following:
5542 <DL COMPACT>
5543 <DT>*<DD>
5544 open files inherited by the shell at invocation, as modified by
5545 redirections supplied to the <B>exec</B> builtin
5546 <DT>*<DD>
5547 the current working directory as set by <B>cd</B>, <B>pushd</B>, or
5548 <B>popd</B>, or inherited by the shell at invocation
5549 <DT>*<DD>
5550 the file creation mode mask as set by <B>umask</B> or inherited from
5551 the shell's parent
5552 <DT>*<DD>
5553 current traps set by <B>trap</B>
5554 <DT>*<DD>
5555 shell parameters that are set by variable assignment or with <B>set</B>
5556 or inherited from the shell's parent in the environment
5557 <DT>*<DD>
5558 shell functions defined during execution or inherited from the shell's
5559 parent in the environment
5560 <DT>*<DD>
5561 options enabled at invocation (either by default or with command-line
5562 arguments) or by <B>set</B>
5563 <DT>*<DD>
5564 options enabled by <B>shopt</B>
5565 <DT>*<DD>
5566 shell aliases defined with <B>alias</B>
5567 <DT>*<DD>
5568 various process IDs, including those of background jobs, the value
5569 of <B>$$</B>, and the value of
5570 <FONT SIZE=-1><B>PPID</B>
5571
5572 </FONT>
5573 </DL>
5574 <P>
5575
5576 When a simple command other than a builtin or shell function
5577 is to be executed, it
5578 is invoked in a separate execution environment that consists of
5579 the following. Unless otherwise noted, the values are inherited
5580 from the shell.
5581
5582 <DL COMPACT>
5583 <DT>*<DD>
5584 the shell's open files, plus any modifications and additions specified
5585 by redirections to the command
5586 <DT>*<DD>
5587 the current working directory
5588 <DT>*<DD>
5589 the file creation mode mask
5590 <DT>*<DD>
5591 shell variables and functions marked for export, along with variables
5592 exported for the command, passed in the environment
5593 <DT>*<DD>
5594 traps caught by the shell are reset to the values inherited from the
5595 shell's parent, and traps ignored by the shell are ignored
5596 </DL>
5597 <P>
5598
5599 A command invoked in this separate environment cannot affect the
5600 shell's execution environment.
5601 <P>
5602
5603 Command substitution, commands grouped with parentheses,
5604 and asynchronous commands are invoked in a
5605 subshell environment that is a duplicate of the shell environment,
5606 except that traps caught by the shell are reset to the values
5607 that the shell inherited from its parent at invocation. Builtin
5608 commands that are invoked as part of a pipeline are also executed in a
5609 subshell environment. Changes made to the subshell environment
5610 cannot affect the shell's execution environment.
5611 <P>
5612
5613 Subshells spawned to execute command substitutions inherit the value of
5614 the <B>-e</B> option from the parent shell. When not in <I>posix</I> mode,
5615 <B>bash</B> clears the <B>-e</B> option in such subshells.
5616 <P>
5617
5618 If a command is followed by a <B>&amp;</B> and job control is not active, the
5619 default standard input for the command is the empty file <I>/dev/null</I>.
5620 Otherwise, the invoked command inherits the file descriptors of the calling
5621 shell as modified by redirections.
5622 <A NAME="lbCA">&nbsp;</A>
5623 <H3>ENVIRONMENT</H3>
5624
5625 When a program is invoked it is given an array of strings
5626 called the
5627 <I>environment</I>.
5628
5629 This is a list of
5630 <I>name</I>-<I>value</I> pairs, of the form
5631 <I>name</I>=value.
5632
5633 <P>
5634
5635 The shell provides several ways to manipulate the environment.
5636 On invocation, the shell scans its own environment and
5637 creates a parameter for each name found, automatically marking
5638 it for
5639 <I>export</I>
5640
5641 to child processes. Executed commands inherit the environment.
5642 The
5643 <B>export</B>
5644
5645 and
5646 <B>declare -x</B>
5647
5648 commands allow parameters and functions to be added to and
5649 deleted from the environment. If the value of a parameter
5650 in the environment is modified, the new value becomes part
5651 of the environment, replacing the old. The environment
5652 inherited by any executed command consists of the shell's
5653 initial environment, whose values may be modified in the shell,
5654 less any pairs removed by the
5655 <B>unset</B>
5656
5657 command, plus any additions via the
5658 <B>export</B>
5659
5660 and
5661 <B>declare -x</B>
5662
5663 commands.
5664 <P>
5665
5666 The environment for any
5667 <I>simple command</I>
5668
5669 or function may be augmented temporarily by prefixing it with
5670 parameter assignments, as described above in
5671 <FONT SIZE=-1><B>PARAMETERS</B>.
5672
5673 </FONT>
5674 These assignment statements affect only the environment seen
5675 by that command.
5676 <P>
5677
5678 If the
5679 <B>-k</B>
5680
5681 option is set (see the
5682 <B>set</B>
5683
5684 builtin command below), then
5685 <I>all</I>
5686
5687 parameter assignments are placed in the environment for a command,
5688 not just those that precede the command name.
5689 <P>
5690
5691 When
5692 <B>bash</B>
5693
5694 invokes an external command, the variable
5695 <B>_</B>
5696
5697 is set to the full filename of the command and passed to that
5698 command in its environment.
5699 <A NAME="lbCB">&nbsp;</A>
5700 <H3>EXIT STATUS</H3>
5701
5702 <P>
5703
5704 The exit status of an executed command is the value returned by the
5705 <I>waitpid</I> system call or equivalent function. Exit statuses
5706 fall between 0 and 255, though, as explained below, the shell may
5707 use values above 125 specially. Exit statuses from shell builtins and
5708 compound commands are also limited to this range. Under certain
5709 circumstances, the shell will use special values to indicate specific
5710 failure modes.
5711 <P>
5712
5713 For the shell's purposes, a command which exits with a
5714 zero exit status has succeeded. An exit status of zero
5715 indicates success. A non-zero exit status indicates failure.
5716 When a command terminates on a fatal signal <I>N</I>, <B>bash</B> uses
5717 the value of 128+<I>N</I> as the exit status.
5718 <P>
5719
5720 If a command is not found, the child process created to
5721 execute it returns a status of 127. If a command is found
5722 but is not executable, the return status is 126.
5723 <P>
5724
5725 If a command fails because of an error during expansion or redirection,
5726 the exit status is greater than zero.
5727 <P>
5728
5729 Shell builtin commands return a status of 0 (<I>true</I>) if
5730 successful, and non-zero (<I>false</I>) if an error occurs
5731 while they execute.
5732 All builtins return an exit status of 2 to indicate incorrect usage.
5733 <P>
5734
5735 <B>Bash</B> itself returns the exit status of the last command
5736 executed, unless a syntax error occurs, in which case it exits
5737 with a non-zero value. See also the <B>exit</B> builtin
5738 command below.
5739 <A NAME="lbCC">&nbsp;</A>
5740 <H3>SIGNALS</H3>
5741
5742 When <B>bash</B> is interactive, in the absence of any traps, it ignores
5743 <FONT SIZE=-1><B>SIGTERM</B>
5744
5745 </FONT>
5746 (so that <B>kill 0</B> does not kill an interactive shell),
5747 and
5748 <FONT SIZE=-1><B>SIGINT</B>
5749
5750 </FONT>
5751 is caught and handled (so that the <B>wait</B> builtin is interruptible).
5752 In all cases, <B>bash</B> ignores
5753 <FONT SIZE=-1><B>SIGQUIT</B>.
5754
5755 </FONT>
5756 If job control is in effect,
5757 <B>bash</B>
5758
5759 ignores
5760 <FONT SIZE=-1><B>SIGTTIN</B>,
5761
5762 </FONT>
5763 <FONT SIZE=-1><B>SIGTTOU</B>,
5764
5765 </FONT>
5766 and
5767 <FONT SIZE=-1><B>SIGTSTP</B>.
5768
5769 </FONT>
5770 <P>
5771
5772 Non-builtin commands run by <B>bash</B> have signal handlers
5773 set to the values inherited by the shell from its parent.
5774 When job control is not in effect, asynchronous commands
5775 ignore
5776 <FONT SIZE=-1><B>SIGINT</B>
5777
5778 </FONT>
5779 and
5780 <FONT SIZE=-1><B>SIGQUIT</B>
5781
5782 </FONT>
5783 in addition to these inherited handlers.
5784 Commands run as a result of command substitution ignore the
5785 keyboard-generated job control signals
5786 <FONT SIZE=-1><B>SIGTTIN</B>,
5787
5788 </FONT>
5789 <FONT SIZE=-1><B>SIGTTOU</B>,
5790
5791 </FONT>
5792 and
5793 <FONT SIZE=-1><B>SIGTSTP</B>.
5794
5795 </FONT>
5796 <P>
5797
5798 The shell exits by default upon receipt of a
5799 <FONT SIZE=-1><B>SIGHUP</B>.
5800
5801 </FONT>
5802 Before exiting, an interactive shell resends the
5803 <FONT SIZE=-1><B>SIGHUP</B>
5804
5805 </FONT>
5806 to all jobs, running or stopped.
5807 Stopped jobs are sent
5808 <FONT SIZE=-1><B>SIGCONT</B>
5809
5810 </FONT>
5811 to ensure that they receive the
5812 <FONT SIZE=-1><B>SIGHUP</B>.
5813
5814 </FONT>
5815 To prevent the shell from
5816 sending the signal to a particular job, it should be removed from the
5817 jobs table with the
5818 <B>disown</B>
5819
5820 builtin (see
5821 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
5822
5823 </FONT>
5824 below) or marked
5825 to not receive
5826 <FONT SIZE=-1><B>SIGHUP</B>
5827
5828 </FONT>
5829 using
5830 <B>disown -h</B>.
5831
5832 <P>
5833
5834 If the
5835 <B>huponexit</B>
5836
5837 shell option has been set with
5838 <B>shopt</B>,
5839
5840 <B>bash</B>
5841
5842 sends a
5843 <FONT SIZE=-1><B>SIGHUP</B>
5844
5845 </FONT>
5846 to all jobs when an interactive login shell exits.
5847 <P>
5848
5849 If <B>bash</B> is waiting for a command to complete and receives a signal
5850 for which a trap has been set, the trap will not be executed until
5851 the command completes.
5852 When <B>bash</B> is waiting for an asynchronous command via the <B>wait</B>
5853 builtin, the reception of a signal for which a trap has been set will
5854 cause the <B>wait</B> builtin to return immediately with an exit status
5855 greater than 128, immediately after which the trap is executed.
5856 <A NAME="lbCD">&nbsp;</A>
5857 <H3>JOB CONTROL</H3>
5858
5859 <I>Job control</I>
5860
5861 refers to the ability to selectively stop (<I>suspend</I>)
5862 the execution of processes and continue (<I>resume</I>)
5863 their execution at a later point. A user typically employs
5864 this facility via an interactive interface supplied jointly
5865 by the operating system kernel's terminal driver and
5866 <B>bash</B>.
5867
5868 <P>
5869
5870 The shell associates a
5871 <I>job</I>
5872
5873 with each pipeline. It keeps a table of currently executing
5874 jobs, which may be listed with the
5875 <B>jobs</B>
5876
5877 command. When
5878 <B>bash</B>
5879
5880 starts a job asynchronously (in the
5881 <I>background</I>),
5882
5883 it prints a line that looks like:
5884 <DL COMPACT><DT><DD>
5885 <P>
5886
5887 [1] 25647
5888 </DL>
5889
5890 <P>
5891
5892 indicating that this job is job number 1 and that the process ID
5893 of the last process in the pipeline associated with this job is 25647.
5894 All of the processes in a single pipeline are members of the same job.
5895 <B>Bash</B>
5896
5897 uses the
5898 <I>job</I>
5899
5900 abstraction as the basis for job control.
5901 <P>
5902
5903 To facilitate the implementation of the user interface to job
5904 control, the operating system maintains the notion of a <I>current terminal
5905 process group ID</I>. Members of this process group (processes whose
5906 process group ID is equal to the current terminal process group ID)
5907 receive keyboard-generated signals such as
5908 <FONT SIZE=-1><B>SIGINT</B>.
5909
5910 </FONT>
5911 These processes are said to be in the
5912 <I>foreground</I>.
5913
5914 <I>Background</I>
5915
5916 processes are those whose process group ID differs from the terminal's;
5917 such processes are immune to keyboard-generated signals.
5918 Only foreground processes are allowed to read from or, if the
5919 user so specifies with <TT>stty tostop</TT>, write to the
5920 terminal.
5921 Background processes which attempt to read from (write to when
5922 <TT>stty tostop</TT> is in effect) the
5923 terminal are sent a
5924 <FONT SIZE=-1><B>SIGTTIN (SIGTTOU)</B>
5925
5926 </FONT>
5927 signal by the kernel's terminal driver,
5928 which, unless caught, suspends the process.
5929 <P>
5930
5931 If the operating system on which
5932 <B>bash</B>
5933
5934 is running supports
5935 job control,
5936 <B>bash</B>
5937
5938 contains facilities to use it.
5939 Typing the
5940 <I>suspend</I>
5941
5942 character (typically
5943 <B>^Z</B>,
5944
5945 Control-Z) while a process is running
5946 causes that process to be stopped and returns control to
5947 <B>bash</B>.
5948
5949 Typing the
5950 <I>delayed suspend</I>
5951
5952 character (typically
5953 <B>^Y</B>,
5954
5955 Control-Y) causes the process to be stopped when it
5956 attempts to read input from the terminal, and control to
5957 be returned to
5958 <B>bash</B>.
5959
5960 The user may then manipulate the state of this job, using the
5961 <B>bg</B>
5962
5963 command to continue it in the background, the
5964 <B>fg</B>
5965
5966 command to continue it in the foreground, or
5967 the
5968 <B>kill</B>
5969
5970 command to kill it. A <B>^Z</B> takes effect immediately,
5971 and has the additional side effect of causing pending output
5972 and typeahead to be discarded.
5973 <P>
5974
5975 There are a number of ways to refer to a job in the shell.
5976 The character
5977 <B>%</B>
5978
5979 introduces a job specification (<I>jobspec</I>). Job number
5980 <I>n</I>
5981
5982 may be referred to as
5983 <B>%n</B>.
5984
5985 A job may also be referred to using a prefix of the name used to
5986 start it, or using a substring that appears in its command line.
5987 For example,
5988 <B>%ce</B>
5989
5990 refers to a stopped
5991 <B>ce</B>
5992
5993 job. If a prefix matches more than one job,
5994 <B>bash</B>
5995
5996 reports an error. Using
5997 <B>%?ce</B>,
5998
5999 on the other hand, refers to any job containing the string
6000 <B>ce</B>
6001
6002 in its command line. If the substring matches more than one job,
6003 <B>bash</B>
6004
6005 reports an error. The symbols
6006 <B>%%</B>
6007
6008 and
6009 <B>%+</B>
6010
6011 refer to the shell's notion of the
6012 <I>current job</I>,
6013
6014 which is the last job stopped while it was in
6015 the foreground or started in the background.
6016 The
6017 <I>previous job</I>
6018
6019 may be referenced using
6020 <B>%-</B>.
6021
6022 If there is only a single job, <B>%+</B> and <B>%-</B> can both be used
6023 to refer to that job.
6024 In output pertaining to jobs (e.g., the output of the
6025 <B>jobs</B>
6026
6027 command), the current job is always flagged with a
6028 <B>+</B>,
6029
6030 and the previous job with a
6031 <B>-</B>.
6032
6033 A single % (with no accompanying job specification) also refers to the
6034 current job.
6035 <P>
6036
6037 Simply naming a job can be used to bring it into the
6038 foreground:
6039 <B>%1</B>
6040
6041 is a synonym for
6042 <B>``fg %1''</B>,
6043 bringing job 1 from the background into the foreground.
6044 Similarly,
6045 <B>``%1 &amp;''</B>
6046
6047 resumes job 1 in the background, equivalent to
6048 <B>``bg %1''</B>.
6049 <P>
6050
6051 The shell learns immediately whenever a job changes state.
6052 Normally,
6053 <B>bash</B>
6054
6055 waits until it is about to print a prompt before reporting
6056 changes in a job's status so as to not interrupt
6057 any other output. If the
6058 <B>-b</B>
6059
6060 option to the
6061 <B>set</B>
6062
6063 builtin command
6064 is enabled,
6065 <B>bash</B>
6066
6067 reports such changes immediately.
6068 Any trap on
6069 <FONT SIZE=-1><B>SIGCHLD</B>
6070
6071 </FONT>
6072 is executed for each child that exits.
6073 <P>
6074
6075 If an attempt to exit
6076 <B>bash</B>
6077
6078 is made while jobs are stopped (or, if the <B>checkjobs</B> shell option has
6079 been enabled using the <B>shopt</B> builtin, running), the shell prints a
6080 warning message, and, if the <B>checkjobs</B> option is enabled, lists the
6081 jobs and their statuses.
6082 The
6083 <B>jobs</B>
6084
6085 command may then be used to inspect their status.
6086 If a second attempt to exit is made without an intervening command,
6087 the shell does not print another warning, and any stopped
6088 jobs are terminated.
6089 <A NAME="lbCE">&nbsp;</A>
6090 <H3>PROMPTING</H3>
6091
6092 When executing interactively,
6093 <B>bash</B>
6094
6095 displays the primary prompt
6096 <FONT SIZE=-1><B>PS1</B>
6097
6098 </FONT>
6099 when it is ready to read a command, and the secondary prompt
6100 <FONT SIZE=-1><B>PS2</B>
6101
6102 </FONT>
6103 when it needs more input to complete a command.
6104 <B>Bash</B>
6105
6106 allows these prompt strings to be customized by inserting a number of
6107 backslash-escaped special characters that are decoded as follows:
6108 <DL COMPACT><DT><DD>
6109
6110 <DL COMPACT>
6111 <DT><B>\a</B>
6112
6113 <DD>
6114 an ASCII bell character (07)
6115 <DT><B>\d</B>
6116
6117 <DD>
6118 the date in &quot;Weekday Month Date&quot; format (e.g., &quot;Tue May 26&quot;)
6119 <DT><B>\D{</B><I>format</I>}
6120
6121 <DD>
6122 the <I>format</I> is passed to <I>strftime</I>(3) and the result is inserted
6123 into the prompt string; an empty <I>format</I> results in a locale-specific
6124 time representation. The braces are required
6125 <DT><B>\e</B>
6126
6127 <DD>
6128 an ASCII escape character (033)
6129 <DT><B>\h</B>
6130
6131 <DD>
6132 the hostname up to the first `.'
6133 <DT><B>\H</B>
6134
6135 <DD>
6136 the hostname
6137 <DT><B>\j</B>
6138
6139 <DD>
6140 the number of jobs currently managed by the shell
6141 <DT><B>\l</B>
6142
6143 <DD>
6144 the basename of the shell's terminal device name
6145 <DT><B>\n</B>
6146
6147 <DD>
6148 newline
6149 <DT><B>\r</B>
6150
6151 <DD>
6152 carriage return
6153 <DT><B>\s</B>
6154
6155 <DD>
6156 the name of the shell, the basename of
6157 <B>$0</B>
6158
6159 (the portion following the final slash)
6160 <DT><B>\t</B>
6161
6162 <DD>
6163 the current time in 24-hour HH:MM:SS format
6164 <DT><B>\T</B>
6165
6166 <DD>
6167 the current time in 12-hour HH:MM:SS format
6168 <DT><B>\@</B>
6169
6170 <DD>
6171 the current time in 12-hour am/pm format
6172 <DT><B>\A</B>
6173
6174 <DD>
6175 the current time in 24-hour HH:MM format
6176 <DT><B>\u</B>
6177
6178 <DD>
6179 the username of the current user
6180 <DT><B>\v</B>
6181
6182 <DD>
6183 the version of <B>bash</B> (e.g., 2.00)
6184 <DT><B>\V</B>
6185
6186 <DD>
6187 the release of <B>bash</B>, version + patch level (e.g., 2.00.0)
6188 <DT><B>\w</B>
6189
6190 <DD>
6191 the current working directory, with
6192 <FONT SIZE=-1><B>$HOME</B>
6193
6194 </FONT>
6195 abbreviated with a tilde
6196 (uses the value of the
6197 <FONT SIZE=-1><B>PROMPT_DIRTRIM</B>
6198
6199 </FONT>
6200 variable)
6201 <DT><B>\W</B>
6202
6203 <DD>
6204 the basename of the current working directory, with
6205 <FONT SIZE=-1><B>$HOME</B>
6206
6207 </FONT>
6208 abbreviated with a tilde
6209 <DT><B>\!</B>
6210
6211 <DD>
6212 the history number of this command
6213 <DT><B>\#</B>
6214
6215 <DD>
6216 the command number of this command
6217 <DT><B>\$</B>
6218
6219 <DD>
6220 if the effective UID is 0, a
6221 <B>#</B>,
6222
6223 otherwise a
6224 <B>$</B>
6225
6226 <DT><B>\</B><I>nnn</I>
6227
6228 <DD>
6229 the character corresponding to the octal number <I>nnn</I>
6230 <DT><B>\\</B>
6231
6232 <DD>
6233 a backslash
6234 <DT><B>\[</B>
6235
6236 <DD>
6237 begin a sequence of non-printing characters, which could be used to
6238 embed a terminal control sequence into the prompt
6239 <DT><B>\]</B>
6240
6241 <DD>
6242 end a sequence of non-printing characters
6243
6244 </DL></DL>
6245
6246 <P>
6247
6248 The command number and the history number are usually different:
6249 the history number of a command is its position in the history
6250 list, which may include commands restored from the history file
6251 (see
6252 <FONT SIZE=-1><B>HISTORY</B>
6253
6254 </FONT>
6255 below), while the command number is the position in the sequence
6256 of commands executed during the current shell session.
6257 After the string is decoded, it is expanded via
6258 parameter expansion, command substitution, arithmetic
6259 expansion, and quote removal, subject to the value of the
6260 <B>promptvars</B>
6261
6262 shell option (see the description of the
6263 <B>shopt</B>
6264
6265 command under
6266 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
6267
6268 </FONT>
6269 below).
6270 <A NAME="lbCF">&nbsp;</A>
6271 <H3>READLINE</H3>
6272
6273 This is the library that handles reading input when using an interactive
6274 shell, unless the
6275 <B>--noediting</B>
6276
6277 option is given at shell invocation.
6278 Line editing is also used when using the <B>-e</B> option to the
6279 <B>read</B> builtin.
6280 By default, the line editing commands are similar to those of Emacs.
6281 A vi-style line editing interface is also available.
6282 Line editing can be enabled at any time using the
6283 <B>-o emacs</B>
6284
6285 or
6286 <B>-o vi</B>
6287
6288 options to the
6289 <B>set</B>
6290
6291 builtin (see
6292 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
6293
6294 </FONT>
6295 below).
6296 To turn off line editing after the shell is running, use the
6297 <B>+o emacs</B>
6298
6299 or
6300 <B>+o vi</B>
6301
6302 options to the
6303 <B>set</B>
6304
6305 builtin.
6306 <A NAME="lbCG">&nbsp;</A>
6307 <H4>Readline Notation</H4>
6308
6309 <P>
6310
6311 In this section, the Emacs-style notation is used to denote
6312 keystrokes. Control keys are denoted by C-<I>key</I>, e.g., C-n
6313 means Control-N. Similarly,
6314 <I>meta</I>
6315
6316 keys are denoted by M-<I>key</I>, so M-x means Meta-X. (On keyboards
6317 without a
6318 <I>meta</I>
6319
6320 key, M-<I>x</I> means ESC <I>x</I>, i.e., press the Escape key
6321 then the
6322 <I>x</I>
6323
6324 key. This makes ESC the <I>meta prefix</I>.
6325 The combination M-C-<I>x</I> means ESC-Control-<I>x</I>,
6326 or press the Escape key
6327 then hold the Control key while pressing the
6328 <I>x</I>
6329
6330 key.)
6331 <P>
6332
6333 Readline commands may be given numeric
6334 <I>arguments</I>,
6335
6336 which normally act as a repeat count.
6337 Sometimes, however, it is the sign of the argument that is significant.
6338 Passing a negative argument to a command that acts in the forward
6339 direction (e.g., <B>kill-line</B>) causes that command to act in a
6340 backward direction.
6341 Commands whose behavior with arguments deviates from this are noted
6342 below.
6343 <P>
6344
6345 When a command is described as <I>killing</I> text, the text
6346 deleted is saved for possible future retrieval
6347 (<I>yanking</I>). The killed text is saved in a
6348 <I>kill ring</I>. Consecutive kills cause the text to be
6349 accumulated into one unit, which can be yanked all at once.
6350 Commands which do not kill text separate the chunks of text
6351 on the kill ring.
6352 <A NAME="lbCH">&nbsp;</A>
6353 <H4>Readline Initialization</H4>
6354
6355 <P>
6356
6357 Readline is customized by putting commands in an initialization
6358 file (the <I>inputrc</I> file).
6359 The name of this file is taken from the value of the
6360 <FONT SIZE=-1><B>INPUTRC</B>
6361
6362 </FONT>
6363 variable. If that variable is unset, the default is
6364 <A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>.
6365
6366 When a program which uses the readline library starts up, the
6367 initialization file is read, and the key bindings and variables
6368 are set.
6369 There are only a few basic constructs allowed in the
6370 readline initialization file.
6371 Blank lines are ignored.
6372 Lines beginning with a <B>#</B> are comments.
6373 Lines beginning with a <B>$</B> indicate conditional constructs.
6374 Other lines denote key bindings and variable settings.
6375 <P>
6376
6377 The default key-bindings may be changed with an
6378 <I>inputrc </I>
6379
6380 file.
6381 Other programs that use this library may add their own commands
6382 and bindings.
6383 <P>
6384
6385 For example, placing
6386 <DL COMPACT><DT><DD>
6387 <P>
6388
6389 M-Control-u: universal-argument
6390 </DL>
6391
6392 or
6393 <DL COMPACT><DT><DD>
6394 C-Meta-u: universal-argument
6395 </DL>
6396
6397 into the
6398 <I>inputrc</I>
6399
6400 would make M-C-u execute the readline command
6401 <I>universal-argument</I>.
6402
6403 <P>
6404
6405 The following symbolic character names are recognized:
6406 <I>RUBOUT</I>,
6407
6408 <I>DEL</I>,
6409
6410 <I>ESC</I>,
6411
6412 <I>LFD</I>,
6413
6414 <I>NEWLINE</I>,
6415
6416 <I>RET</I>,
6417
6418 <I>RETURN</I>,
6419
6420 <I>SPC</I>,
6421
6422 <I>SPACE</I>,
6423
6424 and
6425 <I>TAB</I>.
6426
6427 <P>
6428
6429 In addition to command names, readline allows keys to be bound
6430 to a string that is inserted when the key is pressed (a <I>macro</I>).
6431 <A NAME="lbCI">&nbsp;</A>
6432 <H4>Readline Key Bindings</H4>
6433
6434 <P>
6435
6436 The syntax for controlling key bindings in the
6437 <I>inputrc</I>
6438
6439 file is simple. All that is required is the name of the
6440 command or the text of a macro and a key sequence to which
6441 it should be bound. The name may be specified in one of two ways:
6442 as a symbolic key name, possibly with <I>Meta-</I> or <I>Control-</I>
6443 prefixes, or as a key sequence.
6444 <P>
6445
6446 When using the form <B>keyname</B>:<I>function-name</I> or <I>macro</I>,
6447 <I>keyname</I>
6448
6449 is the name of a key spelled out in English. For example:
6450 <P>
6451 <DL COMPACT><DT><DD>
6452 Control-u: universal-argument
6453 <BR>
6454
6455 Meta-Rubout: backward-kill-word
6456 <BR>
6457
6458 Control-o: &quot;&gt; output&quot;
6459 </DL>
6460
6461 <P>
6462
6463 In the above example,
6464 <I>C-u</I>
6465
6466 is bound to the function
6467 <B>universal-argument</B>,
6468
6469 <I>M-DEL</I>
6470
6471 is bound to the function
6472 <B>backward-kill-word</B>,
6473
6474 and
6475 <I>C-o</I>
6476
6477 is bound to run the macro
6478 expressed on the right hand side (that is, to insert the text
6479 <TT>&gt; output</TT>
6480
6481 into the line).
6482 <P>
6483
6484 In the second form, <B>&quot;keyseq&quot;</B>:<I>function-name</I> or <I>macro</I>,
6485 <B>keyseq</B>
6486
6487 differs from
6488 <B>keyname</B>
6489
6490 above in that strings denoting
6491 an entire key sequence may be specified by placing the sequence
6492 within double quotes. Some GNU Emacs style key escapes can be
6493 used, as in the following example, but the symbolic character names
6494 are not recognized.
6495 <P>
6496 <DL COMPACT><DT><DD>
6497 &quot;\C-u&quot;: universal-argument
6498 <BR>
6499
6500 &quot;\C-x\C-r&quot;: re-read-init-file
6501 <BR>
6502
6503 &quot;\e[11~&quot;: &quot;Function Key 1&quot;
6504 </DL>
6505
6506 <P>
6507
6508 In this example,
6509 <I>C-u</I>
6510
6511 is again bound to the function
6512 <B>universal-argument</B>.
6513
6514 <I>C-x C-r</I>
6515
6516 is bound to the function
6517 <B>re-read-init-file</B>,
6518
6519 and
6520 <I>ESC [ 1 1 ~</I>
6521
6522 is bound to insert the text
6523 <TT>Function Key 1</TT>.
6524
6525 <P>
6526
6527 The full set of GNU Emacs style escape sequences is
6528 <DL COMPACT><DT><DD>
6529
6530 <DL COMPACT>
6531 <DT><B>\C-</B>
6532
6533 <DD>
6534 control prefix
6535 <DT><B>\M-</B>
6536
6537 <DD>
6538 meta prefix
6539 <DT><B>\e</B>
6540
6541 <DD>
6542 an escape character
6543 <DT><B>\\</B>
6544
6545 <DD>
6546 backslash
6547 <DT><B>\</B>
6548
6549 <DD>
6550 literal &quot;
6551 <DT><B>\aq</B>
6552
6553 <DD>
6554 literal aq
6555 </DL></DL>
6556
6557
6558 <P>
6559
6560 In addition to the GNU Emacs style escape sequences, a second
6561 set of backslash escapes is available:
6562 <DL COMPACT><DT><DD>
6563
6564 <DL COMPACT>
6565 <DT><B>\a</B>
6566
6567 <DD>
6568 alert (bell)
6569 <DT><B>\b</B>
6570
6571 <DD>
6572 backspace
6573 <DT><B>\d</B>
6574
6575 <DD>
6576 delete
6577 <DT><B>\f</B>
6578
6579 <DD>
6580 form feed
6581 <DT><B>\n</B>
6582
6583 <DD>
6584 newline
6585 <DT><B>\r</B>
6586
6587 <DD>
6588 carriage return
6589 <DT><B>\t</B>
6590
6591 <DD>
6592 horizontal tab
6593 <DT><B>\v</B>
6594
6595 <DD>
6596 vertical tab
6597 <DT><B>\</B><I>nnn</I>
6598
6599 <DD>
6600 the eight-bit character whose value is the octal value <I>nnn</I>
6601 (one to three digits)
6602 <DT><B>\x</B><I>HH</I>
6603
6604 <DD>
6605 the eight-bit character whose value is the hexadecimal value <I>HH</I>
6606 (one or two hex digits)
6607 </DL></DL>
6608
6609
6610 <P>
6611
6612 When entering the text of a macro, single or double quotes must
6613 be used to indicate a macro definition.
6614 Unquoted text is assumed to be a function name.
6615 In the macro body, the backslash escapes described above are expanded.
6616 Backslash will quote any other character in the macro text,
6617 including &quot; and aq.
6618 <P>
6619
6620 <B>Bash</B>
6621
6622 allows the current readline key bindings to be displayed or modified
6623 with the
6624 <B>bind</B>
6625
6626 builtin command. The editing mode may be switched during interactive
6627 use by using the
6628 <B>-o</B>
6629
6630 option to the
6631 <B>set</B>
6632
6633 builtin command (see
6634 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
6635
6636 </FONT>
6637 below).
6638 <A NAME="lbCJ">&nbsp;</A>
6639 <H4>Readline Variables</H4>
6640
6641 <P>
6642
6643 Readline has variables that can be used to further customize its
6644 behavior. A variable may be set in the
6645 <I>inputrc</I>
6646
6647 file with a statement of the form
6648 <DL COMPACT><DT><DD>
6649 <P>
6650
6651 <B>set</B> <I>variable-name</I> <I>value</I>
6652 </DL>
6653
6654 <P>
6655
6656 Except where noted, readline variables can take the values
6657 <B>On</B>
6658
6659 or
6660 <B>Off</B>
6661
6662 (without regard to case).
6663 Unrecognized variable names are ignored.
6664 When a variable value is read, empty or null values, &quot;on&quot; (case-insensitive),
6665 and &quot;1&quot; are equivalent to <B>On</B>. All other values are equivalent to
6666 <B>Off</B>.
6667 The variables and their default values are:
6668 <P>
6669
6670
6671 <DL COMPACT>
6672 <DT><B>bell-style (audible)</B>
6673
6674 <DD>
6675 Controls what happens when readline wants to ring the terminal bell.
6676 If set to <B>none</B>, readline never rings the bell. If set to
6677 <B>visible</B>, readline uses a visible bell if one is available.
6678 If set to <B>audible</B>, readline attempts to ring the terminal's bell.
6679 <DT><B>bind-tty-special-chars (On)</B>
6680
6681 <DD>
6682 If set to <B>On</B>, readline attempts to bind the control characters
6683 treated specially by the kernel's terminal driver to their readline
6684 equivalents.
6685 <DT><B>colored-stats (Off)</B>
6686
6687 <DD>
6688 If set to <B>On</B>, readline displays possible completions using different
6689 colors to indicate their file type.
6690 The color definitions are taken from the value of the <B>LS_COLORS</B>
6691 environment variable.
6692 <DT><B>comment-begin (``#'')</B>
6693
6694 <DD>
6695 The string that is inserted when the readline
6696 <B>insert-comment</B>
6697
6698 command is executed.
6699 This command is bound to
6700 <B>M-#</B>
6701
6702 in emacs mode and to
6703 <B>#</B>
6704
6705 in vi command mode.
6706 <DT><B>completion-ignore-case (Off)</B>
6707
6708 <DD>
6709 If set to <B>On</B>, readline performs filename matching and completion
6710 in a case-insensitive fashion.
6711 <DT><B>completion-prefix-display-length (0)</B>
6712
6713 <DD>
6714 The length in characters of the common prefix of a list of possible
6715 completions that is displayed without modification. When set to a
6716 value greater than zero, common prefixes longer than this value are
6717 replaced with an ellipsis when displaying possible completions.
6718 <DT><B>completion-query-items (100)</B>
6719
6720 <DD>
6721 This determines when the user is queried about viewing
6722 the number of possible completions
6723 generated by the <B>possible-completions</B> command.
6724 It may be set to any integer value greater than or equal to
6725 zero. If the number of possible completions is greater than
6726 or equal to the value of this variable, the user is asked whether
6727 or not he wishes to view them; otherwise they are simply listed
6728 on the terminal.
6729 <DT><B>convert-meta (On)</B>
6730
6731 <DD>
6732 If set to <B>On</B>, readline will convert characters with the
6733 eighth bit set to an ASCII key sequence
6734 by stripping the eighth bit and prefixing an
6735 escape character (in effect, using escape as the <I>meta prefix</I>).
6736 <DT><B>disable-completion (Off)</B>
6737
6738 <DD>
6739 If set to <B>On</B>, readline will inhibit word completion. Completion
6740 characters will be inserted into the line as if they had been
6741 mapped to <B>self-insert</B>.
6742 <DT><B>editing-mode (emacs)</B>
6743
6744 <DD>
6745 Controls whether readline begins with a set of key bindings similar
6746 to <I>Emacs</I> or <I>vi</I>.
6747 <B>editing-mode</B>
6748
6749 can be set to either
6750 <B>emacs</B>
6751
6752 or
6753 <B>vi</B>.
6754
6755 <DT><B>echo-control-characters (On)</B>
6756
6757 <DD>
6758 When set to <B>On</B>, on operating systems that indicate they support it,
6759 readline echoes a character corresponding to a signal generated from the
6760 keyboard.
6761 <DT><B>enable-keypad (Off)</B>
6762
6763 <DD>
6764 When set to <B>On</B>, readline will try to enable the application
6765 keypad when it is called. Some systems need this to enable the
6766 arrow keys.
6767 <DT><B>enable-meta-key (On)</B>
6768
6769 <DD>
6770 When set to <B>On</B>, readline will try to enable any meta modifier
6771 key the terminal claims to support when it is called. On many terminals,
6772 the meta key is used to send eight-bit characters.
6773 <DT><B>expand-tilde (Off)</B>
6774
6775 <DD>
6776 If set to <B>On</B>, tilde expansion is performed when readline
6777 attempts word completion.
6778 <DT><B>history-preserve-point (Off)</B>
6779
6780 <DD>
6781 If set to <B>On</B>, the history code attempts to place point at the
6782 same location on each history line retrieved with <B>previous-history</B>
6783 or <B>next-history</B>.
6784 <DT><B>history-size (0)</B>
6785
6786 <DD>
6787 Set the maximum number of history entries saved in the history list. If
6788 set to zero, the number of entries in the history list is not limited.
6789 <DT><B>horizontal-scroll-mode (Off)</B>
6790
6791 <DD>
6792 When set to <B>On</B>, makes readline use a single line for display,
6793 scrolling the input horizontally on a single screen line when it
6794 becomes longer than the screen width rather than wrapping to a new line.
6795 <DT><B>input-meta (Off)</B>
6796
6797 <DD>
6798 If set to <B>On</B>, readline will enable eight-bit input (that is,
6799 it will not strip the high bit from the characters it reads),
6800 regardless of what the terminal claims it can support. The name
6801 <B>meta-flag</B>
6802
6803 is a synonym for this variable.
6804 <DT><B>isearch-terminators (``C-[C-J'')</B>
6805
6806 <DD>
6807 The string of characters that should terminate an incremental
6808 search without subsequently executing the character as a command.
6809 If this variable has not been given a value, the characters
6810 <I>ESC</I> and <I>C-J</I> will terminate an incremental search.
6811 <DT><B>keymap (emacs)</B>
6812
6813 <DD>
6814 Set the current readline keymap. The set of valid keymap names is
6815 <I>emacs, emacs-standard, emacs-meta, emacs-ctlx, vi,
6816 vi-command</I>, and
6817 <I>vi-insert</I>.
6818
6819 <I>vi</I> is equivalent to <I>vi-command</I>; <I>emacs</I> is
6820 equivalent to <I>emacs-standard</I>. The default value is
6821 <I>emacs</I>;
6822
6823 the value of
6824 <B>editing-mode</B>
6825
6826 also affects the default keymap.
6827 <DT><B>mark-directories (On)</B>
6828
6829 <DD>
6830 If set to <B>On</B>, completed directory names have a slash
6831 appended.
6832 <DT><B>mark-modified-lines (Off)</B>
6833
6834 <DD>
6835 If set to <B>On</B>, history lines that have been modified are displayed
6836 with a preceding asterisk (<B>*</B>).
6837 <DT><B>mark-symlinked-directories (Off)</B>
6838
6839 <DD>
6840 If set to <B>On</B>, completed names which are symbolic links to directories
6841 have a slash appended (subject to the value of
6842 <B>mark-directories</B>).
6843 <DT><B>match-hidden-files (On)</B>
6844
6845 <DD>
6846 This variable, when set to <B>On</B>, causes readline to match files whose
6847 names begin with a `.' (hidden files) when performing filename
6848 completion.
6849 If set to <B>Off</B>, the leading `.' must be
6850 supplied by the user in the filename to be completed.
6851 <DT><B>menu-complete-display-prefix (Off)</B>
6852
6853 <DD>
6854 If set to <B>On</B>, menu completion displays the common prefix of the
6855 list of possible completions (which may be empty) before cycling through
6856 the list.
6857 <DT><B>output-meta (Off)</B>
6858
6859 <DD>
6860 If set to <B>On</B>, readline will display characters with the
6861 eighth bit set directly rather than as a meta-prefixed escape
6862 sequence.
6863 <DT><B>page-completions (On)</B>
6864
6865 <DD>
6866 If set to <B>On</B>, readline uses an internal <I>more</I>-like pager
6867 to display a screenful of possible completions at a time.
6868 <DT><B>print-completions-horizontally (Off)</B>
6869
6870 <DD>
6871 If set to <B>On</B>, readline will display completions with matches
6872 sorted horizontally in alphabetical order, rather than down the screen.
6873 <DT><B>revert-all-at-newline (Off)</B>
6874
6875 <DD>
6876 If set to <B>On</B>, readline will undo all changes to history lines
6877 before returning when <B>accept-line</B> is executed. By default,
6878 history lines may be modified and retain individual undo lists across
6879 calls to <B>readline</B>.
6880 <DT><B>show-all-if-ambiguous (Off)</B>
6881
6882 <DD>
6883 This alters the default behavior of the completion functions. If
6884 set to
6885 <B>On</B>,
6886
6887 words which have more than one possible completion cause the
6888 matches to be listed immediately instead of ringing the bell.
6889 <DT><B>show-all-if-unmodified (Off)</B>
6890
6891 <DD>
6892 This alters the default behavior of the completion functions in
6893 a fashion similar to <B>show-all-if-ambiguous</B>.
6894 If set to
6895 <B>On</B>,
6896
6897 words which have more than one possible completion without any
6898 possible partial completion (the possible completions don't share
6899 a common prefix) cause the matches to be listed immediately instead
6900 of ringing the bell.
6901 <DT><B>skip-completed-text (Off)</B>
6902
6903 <DD>
6904 If set to <B>On</B>, this alters the default completion behavior when
6905 inserting a single match into the line. It's only active when
6906 performing completion in the middle of a word. If enabled, readline
6907 does not insert characters from the completion that match characters
6908 after point in the word being completed, so portions of the word
6909 following the cursor are not duplicated.
6910 <DT><B>visible-stats (Off)</B>
6911
6912 <DD>
6913 If set to <B>On</B>, a character denoting a file's type as reported
6914 by <I>stat</I>(2) is appended to the filename when listing possible
6915 completions.
6916
6917 </DL>
6918 <A NAME="lbCK">&nbsp;</A>
6919 <H4>Readline Conditional Constructs</H4>
6920
6921 <P>
6922
6923 Readline implements a facility similar in spirit to the conditional
6924 compilation features of the C preprocessor which allows key
6925 bindings and variable settings to be performed as the result
6926 of tests. There are four parser directives used.
6927 <DL COMPACT>
6928 <DT><B>$if</B><DD>
6929 The
6930 <B>$if</B>
6931
6932 construct allows bindings to be made based on the
6933 editing mode, the terminal being used, or the application using
6934 readline. The text of the test extends to the end of the line;
6935 no characters are required to isolate it.
6936 <DL COMPACT><DT><DD>
6937 <DL COMPACT>
6938 <DT><B>mode</B><DD>
6939 The <B>mode=</B> form of the <B>$if</B> directive is used to test
6940 whether readline is in emacs or vi mode.
6941 This may be used in conjunction
6942 with the <B>set keymap</B> command, for instance, to set bindings in
6943 the <I>emacs-standard</I> and <I>emacs-ctlx</I> keymaps only if
6944 readline is starting out in emacs mode.
6945 <DT><B>term</B><DD>
6946 The <B>term=</B> form may be used to include terminal-specific
6947 key bindings, perhaps to bind the key sequences output by the
6948 terminal's function keys. The word on the right side of the
6949 <B>=</B>
6950
6951 is tested against the both full name of the terminal and the portion
6952 of the terminal name before the first <B>-</B>. This allows
6953 <I>sun</I>
6954
6955 to match both
6956 <I>sun</I>
6957
6958 and
6959 <I>sun-cmd</I>,
6960
6961 for instance.
6962 <DT><B>application</B><DD>
6963 The <B>application</B> construct is used to include
6964 application-specific settings. Each program using the readline
6965 library sets the <I>application name</I>, and an initialization
6966 file can test for a particular value.
6967 This could be used to bind key sequences to functions useful for
6968 a specific program. For instance, the following command adds a
6969 key sequence that quotes the current or previous word in <B>bash</B>:
6970 <P>
6971 <DL COMPACT><DT><DD>
6972 <PRE>
6973 <B>$if</B> Bash
6974 # Quote the current or previous word
6975 &quot;\C-xq&quot;: &quot;\eb\&quot;\ef\&quot;&quot;
6976 <B>$endif</B>
6977 </PRE>
6978
6979 </DL>
6980
6981 </DL></DL>
6982
6983 <DT><B>$endif</B><DD>
6984 This command, as seen in the previous example, terminates an
6985 <B>$if</B> command.
6986 <DT><B>$else</B><DD>
6987 Commands in this branch of the <B>$if</B> directive are executed if
6988 the test fails.
6989 <DT><B>$include</B><DD>
6990 This directive takes a single filename as an argument and reads commands
6991 and bindings from that file. For example, the following directive
6992 would read <A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>:
6993 <P>
6994 <DL COMPACT><DT><DD>
6995 <PRE>
6996 <B>$include</B> <A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>
6997 </PRE>
6998
6999 </DL>
7000
7001 </DL>
7002 <A NAME="lbCL">&nbsp;</A>
7003 <H4>Searching</H4>
7004
7005 <P>
7006
7007 Readline provides commands for searching through the command history
7008 (see
7009 <FONT SIZE=-1><B>HISTORY</B>
7010
7011 </FONT>
7012 below) for lines containing a specified string.
7013 There are two search modes:
7014 <I>incremental</I>
7015
7016 and
7017 <I>non-incremental</I>.
7018
7019 <P>
7020
7021 Incremental searches begin before the user has finished typing the
7022 search string.
7023 As each character of the search string is typed, readline displays
7024 the next entry from the history matching the string typed so far.
7025 An incremental search requires only as many characters as needed to
7026 find the desired history entry.
7027 The characters present in the value of the <B>isearch-terminators</B>
7028 variable are used to terminate an incremental search.
7029 If that variable has not been assigned a value the Escape and
7030 Control-J characters will terminate an incremental search.
7031 Control-G will abort an incremental search and restore the original
7032 line.
7033 When the search is terminated, the history entry containing the
7034 search string becomes the current line.
7035 <P>
7036
7037 To find other matching entries in the history list, type Control-S or
7038 Control-R as appropriate.
7039 This will search backward or forward in the history for the next
7040 entry matching the search string typed so far.
7041 Any other key sequence bound to a readline command will terminate
7042 the search and execute that command.
7043 For instance, a <I>newline</I> will terminate the search and accept
7044 the line, thereby executing the command from the history list.
7045 <P>
7046
7047 Readline remembers the last incremental search string. If two
7048 Control-Rs are typed without any intervening characters defining a
7049 new search string, any remembered search string is used.
7050 <P>
7051
7052 Non-incremental searches read the entire search string before starting
7053 to search for matching history lines. The search string may be
7054 typed by the user or be part of the contents of the current line.
7055 <A NAME="lbCM">&nbsp;</A>
7056 <H4>Readline Command Names</H4>
7057
7058 <P>
7059
7060 The following is a list of the names of the commands and the default
7061 key sequences to which they are bound.
7062 Command names without an accompanying key sequence are unbound by default.
7063 In the following descriptions, <I>point</I> refers to the current cursor
7064 position, and <I>mark</I> refers to a cursor position saved by the
7065 <B>set-mark</B> command.
7066 The text between the point and mark is referred to as the <I>region</I>.
7067 <A NAME="lbCN">&nbsp;</A>
7068 <H4>Commands for Moving</H4>
7069
7070 <P>
7071
7072
7073 <DL COMPACT>
7074 <DT><B>beginning-of-line (C-a)</B>
7075
7076 <DD>
7077 Move to the start of the current line.
7078 <DT><B>end-of-line (C-e)</B>
7079
7080 <DD>
7081 Move to the end of the line.
7082 <DT><B>forward-char (C-f)</B>
7083
7084 <DD>
7085 Move forward a character.
7086 <DT><B>backward-char (C-b)</B>
7087
7088 <DD>
7089 Move back a character.
7090 <DT><B>forward-word (M-f)</B>
7091
7092 <DD>
7093 Move forward to the end of the next word. Words are composed of
7094 alphanumeric characters (letters and digits).
7095 <DT><B>backward-word (M-b)</B>
7096
7097 <DD>
7098 Move back to the start of the current or previous word.
7099 Words are composed of alphanumeric characters (letters and digits).
7100 <DT><B>shell-forward-word</B>
7101
7102 <DD>
7103 Move forward to the end of the next word.
7104 Words are delimited by non-quoted shell metacharacters.
7105 <DT><B>shell-backward-word</B>
7106
7107 <DD>
7108 Move back to the start of the current or previous word.
7109 Words are delimited by non-quoted shell metacharacters.
7110 <DT><B>clear-screen (C-l)</B>
7111
7112 <DD>
7113 Clear the screen leaving the current line at the top of the screen.
7114 With an argument, refresh the current line without clearing the
7115 screen.
7116 <DT><B>redraw-current-line</B>
7117
7118 <DD>
7119 Refresh the current line.
7120
7121 </DL>
7122 <A NAME="lbCO">&nbsp;</A>
7123 <H4>Commands for Manipulating the History</H4>
7124
7125 <P>
7126
7127
7128 <DL COMPACT>
7129 <DT><B>accept-line (Newline, Return)</B>
7130
7131 <DD>
7132 Accept the line regardless of where the cursor is. If this line is
7133 non-empty, add it to the history list according to the state of the
7134 <FONT SIZE=-1><B>HISTCONTROL</B>
7135
7136 </FONT>
7137 variable. If the line is a modified history
7138 line, then restore the history line to its original state.
7139 <DT><B>previous-history (C-p)</B>
7140
7141 <DD>
7142 Fetch the previous command from the history list, moving back in
7143 the list.
7144 <DT><B>next-history (C-n)</B>
7145
7146 <DD>
7147 Fetch the next command from the history list, moving forward in the
7148 list.
7149 <DT><B>beginning-of-history (M-&lt;)</B>
7150
7151 <DD>
7152 Move to the first line in the history.
7153 <DT><B>end-of-history (M-&gt;)</B>
7154
7155 <DD>
7156 Move to the end of the input history, i.e., the line currently being
7157 entered.
7158 <DT><B>reverse-search-history (C-r)</B>
7159
7160 <DD>
7161 Search backward starting at the current line and moving `up' through
7162 the history as necessary. This is an incremental search.
7163 <DT><B>forward-search-history (C-s)</B>
7164
7165 <DD>
7166 Search forward starting at the current line and moving `down' through
7167 the history as necessary. This is an incremental search.
7168 <DT><B>non-incremental-reverse-search-history (M-p)</B>
7169
7170 <DD>
7171 Search backward through the history starting at the current line
7172 using a non-incremental search for a string supplied by the user.
7173 <DT><B>non-incremental-forward-search-history (M-n)</B>
7174
7175 <DD>
7176 Search forward through the history using a non-incremental search for
7177 a string supplied by the user.
7178 <DT><B>history-search-forward</B>
7179
7180 <DD>
7181 Search forward through the history for the string of characters
7182 between the start of the current line and the point.
7183 This is a non-incremental search.
7184 <DT><B>history-search-backward</B>
7185
7186 <DD>
7187 Search backward through the history for the string of characters
7188 between the start of the current line and the point.
7189 This is a non-incremental search.
7190 <DT><B>yank-nth-arg (M-C-y)</B>
7191
7192 <DD>
7193 Insert the first argument to the previous command (usually
7194 the second word on the previous line) at point.
7195 With an argument
7196 <I>n</I>,
7197
7198 insert the <I>n</I>th word from the previous command (the words
7199 in the previous command begin with word 0). A negative argument
7200 inserts the <I>n</I>th word from the end of the previous command.
7201 Once the argument <I>n</I> is computed, the argument is extracted
7202 as if the &quot;!<I>n</I>&quot; history expansion had been specified.
7203 <DT><B>yank-last-arg (M-., M-_)</B>
7204
7205 <DD>
7206 Insert the last argument to the previous command (the last word of
7207 the previous history entry).
7208 With a numeric argument, behave exactly like <B>yank-nth-arg</B>.
7209 Successive calls to <B>yank-last-arg</B> move back through the history
7210 list, inserting the last word (or the word specified by the argument to
7211 the first call) of each line in turn.
7212 Any numeric argument supplied to these successive calls determines
7213 the direction to move through the history. A negative argument switches
7214 the direction through the history (back or forward).
7215 The history expansion facilities are used to extract the last argument,
7216 as if the &quot;!$&quot; history expansion had been specified.
7217 <DT><B>shell-expand-line (M-C-e)</B>
7218
7219 <DD>
7220 Expand the line as the shell does. This
7221 performs alias and history expansion as well as all of the shell
7222 word expansions. See
7223 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
7224
7225 </FONT>
7226 below for a description of history expansion.
7227 <DT><B>history-expand-line (M-^)</B>
7228
7229 <DD>
7230 Perform history expansion on the current line.
7231 See
7232 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
7233
7234 </FONT>
7235 below for a description of history expansion.
7236 <DT><B>magic-space</B>
7237
7238 <DD>
7239 Perform history expansion on the current line and insert a space.
7240 See
7241 <FONT SIZE=-1><B>HISTORY EXPANSION</B>
7242
7243 </FONT>
7244 below for a description of history expansion.
7245 <DT><B>alias-expand-line</B>
7246
7247 <DD>
7248 Perform alias expansion on the current line.
7249 See
7250 <FONT SIZE=-1><B>ALIASES</B>
7251
7252 </FONT>
7253 above for a description of alias expansion.
7254 <DT><B>history-and-alias-expand-line</B>
7255
7256 <DD>
7257 Perform history and alias expansion on the current line.
7258 <DT><B>insert-last-argument (M-., M-_)</B>
7259
7260 <DD>
7261 A synonym for <B>yank-last-arg</B>.
7262 <DT><B>operate-and-get-next (C-o)</B>
7263
7264 <DD>
7265 Accept the current line for execution and fetch the next line
7266 relative to the current line from the history for editing. Any
7267 argument is ignored.
7268 <DT><B>edit-and-execute-command (C-xC-e)</B>
7269
7270 <DD>
7271 Invoke an editor on the current command line, and execute the result as shell
7272 commands.
7273 <B>Bash</B> attempts to invoke
7274 <FONT SIZE=-1><B>$VISUAL</B>,
7275
7276 </FONT>
7277 <FONT SIZE=-1><B>$EDITOR</B>,
7278
7279 </FONT>
7280 and <I>emacs</I> as the editor, in that order.
7281
7282 </DL>
7283 <A NAME="lbCP">&nbsp;</A>
7284 <H4>Commands for Changing Text</H4>
7285
7286 <P>
7287
7288
7289 <DL COMPACT>
7290 <DT><B>delete-char (C-d)</B>
7291
7292 <DD>
7293 Delete the character at point. If point is at the
7294 beginning of the line, there are no characters in the line, and
7295 the last character typed was not bound to <B>delete-char</B>,
7296 then return
7297 <FONT SIZE=-1><B>EOF</B>.
7298
7299 </FONT>
7300 <DT><B>backward-delete-char (Rubout)</B>
7301
7302 <DD>
7303 Delete the character behind the cursor. When given a numeric argument,
7304 save the deleted text on the kill ring.
7305 <DT><B>forward-backward-delete-char</B>
7306
7307 <DD>
7308 Delete the character under the cursor, unless the cursor is at the
7309 end of the line, in which case the character behind the cursor is
7310 deleted.
7311 <DT><B>quoted-insert (C-q, C-v)</B>
7312
7313 <DD>
7314 Add the next character typed to the line verbatim. This is
7315 how to insert characters like <B>C-q</B>, for example.
7316 <DT><B>tab-insert (C-v TAB)</B>
7317
7318 <DD>
7319 Insert a tab character.
7320 <DT><B>self-insert (a,&nbsp;b,&nbsp;A,&nbsp;1,&nbsp;!,&nbsp;...)</B>
7321
7322 <DD>
7323 Insert the character typed.
7324 <DT><B>transpose-chars (C-t)</B>
7325
7326 <DD>
7327 Drag the character before point forward over the character at point,
7328 moving point forward as well.
7329 If point is at the end of the line, then this transposes
7330 the two characters before point.
7331 Negative arguments have no effect.
7332 <DT><B>transpose-words (M-t)</B>
7333
7334 <DD>
7335 Drag the word before point past the word after point,
7336 moving point over that word as well.
7337 If point is at the end of the line, this transposes
7338 the last two words on the line.
7339 <DT><B>upcase-word (M-u)</B>
7340
7341 <DD>
7342 Uppercase the current (or following) word. With a negative argument,
7343 uppercase the previous word, but do not move point.
7344 <DT><B>downcase-word (M-l)</B>
7345
7346 <DD>
7347 Lowercase the current (or following) word. With a negative argument,
7348 lowercase the previous word, but do not move point.
7349 <DT><B>capitalize-word (M-c)</B>
7350
7351 <DD>
7352 Capitalize the current (or following) word. With a negative argument,
7353 capitalize the previous word, but do not move point.
7354 <DT><B>overwrite-mode</B>
7355
7356 <DD>
7357 Toggle overwrite mode. With an explicit positive numeric argument,
7358 switches to overwrite mode. With an explicit non-positive numeric
7359 argument, switches to insert mode. This command affects only
7360 <B>emacs</B> mode; <B>vi</B> mode does overwrite differently.
7361 Each call to <I>readline()</I> starts in insert mode.
7362 In overwrite mode, characters bound to <B>self-insert</B> replace
7363 the text at point rather than pushing the text to the right.
7364 Characters bound to <B>backward-delete-char</B> replace the character
7365 before point with a space. By default, this command is unbound.
7366
7367 </DL>
7368 <A NAME="lbCQ">&nbsp;</A>
7369 <H4>Killing and Yanking</H4>
7370
7371 <P>
7372
7373
7374 <DL COMPACT>
7375 <DT><B>kill-line (C-k)</B>
7376
7377 <DD>
7378 Kill the text from point to the end of the line.
7379 <DT><B>backward-kill-line (C-x Rubout)</B>
7380
7381 <DD>
7382 Kill backward to the beginning of the line.
7383 <DT><B>unix-line-discard (C-u)</B>
7384
7385 <DD>
7386 Kill backward from point to the beginning of the line.
7387 The killed text is saved on the kill-ring.
7388
7389 <DT><B>kill-whole-line</B>
7390
7391 <DD>
7392 Kill all characters on the current line, no matter where point is.
7393 <DT><B>kill-word (M-d)</B>
7394
7395 <DD>
7396 Kill from point to the end of the current word, or if between
7397 words, to the end of the next word.
7398 Word boundaries are the same as those used by <B>forward-word</B>.
7399 <DT><B>backward-kill-word (M-Rubout)</B>
7400
7401 <DD>
7402 Kill the word behind point.
7403 Word boundaries are the same as those used by <B>backward-word</B>.
7404 <DT><B>shell-kill-word (M-d)</B>
7405
7406 <DD>
7407 Kill from point to the end of the current word, or if between
7408 words, to the end of the next word.
7409 Word boundaries are the same as those used by <B>shell-forward-word</B>.
7410 <DT><B>shell-backward-kill-word (M-Rubout)</B>
7411
7412 <DD>
7413 Kill the word behind point.
7414 Word boundaries are the same as those used by <B>shell-backward-word</B>.
7415 <DT><B>unix-word-rubout (C-w)</B>
7416
7417 <DD>
7418 Kill the word behind point, using white space as a word boundary.
7419 The killed text is saved on the kill-ring.
7420 <DT><B>unix-filename-rubout</B>
7421
7422 <DD>
7423 Kill the word behind point, using white space and the slash character
7424 as the word boundaries.
7425 The killed text is saved on the kill-ring.
7426 <DT><B>delete-horizontal-space (M-\)</B>
7427
7428 <DD>
7429 Delete all spaces and tabs around point.
7430 <DT><B>kill-region</B>
7431
7432 <DD>
7433 Kill the text in the current region.
7434 <DT><B>copy-region-as-kill</B>
7435
7436 <DD>
7437 Copy the text in the region to the kill buffer.
7438 <DT><B>copy-backward-word</B>
7439
7440 <DD>
7441 Copy the word before point to the kill buffer.
7442 The word boundaries are the same as <B>backward-word</B>.
7443 <DT><B>copy-forward-word</B>
7444
7445 <DD>
7446 Copy the word following point to the kill buffer.
7447 The word boundaries are the same as <B>forward-word</B>.
7448 <DT><B>yank (C-y)</B>
7449
7450 <DD>
7451 Yank the top of the kill ring into the buffer at point.
7452 <DT><B>yank-pop (M-y)</B>
7453
7454 <DD>
7455 Rotate the kill ring, and yank the new top. Only works following
7456 <B>yank</B>
7457
7458 or
7459 <B>yank-pop</B>.
7460
7461
7462 </DL>
7463 <A NAME="lbCR">&nbsp;</A>
7464 <H4>Numeric Arguments</H4>
7465
7466 <P>
7467
7468
7469 <DL COMPACT>
7470 <DT><B>digit-argument (M-0, M-1, ..., M--)</B>
7471
7472 <DD>
7473 Add this digit to the argument already accumulating, or start a new
7474 argument. M-- starts a negative argument.
7475 <DT><B>universal-argument</B>
7476
7477 <DD>
7478 This is another way to specify an argument.
7479 If this command is followed by one or more digits, optionally with a
7480 leading minus sign, those digits define the argument.
7481 If the command is followed by digits, executing
7482 <B>universal-argument</B>
7483
7484 again ends the numeric argument, but is otherwise ignored.
7485 As a special case, if this command is immediately followed by a
7486 character that is neither a digit or minus sign, the argument count
7487 for the next command is multiplied by four.
7488 The argument count is initially one, so executing this function the
7489 first time makes the argument count four, a second time makes the
7490 argument count sixteen, and so on.
7491
7492 </DL>
7493 <A NAME="lbCS">&nbsp;</A>
7494 <H4>Completing</H4>
7495
7496 <P>
7497
7498
7499 <DL COMPACT>
7500 <DT><B>complete (TAB)</B>
7501
7502 <DD>
7503 Attempt to perform completion on the text before point.
7504 <B>Bash</B>
7505
7506 attempts completion treating the text as a variable (if the
7507 text begins with <B>$</B>), username (if the text begins with
7508 <B>~</B>), hostname (if the text begins with <B>@</B>), or
7509 command (including aliases and functions) in turn. If none
7510 of these produces a match, filename completion is attempted.
7511 <DT><B>possible-completions (M-?)</B>
7512
7513 <DD>
7514 List the possible completions of the text before point.
7515 <DT><B>insert-completions (M-*)</B>
7516
7517 <DD>
7518 Insert all completions of the text before point
7519 that would have been generated by
7520 <B>possible-completions</B>.
7521 <DT><B>menu-complete</B>
7522
7523 <DD>
7524 Similar to <B>complete</B>, but replaces the word to be completed
7525 with a single match from the list of possible completions.
7526 Repeated execution of <B>menu-complete</B> steps through the list
7527 of possible completions, inserting each match in turn.
7528 At the end of the list of completions, the bell is rung
7529 (subject to the setting of <B>bell-style</B>)
7530 and the original text is restored.
7531 An argument of <I>n</I> moves <I>n</I> positions forward in the list
7532 of matches; a negative argument may be used to move backward
7533 through the list.
7534 This command is intended to be bound to <B>TAB</B>, but is unbound
7535 by default.
7536 <DT><B>menu-complete-backward</B>
7537
7538 <DD>
7539 Identical to <B>menu-complete</B>, but moves backward through the list
7540 of possible completions, as if <B>menu-complete</B> had been given a
7541 negative argument. This command is unbound by default.
7542 <DT><B>delete-char-or-list</B>
7543
7544 <DD>
7545 Deletes the character under the cursor if not at the beginning or
7546 end of the line (like <B>delete-char</B>).
7547 If at the end of the line, behaves identically to
7548 <B>possible-completions</B>.
7549 This command is unbound by default.
7550 <DT><B>complete-filename (M-/)</B>
7551
7552 <DD>
7553 Attempt filename completion on the text before point.
7554 <DT><B>possible-filename-completions (C-x /)</B>
7555
7556 <DD>
7557 List the possible completions of the text before point,
7558 treating it as a filename.
7559 <DT><B>complete-username (M-~)</B>
7560
7561 <DD>
7562 Attempt completion on the text before point, treating
7563 it as a username.
7564 <DT><B>possible-username-completions (C-x ~)</B>
7565
7566 <DD>
7567 List the possible completions of the text before point,
7568 treating it as a username.
7569 <DT><B>complete-variable (M-$)</B>
7570
7571 <DD>
7572 Attempt completion on the text before point, treating
7573 it as a shell variable.
7574 <DT><B>possible-variable-completions (C-x $)</B>
7575
7576 <DD>
7577 List the possible completions of the text before point,
7578 treating it as a shell variable.
7579 <DT><B>complete-hostname (M-@)</B>
7580
7581 <DD>
7582 Attempt completion on the text before point, treating
7583 it as a hostname.
7584 <DT><B>possible-hostname-completions (C-x @)</B>
7585
7586 <DD>
7587 List the possible completions of the text before point,
7588 treating it as a hostname.
7589 <DT><B>complete-command (M-!)</B>
7590
7591 <DD>
7592 Attempt completion on the text before point, treating
7593 it as a command name. Command completion attempts to
7594 match the text against aliases, reserved words, shell
7595 functions, shell builtins, and finally executable filenames,
7596 in that order.
7597 <DT><B>possible-command-completions (C-x !)</B>
7598
7599 <DD>
7600 List the possible completions of the text before point,
7601 treating it as a command name.
7602 <DT><B>dynamic-complete-history (M-TAB)</B>
7603
7604 <DD>
7605 Attempt completion on the text before point, comparing
7606 the text against lines from the history list for possible
7607 completion matches.
7608 <DT><B>dabbrev-expand</B>
7609
7610 <DD>
7611 Attempt menu completion on the text before point, comparing
7612 the text against lines from the history list for possible
7613 completion matches.
7614 <DT><B>complete-into-braces (M-{)</B>
7615
7616 <DD>
7617 Perform filename completion and insert the list of possible completions
7618 enclosed within braces so the list is available to the shell (see
7619 <B>Brace Expansion</B>
7620
7621 above).
7622
7623 </DL>
7624 <A NAME="lbCT">&nbsp;</A>
7625 <H4>Keyboard Macros</H4>
7626
7627 <P>
7628
7629
7630 <DL COMPACT>
7631 <DT><B>start-kbd-macro (C-x ()</B>
7632
7633 <DD>
7634 Begin saving the characters typed into the current keyboard macro.
7635 <DT><B>end-kbd-macro (C-x ))</B>
7636
7637 <DD>
7638 Stop saving the characters typed into the current keyboard macro
7639 and store the definition.
7640 <DT><B>call-last-kbd-macro (C-x e)</B>
7641
7642 <DD>
7643 Re-execute the last keyboard macro defined, by making the characters
7644 in the macro appear as if typed at the keyboard.
7645 <B>print-last-kbd-macro ()</B>
7646
7647 Print the last keyboard macro defined in a format suitable for the
7648 <I>inputrc</I> file.
7649
7650 </DL>
7651 <A NAME="lbCU">&nbsp;</A>
7652 <H4>Miscellaneous</H4>
7653
7654 <P>
7655
7656
7657 <DL COMPACT>
7658 <DT><B>re-read-init-file (C-x C-r)</B>
7659
7660 <DD>
7661 Read in the contents of the <I>inputrc</I> file, and incorporate
7662 any bindings or variable assignments found there.
7663 <DT><B>abort (C-g)</B>
7664
7665 <DD>
7666 Abort the current editing command and
7667 ring the terminal's bell (subject to the setting of
7668 <B>bell-style</B>).
7669
7670 <DT><B>do-uppercase-version (M-a, M-b, M-</B><I>x</I>, ...)
7671
7672 <DD>
7673 If the metafied character <I>x</I> is lowercase, run the command
7674 that is bound to the corresponding uppercase character.
7675 <DT><B>prefix-meta (ESC)</B>
7676
7677 <DD>
7678 Metafy the next character typed.
7679 <FONT SIZE=-1><B>ESC</B>
7680
7681 </FONT>
7682 <B>f</B>
7683
7684 is equivalent to
7685 <B>Meta-f</B>.
7686
7687 <DT><B>undo (C-_, C-x C-u)</B>
7688
7689 <DD>
7690 Incremental undo, separately remembered for each line.
7691 <DT><B>revert-line (M-r)</B>
7692
7693 <DD>
7694 Undo all changes made to this line. This is like executing the
7695 <B>undo</B>
7696
7697 command enough times to return the line to its initial state.
7698 <DT><B>tilde-expand (M-&amp;)</B>
7699
7700 <DD>
7701 Perform tilde expansion on the current word.
7702 <DT><B>set-mark (C-@, M-&lt;space&gt;)</B>
7703
7704 <DD>
7705 Set the mark to the point. If a
7706 numeric argument is supplied, the mark is set to that position.
7707 <DT><B>exchange-point-and-mark (C-x C-x)</B>
7708
7709 <DD>
7710 Swap the point with the mark. The current cursor position is set to
7711 the saved position, and the old cursor position is saved as the mark.
7712 <DT><B>character-search (C-])</B>
7713
7714 <DD>
7715 A character is read and point is moved to the next occurrence of that
7716 character. A negative count searches for previous occurrences.
7717 <DT><B>character-search-backward (M-C-])</B>
7718
7719 <DD>
7720 A character is read and point is moved to the previous occurrence of that
7721 character. A negative count searches for subsequent occurrences.
7722 <DT><B>skip-csi-sequence</B>
7723
7724 <DD>
7725 Read enough characters to consume a multi-key sequence such as those
7726 defined for keys like Home and End. Such sequences begin with a
7727 Control Sequence Indicator (CSI), usually ESC-[. If this sequence is
7728 bound to &quot;\[&quot;, keys producing such sequences will have no effect
7729 unless explicitly bound to a readline command, instead of inserting
7730 stray characters into the editing buffer. This is unbound by default,
7731 but usually bound to ESC-[.
7732 <DT><B>insert-comment (M-#)</B>
7733
7734 <DD>
7735 Without a numeric argument, the value of the readline
7736 <B>comment-begin</B>
7737
7738 variable is inserted at the beginning of the current line.
7739 If a numeric argument is supplied, this command acts as a toggle: if
7740 the characters at the beginning of the line do not match the value
7741 of <B>comment-begin</B>, the value is inserted, otherwise
7742 the characters in <B>comment-begin</B> are deleted from the beginning of
7743 the line.
7744 In either case, the line is accepted as if a newline had been typed.
7745 The default value of
7746 <B>comment-begin</B> causes this command to make the current line
7747 a shell comment.
7748 If a numeric argument causes the comment character to be removed, the line
7749 will be executed by the shell.
7750 <DT><B>glob-complete-word (M-g)</B>
7751
7752 <DD>
7753 The word before point is treated as a pattern for pathname expansion,
7754 with an asterisk implicitly appended. This pattern is used to
7755 generate a list of matching filenames for possible completions.
7756 <DT><B>glob-expand-word (C-x *)</B>
7757
7758 <DD>
7759 The word before point is treated as a pattern for pathname expansion,
7760 and the list of matching filenames is inserted, replacing the word.
7761 If a numeric argument is supplied, an asterisk is appended before
7762 pathname expansion.
7763 <DT><B>glob-list-expansions (C-x g)</B>
7764
7765 <DD>
7766 The list of expansions that would have been generated by
7767 <B>glob-expand-word</B>
7768
7769 is displayed, and the line is redrawn.
7770 If a numeric argument is supplied, an asterisk is appended before
7771 pathname expansion.
7772 <DT><B>dump-functions</B>
7773
7774 <DD>
7775 Print all of the functions and their key bindings to the
7776 readline output stream. If a numeric argument is supplied,
7777 the output is formatted in such a way that it can be made part
7778 of an <I>inputrc</I> file.
7779 <DT><B>dump-variables</B>
7780
7781 <DD>
7782 Print all of the settable readline variables and their values to the
7783 readline output stream. If a numeric argument is supplied,
7784 the output is formatted in such a way that it can be made part
7785 of an <I>inputrc</I> file.
7786 <DT><B>dump-macros</B>
7787
7788 <DD>
7789 Print all of the readline key sequences bound to macros and the
7790 strings they output. If a numeric argument is supplied,
7791 the output is formatted in such a way that it can be made part
7792 of an <I>inputrc</I> file.
7793 <DT><B>display-shell-version (C-x C-v)</B>
7794
7795 <DD>
7796 Display version information about the current instance of
7797 <B>bash</B>.
7798
7799
7800 </DL>
7801 <A NAME="lbCV">&nbsp;</A>
7802 <H4>Programmable Completion</H4>
7803
7804 <P>
7805
7806 When word completion is attempted for an argument to a command for
7807 which a completion specification (a <I>compspec</I>) has been defined
7808 using the <B>complete</B> builtin (see
7809 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
7810
7811 </FONT>
7812 below), the programmable completion facilities are invoked.
7813 <P>
7814
7815 First, the command name is identified.
7816 If the command word is the empty string (completion attempted at the
7817 beginning of an empty line), any compspec defined with
7818 the <B>-E</B> option to <B>complete</B> is used.
7819 If a compspec has been defined for that command, the
7820 compspec is used to generate the list of possible completions for the word.
7821 If the command word is a full pathname, a compspec for the full
7822 pathname is searched for first.
7823 If no compspec is found for the full pathname, an attempt is made to
7824 find a compspec for the portion following the final slash.
7825 If those searches do not result in a compspec, any compspec defined with
7826 the <B>-D</B> option to <B>complete</B> is used as the default.
7827 <P>
7828
7829 Once a compspec has been found, it is used to generate the list of
7830 matching words.
7831 If a compspec is not found, the default <B>bash</B> completion as
7832 described above under <B>Completing</B> is performed.
7833 <P>
7834
7835 First, the actions specified by the compspec are used.
7836 Only matches which are prefixed by the word being completed are
7837 returned.
7838 When the
7839 <B>-f</B>
7840
7841 or
7842 <B>-d</B>
7843
7844 option is used for filename or directory name completion, the shell
7845 variable
7846 <FONT SIZE=-1><B>FIGNORE</B>
7847
7848 </FONT>
7849 is used to filter the matches.
7850 <P>
7851
7852 Any completions specified by a pathname expansion pattern to the
7853 <B>-G</B> option are generated next.
7854 The words generated by the pattern need not match the word
7855 being completed.
7856 The
7857 <FONT SIZE=-1><B>GLOBIGNORE</B>
7858
7859 </FONT>
7860 shell variable is not used to filter the matches, but the
7861 <FONT SIZE=-1><B>FIGNORE</B>
7862
7863 </FONT>
7864 variable is used.
7865 <P>
7866
7867 Next, the string specified as the argument to the <B>-W</B> option
7868 is considered.
7869 The string is first split using the characters in the
7870 <FONT SIZE=-1><B>IFS</B>
7871
7872 </FONT>
7873 special variable as delimiters.
7874 Shell quoting is honored.
7875 Each word is then expanded using
7876 brace expansion, tilde expansion, parameter and variable expansion,
7877 command substitution, and arithmetic expansion,
7878 as described above under
7879 <FONT SIZE=-1><B>EXPANSION</B>.
7880
7881 </FONT>
7882 The results are split using the rules described above under
7883 <B>Word Splitting</B>.
7884 The results of the expansion are prefix-matched against the word being
7885 completed, and the matching words become the possible completions.
7886 <P>
7887
7888 After these matches have been generated, any shell function or command
7889 specified with the <B>-F</B> and <B>-C</B> options is invoked.
7890 When the command or function is invoked, the
7891 <FONT SIZE=-1><B>COMP_LINE</B>,
7892
7893 </FONT>
7894 <FONT SIZE=-1><B>COMP_POINT</B>,
7895
7896 </FONT>
7897 <FONT SIZE=-1><B>COMP_KEY</B>,
7898
7899 </FONT>
7900 and
7901 <FONT SIZE=-1><B>COMP_TYPE</B>
7902
7903 </FONT>
7904 variables are assigned values as described above under
7905 <B>Shell Variables</B>.
7906 If a shell function is being invoked, the
7907 <FONT SIZE=-1><B>COMP_WORDS</B>
7908
7909 </FONT>
7910 and
7911 <FONT SIZE=-1><B>COMP_CWORD</B>
7912
7913 </FONT>
7914 variables are also set.
7915 When the function or command is invoked,
7916 the first argument (<B>$1</B>) is the name of the command whose arguments are
7917 being completed,
7918 the second argument (<B>$2</B>) is the word being completed,
7919 and the third argument (<B>$3</B>) is the word preceding the word being
7920 completed on the current command line.
7921 No filtering of the generated completions against the word being completed
7922 is performed; the function or command has complete freedom in generating
7923 the matches.
7924 <P>
7925
7926 Any function specified with <B>-F</B> is invoked first.
7927 The function may use any of the shell facilities, including the
7928 <B>compgen</B> builtin described below, to generate the matches.
7929 It must put the possible completions in the
7930 <FONT SIZE=-1><B>COMPREPLY</B>
7931
7932 </FONT>
7933 array variable, one per array element.
7934 <P>
7935
7936 Next, any command specified with the <B>-C</B> option is invoked
7937 in an environment equivalent to command substitution.
7938 It should print a list of completions, one per line, to the
7939 standard output.
7940 Backslash may be used to escape a newline, if necessary.
7941 <P>
7942
7943 After all of the possible completions are generated, any filter
7944 specified with the <B>-X</B> option is applied to the list.
7945 The filter is a pattern as used for pathname expansion; a <B>&amp;</B>
7946 in the pattern is replaced with the text of the word being completed.
7947 A literal <B>&amp;</B> may be escaped with a backslash; the backslash
7948 is removed before attempting a match.
7949 Any completion that matches the pattern will be removed from the list.
7950 A leading <B>!</B> negates the pattern; in this case any completion
7951 not matching the pattern will be removed.
7952 <P>
7953
7954 Finally, any prefix and suffix specified with the <B>-P</B> and <B>-S</B>
7955 options are added to each member of the completion list, and the result is
7956 returned to the readline completion code as the list of possible
7957 completions.
7958 <P>
7959
7960 If the previously-applied actions do not generate any matches, and the
7961 <B>-o dirnames</B> option was supplied to <B>complete</B> when the
7962 compspec was defined, directory name completion is attempted.
7963 <P>
7964
7965 If the <B>-o plusdirs</B> option was supplied to <B>complete</B> when the
7966 compspec was defined, directory name completion is attempted and any
7967 matches are added to the results of the other actions.
7968 <P>
7969
7970 By default, if a compspec is found, whatever it generates is returned
7971 to the completion code as the full set of possible completions.
7972 The default <B>bash</B> completions are not attempted, and the readline
7973 default of filename completion is disabled.
7974 If the <B>-o bashdefault</B> option was supplied to <B>complete</B> when
7975 the compspec was defined, the <B>bash</B> default completions are attempted
7976 if the compspec generates no matches.
7977 If the <B>-o default</B> option was supplied to <B>complete</B> when the
7978 compspec was defined, readline's default completion will be performed
7979 if the compspec (and, if attempted, the default <B>bash</B> completions)
7980 generate no matches.
7981 <P>
7982
7983 When a compspec indicates that directory name completion is desired,
7984 the programmable completion functions force readline to append a slash
7985 to completed names which are symbolic links to directories, subject to
7986 the value of the <B>mark-directories</B> readline variable, regardless
7987 of the setting of the <B>mark-symlinked-directories</B> readline variable.
7988 <P>
7989
7990 There is some support for dynamically modifying completions. This is
7991 most useful when used in combination with a default completion specified
7992 with <B>complete -D</B>.
7993 It's possible for shell functions executed as completion
7994 handlers to indicate that completion should be retried by returning an
7995 exit status of 124. If a shell function returns 124, and changes
7996 the compspec associated with the command on which completion is being
7997 attempted (supplied as the first argument when the function is executed),
7998 programmable completion restarts from the beginning, with an
7999 attempt to find a new compspec for that command. This allows a set of
8000 completions to be built dynamically as completion is attempted, rather than
8001 being loaded all at once.
8002 <P>
8003
8004 For instance, assuming that there is a library of compspecs, each kept in a
8005 file corresponding to the name of the command, the following default
8006 completion function would load completions dynamically:
8007 <P>
8008
8009 <TT>_completion_loader()
8010 <BR>
8011
8012 {
8013 <BR>
8014
8015 <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>
8016 <BR>
8017
8018 }
8019 <BR>
8020
8021 complete -D -F _completion_loader
8022 <BR>
8023
8024 </TT>
8025 <A NAME="lbCW">&nbsp;</A>
8026 <H3>HISTORY</H3>
8027
8028 When the
8029 <B>-o history</B>
8030
8031 option to the
8032 <B>set</B>
8033
8034 builtin is enabled, the shell provides access to the
8035 <I>command history</I>,
8036 the list of commands previously typed.
8037 The value of the
8038 <FONT SIZE=-1><B>HISTSIZE</B>
8039
8040 </FONT>
8041 variable is used as the
8042 number of commands to save in a history list.
8043 The text of the last
8044 <FONT SIZE=-1><B>HISTSIZE</B>
8045
8046 </FONT>
8047 commands (default 500) is saved. The shell
8048 stores each command in the history list prior to parameter and
8049 variable expansion (see
8050 <FONT SIZE=-1><B>EXPANSION</B>
8051
8052 </FONT>
8053 above) but after history expansion is performed, subject to the
8054 values of the shell variables
8055 <FONT SIZE=-1><B>HISTIGNORE</B>
8056
8057 </FONT>
8058 and
8059 <FONT SIZE=-1><B>HISTCONTROL</B>.
8060
8061 </FONT>
8062 <P>
8063
8064 On startup, the history is initialized from the file named by
8065 the variable
8066 <FONT SIZE=-1><B>HISTFILE</B>
8067
8068 </FONT>
8069 (default <A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>).
8070 The file named by the value of
8071 <FONT SIZE=-1><B>HISTFILE</B>
8072
8073 </FONT>
8074 is truncated, if necessary, to contain no more than
8075 the number of lines specified by the value of
8076 <FONT SIZE=-1><B>HISTFILESIZE</B>.
8077
8078 </FONT>
8079 If <B>HISTFILESIZE</B> is unset, or set to null, a non-numeric value,
8080 or a numeric value less than zero, the history file is not truncated.
8081 When the history file is read,
8082 lines beginning with the history comment character followed immediately
8083 by a digit are interpreted as timestamps for the preceding history line.
8084 These timestamps are optionally displayed depending on the value of the
8085 <FONT SIZE=-1><B>HISTTIMEFORMAT</B>
8086
8087 </FONT>
8088 variable.
8089 When an interactive shell exits, the last
8090 <FONT SIZE=-1><B>$HISTSIZE</B>
8091
8092 </FONT>
8093 lines are copied from the history list to
8094 <FONT SIZE=-1><B>$HISTFILE</B>.
8095
8096 </FONT>
8097 If the
8098 <B>histappend</B>
8099
8100 shell option is enabled
8101 (see the description of
8102 <B>shopt</B>
8103
8104 under
8105 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
8106
8107 </FONT>
8108 below), the lines are appended to the history file,
8109 otherwise the history file is overwritten.
8110 If
8111 <FONT SIZE=-1><B>HISTFILE</B>
8112
8113 </FONT>
8114 is unset, or if the history file is unwritable, the history is
8115 not saved.
8116 If the
8117 <FONT SIZE=-1><B>HISTTIMEFORMAT</B>
8118
8119 </FONT>
8120 variable is set, time stamps are written to the history file, marked
8121 with the history comment character, so
8122 they may be preserved across shell sessions.
8123 This uses the history comment character to distinguish timestamps from
8124 other history lines.
8125 After saving the history, the history file is truncated
8126 to contain no more than
8127 <FONT SIZE=-1><B>HISTFILESIZE</B>
8128
8129 </FONT>
8130 lines. If
8131 <FONT SIZE=-1><B>HISTFILESIZE</B>
8132
8133 </FONT>
8134 is unset, or set to null, a non-numeric value,
8135 or a numeric value less than zero, the history file is not truncated.
8136 <P>
8137
8138 The builtin command
8139 <B>fc</B>
8140
8141 (see
8142 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
8143
8144 </FONT>
8145 below) may be used to list or edit and re-execute a portion of
8146 the history list.
8147 The
8148 <B>history</B>
8149
8150 builtin may be used to display or modify the history list and
8151 manipulate the history file.
8152 When using command-line editing, search commands
8153 are available in each editing mode that provide access to the
8154 history list.
8155 <P>
8156
8157 The shell allows control over which commands are saved on the history
8158 list. The
8159 <FONT SIZE=-1><B>HISTCONTROL</B>
8160
8161 </FONT>
8162 and
8163 <FONT SIZE=-1><B>HISTIGNORE</B>
8164
8165 </FONT>
8166 variables may be set to cause the shell to save only a subset of the
8167 commands entered.
8168 The
8169 <B>cmdhist</B>
8170
8171 shell option, if enabled, causes the shell to attempt to save each
8172 line of a multi-line command in the same history entry, adding
8173 semicolons where necessary to preserve syntactic correctness.
8174 The
8175 <B>lithist</B>
8176
8177 shell option causes the shell to save the command with embedded newlines
8178 instead of semicolons. See the description of the
8179 <B>shopt</B>
8180
8181 builtin below under
8182 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
8183
8184 </FONT>
8185 for information on setting and unsetting shell options.
8186 <A NAME="lbCX">&nbsp;</A>
8187 <H3>HISTORY EXPANSION</H3>
8188
8189 <P>
8190
8191 The shell supports a history expansion feature that
8192 is similar to the history expansion in
8193 <B>csh.</B>
8194
8195 This section describes what syntax features are available. This
8196 feature is enabled by default for interactive shells, and can be
8197 disabled using the
8198 <B>+H</B>
8199
8200 option to the
8201 <B>set</B>
8202
8203 builtin command (see
8204 <FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
8205
8206 </FONT>
8207 below). Non-interactive shells do not perform history expansion
8208 by default.
8209 <P>
8210
8211 History expansions introduce words from the history list into
8212 the input stream, making it easy to repeat commands, insert the
8213 arguments to a previous command into the current input line, or
8214 fix errors in previous commands quickly.
8215 <P>
8216
8217 History expansion is performed immediately after a complete line
8218 is read, before the shell breaks it into words.
8219 It takes place in two parts.
8220 The first is to determine which line from the history list
8221 to use during substitution.
8222 The second is to select portions of that line for inclusion into
8223 the current one.
8224 The line selected from the history is the <I>event</I>,
8225 and the portions of that line that are acted upon are <I>words</I>.
8226 Various <I>modifiers</I> are available to manipulate the selected words.
8227 The line is broken into words in the same fashion as when reading input,
8228 so that several <I>metacharacter</I>-separated words surrounded by
8229 quotes are considered one word.
8230 History expansions are introduced by the appearance of the
8231 history expansion character, which is <B>!</B> by default.
8232 Only backslash (<B>\</B>) and single quotes can quote
8233 the history expansion character.
8234 <P>
8235
8236 Several characters inhibit history expansion if found immediately
8237 following the history expansion character, even if it is unquoted:
8238 space, tab, newline, carriage return, and <B>=</B>.
8239 If the <B>extglob</B> shell option is enabled, <B>(</B> will also
8240 inhibit expansion.
8241 <P>
8242
8243 Several shell options settable with the
8244 <B>shopt</B>
8245
8246 builtin may be used to tailor the behavior of history expansion.
8247 If the
8248 <B>histverify</B>
8249
8250 shell option is enabled (see the description of the
8251 <B>shopt</B>
8252
8253 builtin below), and
8254 <B>readline</B>
8255
8256 is being used, history substitutions are not immediately passed to
8257 the shell parser.
8258 Instead, the expanded line is reloaded into the
8259 <B>readline</B>
8260
8261 editing buffer for further modification.
8262 If
8263 <B>readline</B>
8264
8265 is being used, and the
8266 <B>histreedit</B>
8267
8268 shell option is enabled, a failed history substitution will be reloaded
8269 into the
8270 <B>readline</B>
8271
8272 editing buffer for correction.
8273 The
8274 <B>-p</B>
8275
8276 option to the
8277 <B>history</B>
8278
8279 builtin command may be used to see what a history expansion will
8280 do before using it.
8281 The
8282 <B>-s</B>
8283
8284 option to the
8285 <B>history</B>
8286
8287 builtin may be used to add commands to the end of the history list
8288 without actually executing them, so that they are available for
8289 subsequent recall.
8290 <P>
8291
8292 The shell allows control of the various characters used by the
8293 history expansion mechanism (see the description of
8294 <B>histchars</B>
8295
8296 above under
8297 <B>Shell Variables</B>).
8298
8299 The shell uses
8300 the history comment character to mark history timestamps when
8301 writing the history file.
8302 <A NAME="lbCY">&nbsp;</A>
8303 <H4>Event Designators</H4>
8304
8305 <P>
8306
8307 An event designator is a reference to a command line entry in the
8308 history list.
8309 Unless the reference is absolute, events are relative to the current
8310 position in the history list.
8311 <P>
8312
8313
8314 <DL COMPACT>
8315 <DT><B>!</B>
8316
8317 <DD>
8318 Start a history substitution, except when followed by a
8319 <B>blank</B>,
8320
8321 newline, carriage return, =
8322 or ( (when the <B>extglob</B> shell option is enabled using
8323 the <B>shopt</B> builtin).
8324 <DT><B>!</B><I>n</I>
8325
8326 <DD>
8327 Refer to command line
8328 <I>n</I>.
8329
8330 <DT><B>!-</B><I>n</I>
8331
8332 <DD>
8333 Refer to the current command minus
8334 <I>n</I>.
8335
8336 <DT><B>!!</B>
8337
8338 <DD>
8339 Refer to the previous command. This is a synonym for `!-1'.
8340 <DT><B>!</B><I>string</I>
8341
8342 <DD>
8343 Refer to the most recent command preceding the current position in the
8344 history list starting with
8345 <I>string</I>.
8346
8347 <DT><B>!?</B><I>string</I><B>[?]</B>
8348
8349 <DD>
8350 Refer to the most recent command preceding the current position in the
8351 history list containing
8352 <I>string</I>.
8353
8354 The trailing <B>?</B> may be omitted if
8355 <I>string</I>
8356
8357 is followed immediately by a newline.
8358 <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>
8359
8360 <DD>
8361 Quick substitution. Repeat the previous command, replacing
8362 <I>string1</I>
8363
8364 with
8365 <I>string2</I>.
8366
8367 Equivalent to
8368 ``!!:s/<I>string1</I>/<I>string2</I>/''
8369 (see <B>Modifiers</B> below).
8370 <DT><B>!#</B>
8371
8372 <DD>
8373 The entire command line typed so far.
8374
8375 </DL>
8376 <A NAME="lbCZ">&nbsp;</A>
8377 <H4>Word Designators</H4>
8378
8379 <P>
8380
8381 Word designators are used to select desired words from the event.
8382 A
8383 <B>:</B>
8384
8385 separates the event specification from the word designator.
8386 It may be omitted if the word designator begins with a
8387 <B>^</B>,
8388
8389 <B>$</B>,
8390
8391 <B>*</B>,
8392
8393 <B>-</B>,
8394
8395 or
8396 <B>%</B>.
8397
8398 Words are numbered from the beginning of the line,
8399 with the first word being denoted by 0 (zero).
8400 Words are inserted into the current line separated by single spaces.
8401 <P>
8402
8403
8404 <DL COMPACT>
8405 <DT><B>0 (zero)</B>
8406
8407 <DD>
8408 The zeroth word. For the shell, this is the command
8409 word.
8410 <DT><I>n</I>
8411
8412 <DD>
8413 The <I>n</I>th word.
8414 <DT><B>^</B>
8415
8416 <DD>
8417 The first argument. That is, word 1.
8418 <DT><B>$</B>
8419
8420 <DD>
8421 The last argument.
8422 <DT><B>%</B>
8423
8424 <DD>
8425 The word matched by the most recent `?<I>string</I>?' search.
8426 <DT><I>x</I><B>-</B>y
8427
8428 <DD>
8429 A range of words; `-<I>y</I>' abbreviates `0-<I>y</I>'.
8430 <DT><B>*</B>
8431
8432 <DD>
8433 All of the words but the zeroth. This is a synonym
8434 for `<I>1-$</I>'. It is not an error to use
8435 <B>*</B>
8436
8437 if there is just one
8438 word in the event; the empty string is returned in that case.
8439 <DT><B>x*</B>
8440
8441 <DD>
8442 Abbreviates <I>x-$</I>.
8443 <DT><B>x-</B>
8444
8445 <DD>
8446 Abbreviates <I>x-$</I> like <B>x*</B>, but omits the last word.
8447
8448 </DL>
8449 <P>
8450
8451 If a word designator is supplied without an event specification, the
8452 previous command is used as the event.
8453 <A NAME="lbDA">&nbsp;</A>
8454 <H4>Modifiers</H4>
8455
8456 <P>
8457
8458 After the optional word designator, there may appear a sequence of
8459 one or more of the following modifiers, each preceded by a `:'.
8460 <P>
8461
8462
8463 <P>
8464
8465 <DL COMPACT>
8466 <DT><B>h</B>
8467
8468 <DD>
8469 Remove a trailing filename component, leaving only the head.
8470 <DT><B>t</B>
8471
8472 <DD>
8473 Remove all leading filename components, leaving the tail.
8474 <DT><B>r</B>
8475
8476 <DD>
8477 Remove a trailing suffix of the form <I>.xxx</I>, leaving the
8478 basename.
8479 <DT><B>e</B>
8480
8481 <DD>
8482 Remove all but the trailing suffix.
8483 <DT><B>p</B>
8484
8485 <DD>
8486 Print the new command but do not execute it.
8487 <DT><B>q</B>
8488
8489 <DD>
8490 Quote the substituted words, escaping further substitutions.
8491 <DT><B>x</B>
8492
8493 <DD>
8494 Quote the substituted words as with
8495 <B>q</B>,
8496
8497 but break into words at
8498 <B>blanks</B>
8499
8500 and newlines.
8501 <DT><B>s/</B><I>old</I>/<I>new</I>/
8502
8503 <DD>
8504 Substitute
8505 <I>new</I>
8506
8507 for the first occurrence of
8508 <I>old</I>
8509
8510 in the event line. Any delimiter can be used in place of /. The
8511 final delimiter is optional if it is the last character of the
8512 event line. The delimiter may be quoted in
8513 <I>old</I>
8514
8515 and
8516 <I>new</I>
8517
8518 with a single backslash. If &amp; appears in
8519 <I>new</I>,
8520
8521 it is replaced by
8522 <I>old</I>.
8523
8524 A single backslash will quote the &amp;. If
8525 <I>old</I>
8526
8527 is null, it is set to the last
8528 <I>old</I>
8529
8530 substituted, or, if no previous history substitutions took place,
8531 the last
8532 <I>string</I>
8533
8534 in a
8535 <B>!?</B><I>string</I><B>[?]</B>
8536
8537 search.
8538 <DT><B>&amp;</B>
8539
8540 <DD>
8541 Repeat the previous substitution.
8542 <DT><B>g</B>
8543
8544 <DD>
8545 Cause changes to be applied over the entire event line. This is
8546 used in conjunction with `<B>:s</B>' (e.g., `<B>:gs/</B><I>old</I>/<I>new</I>/')
8547 or `<B>:&amp;</B>'. If used with
8548 `<B>:s</B>', any delimiter can be used
8549 in place of /, and the final delimiter is optional
8550 if it is the last character of the event line.
8551 An <B>a</B> may be used as a synonym for <B>g</B>.
8552 <DT><B>G</B>
8553
8554 <DD>
8555 Apply the following `<B>s</B>' modifier once to each word in the event line.
8556
8557 </DL>
8558 <A NAME="lbDB">&nbsp;</A>
8559 <H3>SHELL BUILTIN COMMANDS</H3>
8560
8561
8562
8563 <P>
8564
8565 Unless otherwise noted, each builtin command documented in this
8566 section as accepting options preceded by
8567 <B>-</B>
8568
8569 accepts
8570 <B>--</B>
8571
8572 to signify the end of the options.
8573 The <B>:</B>, <B>true</B>, <B>false</B>, and <B>test</B> builtins
8574 do not accept options and do not treat <B>--</B> specially.
8575 The <B>exit</B>, <B>logout</B>, <B>break</B>, <B>continue</B>, <B>let</B>,
8576 and <B>shift</B> builtins accept and process arguments beginning with
8577 <B>-</B> without requiring <B>--</B>.
8578 Other builtins that accept arguments but are not specified as accepting
8579 options interpret arguments beginning with <B>-</B> as invalid options and
8580 require <B>--</B> to prevent this interpretation.
8581 <P>
8582
8583 <DL COMPACT>
8584 <DT><B>:</B> [<I>arguments</I>]<DD>
8585
8586 No effect; the command does nothing beyond expanding
8587 <I>arguments</I>
8588
8589 and performing any specified
8590 redirections. A zero exit code is returned.
8591 <DT><B> . </B> <I>filename</I> [<I>arguments</I>]<DD>
8592
8593 <DT><B>source</B> <I>filename</I> [<I>arguments</I>]<DD>
8594
8595 Read and execute commands from
8596 <I>filename</I>
8597
8598 in the current
8599 shell environment and return the exit status of the last command
8600 executed from
8601 <I>filename</I>.
8602
8603 If
8604 <I>filename</I>
8605
8606 does not contain a slash, filenames in
8607 <FONT SIZE=-1><B>PATH</B>
8608
8609 </FONT>
8610 are used to find the directory containing
8611 <I>filename</I>.
8612
8613 The file searched for in
8614 <FONT SIZE=-1><B>PATH</B>
8615
8616 </FONT>
8617 need not be executable.
8618 When <B>bash</B> is not in <I>posix mode</I>, the current directory is
8619 searched if no file is found in
8620 <FONT SIZE=-1><B>PATH</B>.
8621
8622 </FONT>
8623 If the
8624 <B>sourcepath</B>
8625
8626 option to the
8627 <B>shopt</B>
8628
8629 builtin command is turned off, the
8630 <FONT SIZE=-1><B>PATH</B>
8631
8632 </FONT>
8633 is not searched.
8634 If any <I>arguments</I> are supplied, they become the positional
8635 parameters when <I>filename</I> is executed. Otherwise the positional
8636 parameters are unchanged.
8637 The return status is the status of the last command exited within
8638 the script (0 if no commands are executed), and false if
8639 <I>filename</I>
8640
8641 is not found or cannot be read.
8642 <DT><B>alias</B> [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
8643 <B>Alias</B> with no arguments or with the
8644 <B>-p</B>
8645
8646 option prints the list of aliases in the form
8647 <B>alias</B> <I>name</I>=<I>value</I> on standard output.
8648 When arguments are supplied, an alias is defined for
8649 each <I>name</I> whose <I>value</I> is given.
8650 A trailing space in <I>value</I> causes the next word to be
8651 checked for alias substitution when the alias is expanded.
8652 For each <I>name</I> in the argument list for which no <I>value</I>
8653 is supplied, the name and value of the alias is printed.
8654 <B>Alias</B> returns true unless a <I>name</I> is given for which
8655 no alias has been defined.
8656 <DT><B>bg</B> [<I>jobspec</I> ...]<DD>
8657 Resume each suspended job <I>jobspec</I> in the background, as if it
8658 had been started with
8659 <B>&amp;</B>.
8660
8661 If
8662 <I>jobspec</I>
8663
8664 is not present, the shell's notion of the <I>current job</I> is used.
8665 <B>bg</B>
8666
8667 <I>jobspec</I>
8668
8669 returns 0 unless run when job control is disabled or, when run with
8670 job control enabled, any specified <I>jobspec</I> was not found
8671 or was started without job control.
8672 <DT><B>bind</B> [<B>-m</B> <I>keymap</I>] [<B>-lpsvPSVX</B>]<DD>
8673
8674 <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>
8675 <DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <B>-f</B> <I>filename</I><DD>
8676 <DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <B>-x</B> <I>keyseq</I>:<I>shell-command</I><DD>
8677 <DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <I>keyseq</I>:<I>function-name</I><DD>
8678 <DT><B>bind</B> <I>readline-command</I><DD>
8679
8680 Display current
8681 <B>readline</B>
8682
8683 key and function bindings, bind a key sequence to a
8684 <B>readline</B>
8685
8686 function or macro, or set a
8687 <B>readline</B>
8688
8689 variable.
8690 Each non-option argument is a command as it would appear in
8691 <I>.inputrc</I>,
8692
8693 but each binding or command must be passed as a separate argument;
8694 e.g., '&quot;\C-x\C-r&quot;: re-read-init-file'.
8695 Options, if supplied, have the following meanings:
8696 <DL COMPACT><DT><DD>
8697
8698 <DL COMPACT>
8699 <DT><B>-m </B><I>keymap</I>
8700
8701 <DD>
8702 Use
8703 <I>keymap</I>
8704
8705 as the keymap to be affected by the subsequent bindings.
8706 Acceptable
8707 <I>keymap</I>
8708
8709 names are
8710 <I>emacs, emacs-standard, emacs-meta, emacs-ctlx, vi,
8711 vi-move, vi-command</I>, and
8712 <I>vi-insert</I>.
8713
8714 <I>vi</I> is equivalent to <I>vi-command</I>; <I>emacs</I> is
8715 equivalent to <I>emacs-standard</I>.
8716 <DT><B>-l</B>
8717
8718 <DD>
8719 List the names of all <B>readline</B> functions.
8720 <DT><B>-p</B>
8721
8722 <DD>
8723 Display <B>readline</B> function names and bindings in such a way
8724 that they can be re-read.
8725 <DT><B>-P</B>
8726
8727 <DD>
8728 List current <B>readline</B> function names and bindings.
8729 <DT><B>-s</B>
8730
8731 <DD>
8732 Display <B>readline</B> key sequences bound to macros and the strings
8733 they output in such a way that they can be re-read.
8734 <DT><B>-S</B>
8735
8736 <DD>
8737 Display <B>readline</B> key sequences bound to macros and the strings
8738 they output.
8739 <DT><B>-v</B>
8740
8741 <DD>
8742 Display <B>readline</B> variable names and values in such a way that they
8743 can be re-read.
8744 <DT><B>-V</B>
8745
8746 <DD>
8747 List current <B>readline</B> variable names and values.
8748 <DT><B>-f </B><I>filename</I>
8749
8750 <DD>
8751 Read key bindings from <I>filename</I>.
8752 <DT><B>-q </B><I>function</I>
8753
8754 <DD>
8755 Query about which keys invoke the named <I>function</I>.
8756 <DT><B>-u </B><I>function</I>
8757
8758 <DD>
8759 Unbind all keys bound to the named <I>function</I>.
8760 <DT><B>-r </B><I>keyseq</I>
8761
8762 <DD>
8763 Remove any current binding for <I>keyseq</I>.
8764 <DT><B>-x </B><I>keyseq</I>:<I>shell-command</I>
8765
8766 <DD>
8767 Cause <I>shell-command</I> to be executed whenever <I>keyseq</I> is
8768 entered.
8769 When <I>shell-command</I> is executed, the shell sets the
8770 <FONT SIZE=-1><B>READLINE_LINE</B>
8771
8772 </FONT>
8773 variable to the contents of the <B>readline</B> line buffer and the
8774 <FONT SIZE=-1><B>READLINE_POINT</B>
8775
8776 </FONT>
8777 variable to the current location of the insertion point.
8778 If the executed command changes the value of
8779 <FONT SIZE=-1><B>READLINE_LINE</B>
8780
8781 </FONT>
8782 or
8783 <FONT SIZE=-1><B>READLINE_POINT</B>,
8784
8785 </FONT>
8786 those new values will be reflected in the editing state.
8787 <DT><B>-X</B>
8788
8789 <DD>
8790 List all key sequences bound to shell commands and the associated commands
8791 in a format that can be reused as input.
8792
8793 </DL>
8794 <P>
8795
8796 The return value is 0 unless an unrecognized option is given or an
8797 error occurred.
8798 </DL>
8799
8800 <DT><B>break</B> [<I>n</I>]<DD>
8801 Exit from within a
8802 <B>for</B>,
8803
8804 <B>while</B>,
8805
8806 <B>until</B>,
8807
8808 or
8809 <B>select</B>
8810
8811 loop. If <I>n</I> is specified, break <I>n</I> levels.
8812 <I>n</I>
8813
8814 must be >= 1. If
8815 <I>n</I>
8816
8817 is greater than the number of enclosing loops, all enclosing loops
8818 are exited.
8819 The return value is 0 unless <I>n</I> is not greater than or equal to 1.
8820 <DT><B>builtin</B> <I>shell-builtin</I> [<I>arguments</I>]<DD>
8821 Execute the specified shell builtin, passing it
8822 <I>arguments</I>,
8823
8824 and return its exit status.
8825 This is useful when defining a
8826 function whose name is the same as a shell builtin,
8827 retaining the functionality of the builtin within the function.
8828 The <B>cd</B> builtin is commonly redefined this way.
8829 The return status is false if
8830 <I>shell-builtin</I>
8831
8832 is not a shell builtin command.
8833 <DT><B>caller</B> [<I>expr</I>]<DD>
8834 Returns the context of any active subroutine call (a shell function or
8835 a script executed with the <B>.</B> or <B>source</B> builtins).
8836 Without <I>expr</I>, <B>caller</B> displays the line number and source
8837 filename of the current subroutine call.
8838 If a non-negative integer is supplied as <I>expr</I>, <B>caller</B>
8839 displays the line number, subroutine name, and source file corresponding
8840 to that position in the current execution call stack. This extra
8841 information may be used, for example, to print a stack trace. The
8842 current frame is frame 0.
8843 The return value is 0 unless the shell is not executing a subroutine
8844 call or <I>expr</I> does not correspond to a valid position in the
8845 call stack.
8846 <DT><B>cd</B> [<B>-L</B>|[<B>-P</B> [<B>-e</B>]]] [<I>dir</I>]<DD>
8847 Change the current directory to <I>dir</I>.
8848 if <I>dir</I> is not supplied, the value of the
8849 <FONT SIZE=-1><B>HOME</B>
8850
8851 </FONT>
8852 shell variable is the default.
8853 Any additional arguments following <I>dir</I> are ignored.
8854 The variable
8855 <FONT SIZE=-1><B>CDPATH</B>
8856
8857 </FONT>
8858 defines the search path for the directory containing
8859 <I>dir</I>:
8860
8861 each directory name in
8862 <FONT SIZE=-1><B>CDPATH</B>
8863
8864 </FONT>
8865 is searched for <I>dir</I>.
8866 Alternative directory names in
8867 <FONT SIZE=-1><B>CDPATH</B>
8868
8869 </FONT>
8870 are separated by a colon (:). A null directory name in
8871 <FONT SIZE=-1><B>CDPATH</B>
8872
8873 </FONT>
8874 is the same as the current directory, i.e., ``<B>.</B>''. If
8875 <I>dir</I>
8876
8877 begins with a slash (/),
8878 then
8879 <FONT SIZE=-1><B>CDPATH</B>
8880
8881 </FONT>
8882 is not used. The
8883 <B>-P</B>
8884
8885 option causes <B>cd</B> to use the physical directory structure
8886 by resolving symbolic links while traversing <I>dir</I> and
8887 before processing instances of <I>..</I> in <I>dir</I> (see also the
8888 <B>-P</B>
8889
8890 option to the
8891 <B>set</B>
8892
8893 builtin command); the
8894 <B>-L</B>
8895
8896 option forces symbolic links to be followed by resolving the link
8897 after processing instances of <I>..</I> in <I>dir</I>.
8898 If <I>..</I> appears in <I>dir</I>, it is processed by removing the
8899 immediately previous pathname component from <I>dir</I>, back to a slash
8900 or the beginning of <I>dir</I>.
8901 If the
8902 <B>-e</B>
8903
8904 option is supplied with
8905 <B>-P</B>,
8906
8907 and the current working directory cannot be successfully determined
8908 after a successful directory change, <B>cd</B> will return an unsuccessful
8909 status.
8910 An argument of
8911 <B>-</B>
8912
8913 is converted to
8914 <FONT SIZE=-1><B>$OLDPWD</B>
8915
8916 </FONT>
8917 before the directory change is attempted.
8918 If a non-empty directory name from
8919 <FONT SIZE=-1><B>CDPATH</B>
8920
8921 </FONT>
8922 is used, or if
8923 <B>-</B> is the first argument, and the directory change is
8924 successful, the absolute pathname of the new working directory is
8925 written to the standard output.
8926 The return value is true if the directory was successfully changed;
8927 false otherwise.
8928 <DT><B>command</B> [<B>-pVv</B>] <I>command</I> [<I>arg</I> ...]<DD>
8929 Run
8930 <I>command</I>
8931
8932 with
8933 <I>args</I>
8934
8935 suppressing the normal shell function lookup. Only builtin
8936 commands or commands found in the
8937 <FONT SIZE=-1><B>PATH</B>
8938
8939 </FONT>
8940 are executed. If the
8941 <B>-p</B>
8942
8943 option is given, the search for
8944 <I>command</I>
8945
8946 is performed using a default value for
8947 <FONT SIZE=-1><B>PATH</B>
8948
8949 </FONT>
8950 that is guaranteed to find all of the standard utilities.
8951 If either the
8952 <B>-V</B>
8953
8954 or
8955 <B>-v</B>
8956
8957 option is supplied, a description of
8958 <I>command</I>
8959
8960 is printed. The
8961 <B>-v</B>
8962
8963 option causes a single word indicating the command or filename
8964 used to invoke
8965 <I>command</I>
8966
8967 to be displayed; the
8968 <B>-V</B>
8969
8970 option produces a more verbose description.
8971 If the
8972 <B>-V</B>
8973
8974 or
8975 <B>-v</B>
8976
8977 option is supplied, the exit status is 0 if
8978 <I>command</I>
8979
8980 was found, and 1 if not. If neither option is supplied and
8981 an error occurred or
8982 <I>command</I>
8983
8984 cannot be found, the exit status is 127. Otherwise, the exit status of the
8985 <B>command</B>
8986
8987 builtin is the exit status of
8988 <I>command</I>.
8989
8990 <DT><B>compgen</B> [<I>option</I>] [<I>word</I>]<DD>
8991 Generate possible completion matches for <I>word</I> according to
8992 the <I>option</I>s, which may be any option accepted by the
8993 <B>complete</B>
8994
8995 builtin with the exception of <B>-p</B> and <B>-r</B>, and write
8996 the matches to the standard output.
8997 When using the <B>-F</B> or <B>-C</B> options, the various shell variables
8998 set by the programmable completion facilities, while available, will not
8999 have useful values.
9000 <P>
9001 The matches will be generated in the same way as if the programmable
9002 completion code had generated them directly from a completion specification
9003 with the same flags.
9004 If <I>word</I> is specified, only those completions matching <I>word</I>
9005 will be displayed.
9006 <P>
9007 The return value is true unless an invalid option is supplied, or no
9008 matches were generated.
9009 <DT><B>complete</B> [<B>-abcdefgjksuv</B>] [<B>-o</B> <I>comp-option</I>] [<B>-DE</B>] [<B>-A</B> <I>action</I>] [<B>-G</B> <I>globpat</I>] [<B>-W</B> <I>wordlist</I>] [<B>-F</B> <I>function</I>] [<B>-C</B> <I>command</I>]<DD>
9010 <BR>
9011
9012 [<B>-X</B> <I>filterpat</I>] [<B>-P</B> <I>prefix</I>] [<B>-S</B> <I>suffix</I>] <I>name</I> [<I>name ...</I>]
9013
9014 <DT><B>complete</B> <B>-pr</B> [<B>-DE</B>] [<I>name</I> ...]<DD>
9015
9016 Specify how arguments to each <I>name</I> should be completed.
9017 If the <B>-p</B> option is supplied, or if no options are supplied,
9018 existing completion specifications are printed in a way that allows
9019 them to be reused as input.
9020 The <B>-r</B> option removes a completion specification for
9021 each <I>name</I>, or, if no <I>name</I>s are supplied, all
9022 completion specifications.
9023 The <B>-D</B> option indicates that the remaining options and actions should
9024 apply to the ``default'' command completion; that is, completion attempted
9025 on a command for which no completion has previously been defined.
9026 The <B>-E</B> option indicates that the remaining options and actions should
9027 apply to ``empty'' command completion; that is, completion attempted on a
9028 blank line.
9029 <P>
9030 The process of applying these completion specifications when word completion
9031 is attempted is described above under <B>Programmable Completion</B>.
9032 <P>
9033 Other options, if specified, have the following meanings.
9034 The arguments to the <B>-G</B>, <B>-W</B>, and <B>-X</B> options
9035 (and, if necessary, the <B>-P</B> and <B>-S</B> options)
9036 should be quoted to protect them from expansion before the
9037 <B>complete</B>
9038
9039 builtin is invoked.
9040 <DL COMPACT><DT><DD>
9041
9042 <DL COMPACT>
9043 <DT><B>-o</B> <I>comp-option</I><DD>
9044 The <I>comp-option</I> controls several aspects of the compspec's behavior
9045 beyond the simple generation of completions.
9046 <I>comp-option</I> may be one of:
9047 <DL COMPACT><DT><DD>
9048 <DL COMPACT>
9049 <DT><B>bashdefault</B>
9050
9051 <DD>
9052 Perform the rest of the default <B>bash</B> completions if the compspec
9053 generates no matches.
9054 <DT><B>default</B>
9055
9056 <DD>
9057 Use readline's default filename completion if the compspec generates
9058 no matches.
9059 <DT><B>dirnames</B>
9060
9061 <DD>
9062 Perform directory name completion if the compspec generates no matches.
9063 <DT><B>filenames</B>
9064
9065 <DD>
9066 Tell readline that the compspec generates filenames, so it can perform any
9067 filename-specific processing (like adding a slash to directory names,
9068 quoting special characters, or suppressing trailing spaces).
9069 Intended to be used with shell functions.
9070 <DT><B>noquote</B>
9071
9072 <DD>
9073 Tell readline not to quote the completed words if they are filenames
9074 (quoting filenames is the default).
9075 <DT><B>nospace</B>
9076
9077 <DD>
9078 Tell readline not to append a space (the default) to words completed at
9079 the end of the line.
9080 <DT><B>plusdirs</B>
9081
9082 <DD>
9083 After any matches defined by the compspec are generated,
9084 directory name completion is attempted and any
9085 matches are added to the results of the other actions.
9086 </DL></DL>
9087
9088 <DT><B>-A</B> <I>action</I><DD>
9089 The <I>action</I> may be one of the following to generate a list of possible
9090 completions:
9091 <DL COMPACT><DT><DD>
9092 <DL COMPACT>
9093 <DT><B>alias</B>
9094
9095 <DD>
9096 Alias names. May also be specified as <B>-a</B>.
9097 <DT><B>arrayvar</B>
9098
9099 <DD>
9100 Array variable names.
9101 <DT><B>binding</B>
9102
9103 <DD>
9104 <B>Readline</B> key binding names.
9105 <DT><B>builtin</B>
9106
9107 <DD>
9108 Names of shell builtin commands. May also be specified as <B>-b</B>.
9109 <DT><B>command</B>
9110
9111 <DD>
9112 Command names. May also be specified as <B>-c</B>.
9113 <DT><B>directory</B>
9114
9115 <DD>
9116 Directory names. May also be specified as <B>-d</B>.
9117 <DT><B>disabled</B>
9118
9119 <DD>
9120 Names of disabled shell builtins.
9121 <DT><B>enabled</B>
9122
9123 <DD>
9124 Names of enabled shell builtins.
9125 <DT><B>export</B>
9126
9127 <DD>
9128 Names of exported shell variables. May also be specified as <B>-e</B>.
9129 <DT><B>file</B>
9130
9131 <DD>
9132 File names. May also be specified as <B>-f</B>.
9133 <DT><B>function</B>
9134
9135 <DD>
9136 Names of shell functions.
9137 <DT><B>group</B>
9138
9139 <DD>
9140 Group names. May also be specified as <B>-g</B>.
9141 <DT><B>helptopic</B>
9142
9143 <DD>
9144 Help topics as accepted by the <B>help</B> builtin.
9145 <DT><B>hostname</B>
9146
9147 <DD>
9148 Hostnames, as taken from the file specified by the
9149 <FONT SIZE=-1><B>HOSTFILE</B>
9150
9151 </FONT>
9152 shell variable.
9153 <DT><B>job</B>
9154
9155 <DD>
9156 Job names, if job control is active. May also be specified as <B>-j</B>.
9157 <DT><B>keyword</B>
9158
9159 <DD>
9160 Shell reserved words. May also be specified as <B>-k</B>.
9161 <DT><B>running</B>
9162
9163 <DD>
9164 Names of running jobs, if job control is active.
9165 <DT><B>service</B>
9166
9167 <DD>
9168 Service names. May also be specified as <B>-s</B>.
9169 <DT><B>setopt</B>
9170
9171 <DD>
9172 Valid arguments for the <B>-o</B> option to the <B>set</B> builtin.
9173 <DT><B>shopt</B>
9174
9175 <DD>
9176 Shell option names as accepted by the <B>shopt</B> builtin.
9177 <DT><B>signal</B>
9178
9179 <DD>
9180 Signal names.
9181 <DT><B>stopped</B>
9182
9183 <DD>
9184 Names of stopped jobs, if job control is active.
9185 <DT><B>user</B>
9186
9187 <DD>
9188 User names. May also be specified as <B>-u</B>.
9189 <DT><B>variable</B>
9190
9191 <DD>
9192 Names of all shell variables. May also be specified as <B>-v</B>.
9193 </DL></DL>
9194
9195 <DT><B>-C</B> <I>command</I><DD>
9196 <I>command</I> is executed in a subshell environment, and its output is
9197 used as the possible completions.
9198 <DT><B>-F</B> <I>function</I><DD>
9199 The shell function <I>function</I> is executed in the current shell
9200 environment.
9201 When the function is executed,
9202 the first argument (<B>$1</B>) is the name of the command whose arguments are
9203 being completed,
9204 the second argument (<B>$2</B>) is the word being completed,
9205 and the third argument (<B>$3</B>) is the word preceding the word being
9206 completed on the current command line.
9207 When it finishes, the possible completions are retrieved from the value
9208 of the
9209 <FONT SIZE=-1><B>COMPREPLY</B>
9210
9211 </FONT>
9212 array variable.
9213 <DT><B>-G</B> <I>globpat</I><DD>
9214 The pathname expansion pattern <I>globpat</I> is expanded to generate
9215 the possible completions.
9216 <DT><B>-P</B> <I>prefix</I><DD>
9217 <I>prefix</I> is added at the beginning of each possible completion
9218 after all other options have been applied.
9219 <DT><B>-S</B> <I>suffix</I><DD>
9220 <I>suffix</I> is appended to each possible completion
9221 after all other options have been applied.
9222 <DT><B>-W</B> <I>wordlist</I><DD>
9223 The <I>wordlist</I> is split using the characters in the
9224 <FONT SIZE=-1><B>IFS</B>
9225
9226 </FONT>
9227 special variable as delimiters, and each resultant word is expanded.
9228 The possible completions are the members of the resultant list which
9229 match the word being completed.
9230 <DT><B>-X</B> <I>filterpat</I><DD>
9231 <I>filterpat</I> is a pattern as used for pathname expansion.
9232 It is applied to the list of possible completions generated by the
9233 preceding options and arguments, and each completion matching
9234 <I>filterpat</I> is removed from the list.
9235 A leading <B>!</B> in <I>filterpat</I> negates the pattern; in this
9236 case, any completion not matching <I>filterpat</I> is removed.
9237
9238 </DL>
9239 <P>
9240
9241 The return value is true unless an invalid option is supplied, an option
9242 other than <B>-p</B> or <B>-r</B> is supplied without a <I>name</I>
9243 argument, an attempt is made to remove a completion specification for
9244 a <I>name</I> for which no specification exists, or
9245 an error occurs adding a completion specification.
9246 </DL>
9247
9248 <DT><B>compopt</B> [<B>-o</B> <I>option</I>] [<B>-DE</B>] [<B>+o</B> <I>option</I>] [<I>name</I>]<DD>
9249 Modify completion options for each <I>name</I> according to the
9250 <I>option</I>s, or for the
9251 currently-executing completion if no <I>name</I>s are supplied.
9252 If no <I>option</I>s are given, display the completion options for each
9253 <I>name</I> or the current completion.
9254 The possible values of <I>option</I> are those valid for the <B>complete</B>
9255 builtin described above.
9256 The <B>-D</B> option indicates that the remaining options should
9257 apply to the ``default'' command completion; that is, completion attempted
9258 on a command for which no completion has previously been defined.
9259 The <B>-E</B> option indicates that the remaining options should
9260 apply to ``empty'' command completion; that is, completion attempted on a
9261 blank line.
9262 <P>
9263 The return value is true unless an invalid option is supplied, an attempt
9264 is made to modify the options for a <I>name</I> for which no completion
9265 specification exists, or an output error occurs.
9266 <DT><B>continue</B> [<I>n</I>]<DD>
9267 Resume the next iteration of the enclosing
9268 <B>for</B>,
9269
9270 <B>while</B>,
9271
9272 <B>until</B>,
9273
9274 or
9275 <B>select</B>
9276
9277 loop.
9278 If
9279 <I>n</I>
9280
9281 is specified, resume at the <I>n</I>th enclosing loop.
9282 <I>n</I>
9283
9284 must be >= 1. If
9285 <I>n</I>
9286
9287 is greater than the number of enclosing loops, the last enclosing loop
9288 (the ``top-level'' loop) is resumed.
9289 The return value is 0 unless <I>n</I> is not greater than or equal to 1.
9290 <DT><B>declare</B> [<B>-aAfFgilrtux</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
9291
9292 <DT><B>typeset</B> [<B>-aAfFgilrtux</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
9293
9294 Declare variables and/or give them attributes.
9295 If no <I>name</I>s are given then display the values of variables.
9296 The
9297 <B>-p</B>
9298
9299 option will display the attributes and values of each
9300 <I>name</I>.
9301
9302 When
9303 <B>-p</B>
9304
9305 is used with <I>name</I> arguments, additional options are ignored.
9306 When
9307 <B>-p</B>
9308
9309 is supplied without <I>name</I> arguments, it will display the attributes
9310 and values of all variables having the attributes specified by the
9311 additional options.
9312 If no other options are supplied with <B>-p</B>, <B>declare</B> will display
9313 the attributes and values of all shell variables. The <B>-f</B> option
9314 will restrict the display to shell functions.
9315 The
9316 <B>-F</B>
9317
9318 option inhibits the display of function definitions; only the
9319 function name and attributes are printed.
9320 If the <B>extdebug</B> shell option is enabled using <B>shopt</B>,
9321 the source file name and line number where the function is defined
9322 are displayed as well. The
9323 <B>-F</B>
9324
9325 option implies
9326 <B>-f</B>.
9327
9328 The
9329 <B>-g</B>
9330
9331 option forces variables to be created or modified at the global scope,
9332 even when <B>declare</B> is executed in a shell function.
9333 It is ignored in all other cases.
9334 The following options can
9335 be used to restrict output to variables with the specified attribute or
9336 to give variables attributes:
9337 <DL COMPACT><DT><DD>
9338
9339 <DL COMPACT>
9340 <DT><B>-a</B>
9341
9342 <DD>
9343 Each <I>name</I> is an indexed array variable (see
9344 <B>Arrays</B>
9345
9346 above).
9347 <DT><B>-A</B>
9348
9349 <DD>
9350 Each <I>name</I> is an associative array variable (see
9351 <B>Arrays</B>
9352
9353 above).
9354 <DT><B>-f</B>
9355
9356 <DD>
9357 Use function names only.
9358 <DT><B>-i</B>
9359
9360 <DD>
9361 The variable is treated as an integer; arithmetic evaluation (see
9362 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
9363
9364 </FONT>
9365 above) is performed when the variable is assigned a value.
9366 <DT><B>-l</B>
9367
9368 <DD>
9369 When the variable is assigned a value, all upper-case characters are
9370 converted to lower-case.
9371 The upper-case attribute is disabled.
9372 <DT><B>-r</B>
9373
9374 <DD>
9375 Make <I>name</I>s readonly. These names cannot then be assigned values
9376 by subsequent assignment statements or unset.
9377 <DT><B>-t</B>
9378
9379 <DD>
9380 Give each <I>name</I> the <I>trace</I> attribute.
9381 Traced functions inherit the <B>DEBUG</B> and <B>RETURN</B> traps from
9382 the calling shell.
9383 The trace attribute has no special meaning for variables.
9384 <DT><B>-u</B>
9385
9386 <DD>
9387 When the variable is assigned a value, all lower-case characters are
9388 converted to upper-case.
9389 The lower-case attribute is disabled.
9390 <DT><B>-x</B>
9391
9392 <DD>
9393 Mark <I>name</I>s for export to subsequent commands via the environment.
9394
9395 </DL>
9396 <P>
9397
9398 Using `+' instead of `-'
9399 turns off the attribute instead,
9400 with the exceptions that <B>+a</B>
9401 may not be used to destroy an array variable and <B>+r</B> will not
9402 remove the readonly attribute.
9403 When used in a function,
9404 <B>declare</B>
9405
9406 and
9407 <B>typeset</B>
9408
9409 make each
9410 <I>name</I> local, as with the
9411 <B>local</B>
9412
9413 command,
9414 unless the <B>-g</B> option is supplied.
9415 If a variable name is followed by =<I>value</I>, the value of
9416 the variable is set to <I>value</I>.
9417 The return value is 0 unless an invalid option is encountered,
9418 an attempt is made to define a function using
9419
9420 <TT>-f foo=bar</TT>,
9421 an attempt is made to assign a value to a readonly variable,
9422 an attempt is made to assign a value to an array variable without
9423 using the compound assignment syntax (see
9424 <B>Arrays</B>
9425
9426 above), one of the <I>names</I> is not a valid shell variable name,
9427 an attempt is made to turn off readonly status for a readonly variable,
9428 an attempt is made to turn off array status for an array variable,
9429 or an attempt is made to display a non-existent function with <B>-f</B>.
9430 </DL>
9431
9432 <DT><B>dirs [-clpv</B>] [+<I>n</I>] [-<I>n</I>]
9433
9434 <DD>
9435 Without options, displays the list of currently remembered directories.
9436 The default display is on a single line with directory names separated
9437 by spaces.
9438 Directories are added to the list with the
9439 <B>pushd</B>
9440
9441 command; the
9442 <B>popd</B>
9443
9444 command removes entries from the list.
9445 <DL COMPACT><DT><DD>
9446
9447 <DL COMPACT>
9448 <DT><B>-c</B>
9449
9450 <DD>
9451 Clears the directory stack by deleting all of the entries.
9452 <DT><B>-l</B>
9453
9454 <DD>
9455 Produces a listing using full pathnames;
9456 the default listing format uses a tilde to denote the home directory.
9457 <DT><B>-p</B>
9458
9459 <DD>
9460 Print the directory stack with one entry per line.
9461 <DT><B>-v</B>
9462
9463 <DD>
9464 Print the directory stack with one entry per line,
9465 prefixing each entry with its index in the stack.
9466 <DT><B>+</B><I>n</I><DD>
9467 Displays the <I>n</I>th entry counting from the left of the list
9468 shown by
9469 <B>dirs</B>
9470
9471 when invoked without options, starting with zero.
9472 <DT><B>-</B><I>n</I><DD>
9473 Displays the <I>n</I>th entry counting from the right of the list
9474 shown by
9475 <B>dirs</B>
9476
9477 when invoked without options, starting with zero.
9478
9479 </DL>
9480 <P>
9481
9482 The return value is 0 unless an
9483 invalid option is supplied or <I>n</I> indexes beyond the end
9484 of the directory stack.
9485 </DL>
9486
9487 <DT><B>disown</B> [<B>-ar</B>] [<B>-h</B>] [<I>jobspec</I> ...]<DD>
9488 Without options, remove each
9489 <I>jobspec</I>
9490
9491 from the table of active jobs.
9492 If
9493 <I>jobspec</I>
9494
9495 is not present, and neither <B>-a</B> nor <B>-r</B> is supplied,
9496 the shell's notion of the <I>current job</I> is used.
9497 If the <B>-h</B> option is given, each
9498 <I>jobspec</I>
9499
9500 is not removed from the table, but is marked so that
9501 <FONT SIZE=-1><B>SIGHUP</B>
9502
9503 </FONT>
9504 is not sent to the job if the shell receives a
9505 <FONT SIZE=-1><B>SIGHUP</B>.
9506
9507 </FONT>
9508 If no
9509 <I>jobspec</I>
9510
9511 is present, and neither the
9512 <B>-a</B>
9513
9514 nor the
9515 <B>-r</B>
9516
9517 option is supplied, the <I>current job</I> is used.
9518 If no
9519 <I>jobspec</I>
9520
9521 is supplied, the
9522 <B>-a</B>
9523
9524 option means to remove or mark all jobs; the
9525 <B>-r</B>
9526
9527 option without a
9528 <I>jobspec</I>
9529
9530 argument restricts operation to running jobs.
9531 The return value is 0 unless a
9532 <I>jobspec</I>
9533
9534 does not specify a valid job.
9535 <DT><B>echo</B> [<B>-neE</B>] [<I>arg</I> ...]<DD>
9536 Output the <I>arg</I>s, separated by spaces, followed by a newline.
9537 The return status is 0 unless a write error occurs.
9538 If <B>-n</B> is specified, the trailing newline is
9539 suppressed. If the <B>-e</B> option is given, interpretation of
9540 the following backslash-escaped characters is enabled. The
9541 <B>-E</B>
9542
9543 option disables the interpretation of these escape characters,
9544 even on systems where they are interpreted by default.
9545 The <B>xpg_echo</B> shell option may be used to
9546 dynamically determine whether or not <B>echo</B> expands these
9547 escape characters by default.
9548 <B>echo</B>
9549
9550 does not interpret <B>--</B> to mean the end of options.
9551 <B>echo</B>
9552
9553 interprets the following escape sequences:
9554 <DL COMPACT><DT><DD>
9555
9556 <DL COMPACT>
9557 <DT><B>\a</B>
9558
9559 <DD>
9560 alert (bell)
9561 <DT><B>\b</B>
9562
9563 <DD>
9564 backspace
9565 <DT><B>\c</B>
9566
9567 <DD>
9568 suppress further output
9569 <DT><B>\e</B>
9570
9571 <DD>
9572 <DT><B>\E</B>
9573
9574 <DD>
9575 an escape character
9576 <DT><B>\f</B>
9577
9578 <DD>
9579 form feed
9580 <DT><B>\n</B>
9581
9582 <DD>
9583 new line
9584 <DT><B>\r</B>
9585
9586 <DD>
9587 carriage return
9588 <DT><B>\t</B>
9589
9590 <DD>
9591 horizontal tab
9592 <DT><B>\v</B>
9593
9594 <DD>
9595 vertical tab
9596 <DT><B>\\</B>
9597
9598 <DD>
9599 backslash
9600 <DT><B>\0</B><I>nnn</I>
9601
9602 <DD>
9603 the eight-bit character whose value is the octal value <I>nnn</I>
9604 (zero to three octal digits)
9605 <DT><B>\x</B><I>HH</I>
9606
9607 <DD>
9608 the eight-bit character whose value is the hexadecimal value <I>HH</I>
9609 (one or two hex digits)
9610 <DT><B>\u</B><I>HHHH</I>
9611
9612 <DD>
9613 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
9614 <I>HHHH</I> (one to four hex digits)
9615 <DT><B>\U</B><I>HHHHHHHH</I>
9616
9617 <DD>
9618 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
9619 <I>HHHHHHHH</I> (one to eight hex digits)
9620
9621 </DL></DL>
9622
9623 <DT><B>enable</B> [<B>-a</B>] [<B>-dnps</B>] [<B>-f</B> <I>filename</I>] [<I>name</I> ...]<DD>
9624 Enable and disable builtin shell commands.
9625 Disabling a builtin allows a disk command which has the same name
9626 as a shell builtin to be executed without specifying a full pathname,
9627 even though the shell normally searches for builtins before disk commands.
9628 If <B>-n</B> is used, each <I>name</I>
9629 is disabled; otherwise,
9630 <I>names</I> are enabled. For example, to use the
9631 <B>test</B>
9632
9633 binary found via the
9634 <FONT SIZE=-1><B>PATH</B>
9635
9636 </FONT>
9637 instead of the shell builtin version, run
9638 <TT>enable -n test</TT>.
9639
9640 The
9641 <B>-f</B>
9642
9643 option means to load the new builtin command
9644 <I>name</I>
9645
9646 from shared object
9647 <I>filename</I>,
9648
9649 on systems that support dynamic loading. The
9650 <B>-d</B>
9651
9652 option will delete a builtin previously loaded with
9653 <B>-f</B>.
9654
9655 If no <I>name</I> arguments are given, or if the
9656 <B>-p</B>
9657
9658 option is supplied, a list of shell builtins is printed.
9659 With no other option arguments, the list consists of all enabled
9660 shell builtins.
9661 If <B>-n</B> is supplied, only disabled builtins are printed.
9662 If <B>-a</B> is supplied, the list printed includes all builtins, with an
9663 indication of whether or not each is enabled.
9664 If <B>-s</B> is supplied, the output is restricted to the POSIX
9665 <I>special</I> builtins.
9666 The return value is 0 unless a
9667 <I>name</I>
9668
9669 is not a shell builtin or there is an error loading a new builtin
9670 from a shared object.
9671 <DT><B>eval</B> [<I>arg</I> ...]<DD>
9672 The <I>arg</I>s are read and concatenated together into a single
9673 command. This command is then read and executed by the shell, and
9674 its exit status is returned as the value of
9675 <B>eval</B>.
9676
9677 If there are no
9678 <I>args</I>,
9679
9680 or only null arguments,
9681 <B>eval</B>
9682
9683 returns 0.
9684 <DT><B>exec</B> [<B>-cl</B>] [<B>-a</B> <I>name</I>] [<I>command</I> [<I>arguments</I>]]<DD>
9685 If
9686 <I>command</I>
9687
9688 is specified, it replaces the shell.
9689 No new process is created. The
9690 <I>arguments</I>
9691
9692 become the arguments to <I>command</I>.
9693 If the
9694 <B>-l</B>
9695
9696 option is supplied,
9697 the shell places a dash at the beginning of the zeroth argument passed to
9698 <I>command</I>.
9699
9700 This is what
9701 <I>login</I>(1)
9702
9703 does. The
9704 <B>-c</B>
9705
9706 option causes
9707 <I>command</I>
9708
9709 to be executed with an empty environment. If
9710 <B>-a</B>
9711
9712 is supplied, the shell passes
9713 <I>name</I>
9714
9715 as the zeroth argument to the executed command.
9716 If
9717 <I>command</I>
9718
9719 cannot be executed for some reason, a non-interactive shell exits,
9720 unless the
9721 <B>execfail</B>
9722
9723 shell option
9724 is enabled. In that case, it returns failure.
9725 An interactive shell returns failure if the file cannot be executed.
9726 If
9727 <I>command</I>
9728
9729 is not specified, any redirections take effect in the current shell,
9730 and the return status is 0. If there is a redirection error, the
9731 return status is 1.
9732 <DT><B>exit</B> [<I>n</I>]<DD>
9733 Cause the shell to exit
9734 with a status of <I>n</I>. If
9735 <I>n</I>
9736
9737 is omitted, the exit status
9738 is that of the last command executed.
9739 A trap on
9740 <FONT SIZE=-1><B>EXIT</B>
9741
9742 </FONT>
9743 is executed before the shell terminates.
9744 <DT><B>export</B> [<B>-fn</B>] [<I>name</I>[=<I>word</I>]] ...<DD>
9745
9746 <DT><B>export -p</B>
9747
9748 <DD>
9749
9750 The supplied
9751 <I>names</I>
9752
9753 are marked for automatic export to the environment of
9754 subsequently executed commands. If the
9755 <B>-f</B>
9756
9757 option is given,
9758 the
9759 <I>names</I>
9760
9761 refer to functions.
9762 If no
9763 <I>names</I>
9764
9765 are given, or if the
9766 <B>-p</B>
9767
9768 option is supplied, a list
9769 of names of all exported variables is printed.
9770 The
9771 <B>-n</B>
9772
9773 option causes the export property to be removed from each
9774 <I>name</I>.
9775 If a variable name is followed by =<I>word</I>, the value of
9776 the variable is set to <I>word</I>.
9777 <B>export</B>
9778
9779 returns an exit status of 0 unless an invalid option is
9780 encountered,
9781 one of the <I>names</I> is not a valid shell variable name, or
9782 <B>-f</B>
9783
9784 is supplied with a
9785 <I>name</I>
9786
9787 that is not a function.
9788 <DT><B>fc</B> [<B>-e</B> <I>ename</I>] [<B>-lnr</B>] [<I>first</I>] [<I>last</I>]<DD>
9789
9790 <DT><B>fc</B> <B>-s</B> [<I>pat</I>=<I>rep</I>] [<I>cmd</I>]<DD>
9791
9792 The first form selects a range of commands from
9793 <I>first</I>
9794
9795 to
9796 <I>last</I>
9797
9798 from the history list and displays or edits and re-executes them.
9799 <I>First</I>
9800
9801 and
9802 <I>last</I>
9803
9804 may be specified as a string (to locate the last command beginning
9805 with that string) or as a number (an index into the history list,
9806 where a negative number is used as an offset from the current
9807 command number). If
9808 <I>last</I>
9809
9810 is not specified it is set to
9811 the current command for listing (so that
9812
9813 <TT>fc -l -10</TT>
9814 prints the last 10 commands) and to
9815 <I>first</I>
9816
9817 otherwise.
9818 If
9819 <I>first</I>
9820
9821 is not specified it is set to the previous
9822 command for editing and -16 for listing.
9823 <P>
9824 The
9825 <B>-n</B>
9826
9827 option suppresses
9828 the command numbers when listing. The
9829 <B>-r</B>
9830
9831 option reverses the order of
9832 the commands. If the
9833 <B>-l</B>
9834
9835 option is given,
9836 the commands are listed on
9837 standard output. Otherwise, the editor given by
9838 <I>ename</I>
9839
9840 is invoked
9841 on a file containing those commands. If
9842 <I>ename</I>
9843
9844 is not given, the
9845 value of the
9846 <FONT SIZE=-1><B>FCEDIT</B>
9847
9848 </FONT>
9849 variable is used, and
9850 the value of
9851 <FONT SIZE=-1><B>EDITOR</B>
9852
9853 </FONT>
9854 if
9855 <FONT SIZE=-1><B>FCEDIT</B>
9856
9857 </FONT>
9858 is not set. If neither variable is set,
9859
9860 <I>vi</I>
9861
9862 is used. When editing is complete, the edited commands are
9863 echoed and executed.
9864 <P>
9865 In the second form, <I>command</I> is re-executed after each instance
9866 of <I>pat</I> is replaced by <I>rep</I>.
9867 <I>Command</I> is intepreted the same as <I>first</I> above.
9868 A useful alias to use with this is
9869
9870 <TT>r='fc -s'</TT>,
9871 so that typing
9872
9873 <TT>r cc</TT>
9874 runs the last command beginning with
9875
9876 <TT>cc</TT>
9877 and typing
9878
9879 <TT>r</TT>
9880 re-executes the last command.
9881 <P>
9882 If the first form is used, the return value is 0 unless an invalid
9883 option is encountered or
9884 <I>first</I>
9885
9886 or
9887 <I>last</I>
9888
9889 specify history lines out of range.
9890 If the
9891 <B>-e</B>
9892
9893 option is supplied, the return value is the value of the last
9894 command executed or failure if an error occurs with the temporary
9895 file of commands. If the second form is used, the return status
9896 is that of the command re-executed, unless
9897 <I>cmd</I>
9898
9899 does not specify a valid history line, in which case
9900 <B>fc</B>
9901
9902 returns failure.
9903 <DT><B>fg</B> [<I>jobspec</I>]<DD>
9904 Resume
9905 <I>jobspec</I>
9906
9907 in the foreground, and make it the current job.
9908 If
9909 <I>jobspec</I>
9910
9911 is not present, the shell's notion of the <I>current job</I> is used.
9912 The return value is that of the command placed into the foreground,
9913 or failure if run when job control is disabled or, when run with
9914 job control enabled, if
9915 <I>jobspec</I>
9916
9917 does not specify a valid job or
9918 <I>jobspec</I>
9919
9920 specifies a job that was started without job control.
9921 <DT><B>getopts</B> <I>optstring</I> <I>name</I> [<I>args</I>]<DD>
9922 <B>getopts</B>
9923
9924 is used by shell procedures to parse positional parameters.
9925 <I>optstring</I>
9926
9927 contains the option characters to be recognized; if a character
9928 is followed by a colon, the option is expected to have an
9929 argument, which should be separated from it by white space.
9930 The colon and question mark characters may not be used as
9931 option characters.
9932 Each time it is invoked,
9933 <B>getopts</B>
9934
9935 places the next option in the shell variable
9936 <I>name</I>,
9937
9938 initializing
9939 <I>name</I>
9940
9941 if it does not exist,
9942 and the index of the next argument to be processed into the
9943 variable
9944 <FONT SIZE=-1><B>OPTIND</B>.
9945
9946 </FONT>
9947 <FONT SIZE=-1><B>OPTIND</B>
9948
9949 </FONT>
9950 is initialized to 1 each time the shell or a shell script
9951 is invoked. When an option requires an argument,
9952 <B>getopts</B>
9953
9954 places that argument into the variable
9955 <FONT SIZE=-1><B>OPTARG</B>.
9956
9957 </FONT>
9958 The shell does not reset
9959 <FONT SIZE=-1><B>OPTIND</B>
9960
9961 </FONT>
9962 automatically; it must be manually reset between multiple
9963 calls to
9964 <B>getopts</B>
9965
9966 within the same shell invocation if a new set of parameters
9967 is to be used.
9968 <P>
9969 When the end of options is encountered, <B>getopts</B> exits with a
9970 return value greater than zero.
9971 <FONT SIZE=-1><B>OPTIND</B>
9972
9973 </FONT>
9974 is set to the index of the first non-option argument,
9975 and <I>name</I> is set to ?.
9976 <P>
9977 <B>getopts</B>
9978
9979 normally parses the positional parameters, but if more arguments are
9980 given in
9981 <I>args</I>,
9982
9983 <B>getopts</B>
9984
9985 parses those instead.
9986 <P>
9987 <B>getopts</B>
9988
9989 can report errors in two ways. If the first character of
9990 <I>optstring</I>
9991
9992 is a colon,
9993 <I>silent</I>
9994
9995 error reporting is used. In normal operation, diagnostic messages
9996 are printed when invalid options or missing option arguments are
9997 encountered.
9998 If the variable
9999 <FONT SIZE=-1><B>OPTERR</B>
10000
10001 </FONT>
10002 is set to 0, no error messages will be displayed, even if the first
10003 character of
10004 <I>optstring</I>
10005
10006 is not a colon.
10007 <P>
10008 If an invalid option is seen,
10009 <B>getopts</B>
10010
10011 places ? into
10012 <I>name</I>
10013
10014 and, if not silent,
10015 prints an error message and unsets
10016 <FONT SIZE=-1><B>OPTARG</B>.
10017
10018 </FONT>
10019 If
10020 <B>getopts</B>
10021
10022 is silent,
10023 the option character found is placed in
10024 <FONT SIZE=-1><B>OPTARG</B>
10025
10026 </FONT>
10027 and no diagnostic message is printed.
10028 <P>
10029 If a required argument is not found, and
10030 <B>getopts</B>
10031
10032 is not silent,
10033 a question mark (<B>?</B>) is placed in
10034 <I>name</I>,
10035
10036 <FONT SIZE=-1><B>OPTARG</B>
10037
10038 </FONT>
10039 is unset, and a diagnostic message is printed.
10040 If
10041 <B>getopts</B>
10042
10043 is silent, then a colon (<B>:</B>) is placed in
10044 <I>name</I>
10045
10046 and
10047 <FONT SIZE=-1><B>OPTARG</B>
10048
10049 </FONT>
10050 is set to the option character found.
10051 <P>
10052 <B>getopts</B>
10053
10054 returns true if an option, specified or unspecified, is found.
10055 It returns false if the end of options is encountered or an
10056 error occurs.
10057 <DT><B>hash</B> [<B>-lr</B>] [<B>-p</B> <I>filename</I>] [<B>-dt</B>] [<I>name</I>]<DD>
10058 Each time <B>hash</B> is invoked,
10059 the full pathname of the command
10060 <I>name</I>
10061
10062 is determined by searching
10063 the directories in
10064 <B>$PATH</B>
10065
10066 and remembered. Any previously-remembered pathname is discarded.
10067 If the
10068 <B>-p</B>
10069
10070 option is supplied, no path search is performed, and
10071 <I>filename</I>
10072
10073 is used as the full filename of the command.
10074 The
10075 <B>-r</B>
10076
10077 option causes the shell to forget all
10078 remembered locations.
10079 The
10080 <B>-d</B>
10081
10082 option causes the shell to forget the remembered location of each <I>name</I>.
10083 If the
10084 <B>-t</B>
10085
10086 option is supplied, the full pathname to which each <I>name</I> corresponds
10087 is printed. If multiple <I>name</I> arguments are supplied with <B>-t</B>,
10088 the <I>name</I> is printed before the hashed full pathname.
10089 The
10090 <B>-l</B>
10091
10092 option causes output to be displayed in a format that may be reused as input.
10093 If no arguments are given, or if only <B>-l</B> is supplied,
10094 information about remembered commands is printed.
10095 The return status is true unless a
10096 <I>name</I>
10097
10098 is not found or an invalid option is supplied.
10099 <DT><B>help</B> [<B>-dms</B>] [<I>pattern</I>]<DD>
10100 Display helpful information about builtin commands. If
10101 <I>pattern</I>
10102
10103 is specified,
10104 <B>help</B>
10105
10106 gives detailed help on all commands matching
10107 <I>pattern</I>;
10108
10109 otherwise help for all the builtins and shell control structures
10110 is printed.
10111 <DL COMPACT><DT><DD>
10112
10113 <DL COMPACT>
10114 <DT><B>-d</B>
10115
10116 <DD>
10117 Display a short description of each <I>pattern</I>
10118 <DT><B>-m</B>
10119
10120 <DD>
10121 Display the description of each <I>pattern</I> in a manpage-like format
10122 <DT><B>-s</B>
10123
10124 <DD>
10125 Display only a short usage synopsis for each <I>pattern</I>
10126
10127 </DL>
10128 <P>
10129
10130 The return status is 0 unless no command matches
10131 <I>pattern</I>.
10132
10133 </DL>
10134
10135 <DT><B>history [</B><I>n</I>]<DD>
10136
10137 <DT><B>history</B> <B>-c</B><DD>
10138 <DT><B>history -d</B> <I>offset</I><DD>
10139 <DT><B>history</B> <B>-anrw</B> [<I>filename</I>]<DD>
10140 <DT><B>history</B> <B>-p</B> <I>arg</I> [<I>arg ...</I>]<DD>
10141 <DT><B>history</B> <B>-s</B> <I>arg</I> [<I>arg ...</I>]<DD>
10142
10143 With no options, display the command
10144 history list with line numbers. Lines listed
10145 with a
10146 <B>*</B>
10147
10148 have been modified. An argument of
10149 <I>n</I>
10150
10151 lists only the last
10152 <I>n</I>
10153
10154 lines.
10155 If the shell variable
10156 <FONT SIZE=-1><B>HISTTIMEFORMAT</B>
10157
10158 </FONT>
10159 is set and not null,
10160 it is used as a format string for <I>strftime</I>(3) to display
10161 the time stamp associated with each displayed history entry.
10162 No intervening blank is printed between the formatted time stamp
10163 and the history line.
10164 If <I>filename</I> is supplied, it is used as the
10165 name of the history file; if not, the value of
10166 <FONT SIZE=-1><B>HISTFILE</B>
10167
10168 </FONT>
10169 is used. Options, if supplied, have the following meanings:
10170 <DL COMPACT><DT><DD>
10171
10172 <DL COMPACT>
10173 <DT><B>-c</B>
10174
10175 <DD>
10176 Clear the history list by deleting all the entries.
10177 <DT><B>-d</B> <I>offset</I><DD>
10178 Delete the history entry at position <I>offset</I>.
10179 <DT><B>-a</B>
10180
10181 <DD>
10182 Append the ``new'' history lines (history lines entered since the
10183 beginning of the current <B>bash</B> session) to the history file.
10184 <DT><B>-n</B>
10185
10186 <DD>
10187 Read the history lines not already read from the history
10188 file into the current history list. These are lines
10189 appended to the history file since the beginning of the
10190 current <B>bash</B> session.
10191 <DT><B>-r</B>
10192
10193 <DD>
10194 Read the contents of the history file
10195 and append them to the current history list.
10196 <DT><B>-w</B>
10197
10198 <DD>
10199 Write the current history list to the history file, overwriting the
10200 history file's contents.
10201 <DT><B>-p</B>
10202
10203 <DD>
10204 Perform history substitution on the following <I>args</I> and display
10205 the result on the standard output.
10206 Does not store the results in the history list.
10207 Each <I>arg</I> must be quoted to disable normal history expansion.
10208 <DT><B>-s</B>
10209
10210 <DD>
10211 Store the
10212 <I>args</I>
10213
10214 in the history list as a single entry. The last command in the
10215 history list is removed before the
10216 <I>args</I>
10217
10218 are added.
10219
10220 </DL>
10221 <P>
10222
10223 If the
10224 <FONT SIZE=-1><B>HISTTIMEFORMAT</B>
10225
10226 </FONT>
10227 variable is set, the time stamp information
10228 associated with each history entry is written to the history file,
10229 marked with the history comment character.
10230 When the history file is read, lines beginning with the history
10231 comment character followed immediately by a digit are interpreted
10232 as timestamps for the previous history line.
10233 The return value is 0 unless an invalid option is encountered, an
10234 error occurs while reading or writing the history file, an invalid
10235 <I>offset</I> is supplied as an argument to <B>-d</B>, or the
10236 history expansion supplied as an argument to <B>-p</B> fails.
10237 </DL>
10238
10239 <DT><B>jobs</B> [<B>-lnprs</B>] [ <I>jobspec</I> ... ]<DD>
10240
10241 <DT><B>jobs</B> <B>-x</B> <I>command</I> [ <I>args</I> ... ]<DD>
10242
10243 The first form lists the active jobs. The options have the following
10244 meanings:
10245 <DL COMPACT><DT><DD>
10246
10247 <DL COMPACT>
10248 <DT><B>-l</B>
10249
10250 <DD>
10251 List process IDs
10252 in addition to the normal information.
10253 <DT><B>-n</B>
10254
10255 <DD>
10256 Display information only about jobs that have changed status since
10257 the user was last notified of their status.
10258 <DT><B>-p</B>
10259
10260 <DD>
10261 List only the process ID of the job's process group
10262 leader.
10263 <DT><B>-r</B>
10264
10265 <DD>
10266 Display only running jobs.
10267 <DT><B>-s</B>
10268
10269 <DD>
10270 Display only stopped jobs.
10271
10272 </DL>
10273 <P>
10274
10275 If
10276 <I>jobspec</I>
10277
10278 is given, output is restricted to information about that job.
10279 The return status is 0 unless an invalid option is encountered
10280 or an invalid
10281 <I>jobspec</I>
10282
10283 is supplied.
10284 <P>
10285
10286 If the
10287 <B>-x</B>
10288
10289 option is supplied,
10290 <B>jobs</B>
10291
10292 replaces any
10293 <I>jobspec</I>
10294
10295 found in
10296 <I>command</I>
10297
10298 or
10299 <I>args</I>
10300
10301 with the corresponding process group ID, and executes
10302 <I>command</I>
10303
10304 passing it
10305 <I>args</I>,
10306
10307 returning its exit status.
10308 </DL>
10309
10310 <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>
10311
10312 <DT><B>kill</B> <B>-l</B> [<I>sigspec</I> | <I>exit_status</I>]<DD>
10313
10314 Send the signal named by
10315 <I>sigspec</I>
10316
10317 or
10318 <I>signum</I>
10319
10320 to the processes named by
10321 <I>pid</I>
10322
10323 or
10324 <I>jobspec</I>.
10325
10326 <I>sigspec</I>
10327
10328 is either a case-insensitive signal name such as
10329 <FONT SIZE=-1><B>SIGKILL</B>
10330
10331 </FONT>
10332 (with or without the
10333 <FONT SIZE=-1><B>SIG</B>
10334
10335 </FONT>
10336 prefix) or a signal number;
10337 <I>signum</I>
10338
10339 is a signal number.
10340 If
10341 <I>sigspec</I>
10342
10343 is not present, then
10344 <FONT SIZE=-1><B>SIGTERM</B>
10345
10346 </FONT>
10347 is assumed.
10348 An argument of
10349 <B>-l</B>
10350
10351 lists the signal names.
10352 If any arguments are supplied when
10353 <B>-l</B>
10354
10355 is given, the names of the signals corresponding to the arguments are
10356 listed, and the return status is 0.
10357 The <I>exit_status</I> argument to
10358 <B>-l</B>
10359
10360 is a number specifying either a signal number or the exit status of
10361 a process terminated by a signal.
10362 <B>kill</B>
10363
10364 returns true if at least one signal was successfully sent, or false
10365 if an error occurs or an invalid option is encountered.
10366 <DT><B>let</B> <I>arg</I> [<I>arg</I> ...]<DD>
10367 Each
10368 <I>arg</I>
10369
10370 is an arithmetic expression to be evaluated (see
10371 <FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
10372
10373 </FONT>
10374 above).
10375 If the last
10376 <I>arg</I>
10377
10378 evaluates to 0,
10379 <B>let</B>
10380
10381 returns 1; 0 is returned otherwise.
10382 <DT><B>local</B> [<I>option</I>] [<I>name</I>[=<I>value</I>] ...]<DD>
10383 For each argument, a local variable named
10384 <I>name </I>
10385
10386 is created, and assigned
10387 <I>value</I>.
10388
10389 The <I>option</I> can be any of the options accepted by <B>declare</B>.
10390 When
10391 <B>local</B>
10392
10393 is used within a function, it causes the variable
10394 <I>name</I>
10395
10396 to have a visible scope restricted to that function and its children.
10397 With no operands,
10398 <B>local</B>
10399
10400 writes a list of local variables to the standard output. It is
10401 an error to use
10402 <B>local</B>
10403
10404 when not within a function. The return status is 0 unless
10405 <B>local</B>
10406
10407 is used outside a function, an invalid
10408 <I>name</I>
10409
10410 is supplied, or
10411 <I>name</I> is a readonly variable.
10412 <DT><B>logout</B>
10413
10414 <DD>
10415 Exit a login shell.
10416 <DT><B>mapfile</B> [<B>-n</B> <I>count</I>] [<B>-O</B> <I>origin</I>] [<B>-s</B> <I>count</I>] [<B>-t</B>] [<B>-u</B> <I>fd</I>] [<B>-C</B> <I>callback</I>] [<B>-c</B> <I>quantum</I>] [<I>array</I>]<DD>
10417
10418 <DT><B>readarray</B> [<B>-n</B> <I>count</I>] [<B>-O</B> <I>origin</I>] [<B>-s</B> <I>count</I>] [<B>-t</B>] [<B>-u</B> <I>fd</I>] [<B>-C</B> <I>callback</I>] [<B>-c</B> <I>quantum</I>] [<I>array</I>]<DD>
10419
10420 Read lines from the standard input into the indexed array variable
10421 <I>array</I>,
10422
10423 or from file descriptor
10424 <I>fd</I>
10425
10426 if the
10427 <B>-u</B>
10428
10429 option is supplied.
10430 The variable
10431 <FONT SIZE=-1><B>MAPFILE</B>
10432
10433 </FONT>
10434 is the default <I>array</I>.
10435 Options, if supplied, have the following meanings:
10436 <DL COMPACT><DT><DD>
10437
10438 <DL COMPACT>
10439 <DT><B>-n</B>
10440
10441 <DD>
10442 Copy at most
10443 <I>count</I>
10444
10445 lines. If <I>count</I> is 0, all lines are copied.
10446 <DT><B>-O</B>
10447
10448 <DD>
10449 Begin assigning to
10450 <I>array</I>
10451
10452 at index
10453 <I>origin</I>.
10454
10455 The default index is 0.
10456 <DT><B>-s</B>
10457
10458 <DD>
10459 Discard the first <I>count</I> lines read.
10460 <DT><B>-t</B>
10461
10462 <DD>
10463 Remove a trailing newline from each line read.
10464 <DT><B>-u</B>
10465
10466 <DD>
10467 Read lines from file descriptor <I>fd</I> instead of the standard input.
10468 <DT><B>-C</B>
10469
10470 <DD>
10471 Evaluate
10472 <I>callback</I>
10473
10474 each time <I>quantum</I> lines are read. The <B>-c</B> option specifies
10475 <I>quantum</I>.
10476
10477 <DT><B>-c</B>
10478
10479 <DD>
10480 Specify the number of lines read between each call to
10481 <I>callback</I>.
10482
10483
10484 </DL>
10485 <P>
10486
10487 If
10488 <B>-C</B>
10489
10490 is specified without
10491 <B>-c</B>,
10492
10493 the default quantum is 5000.
10494 When <I>callback</I> is evaluated, it is supplied the index of the next
10495 array element to be assigned and the line to be assigned to that element
10496 as additional arguments.
10497 <I>callback</I> is evaluated after the line is read but before the
10498 array element is assigned.
10499 <P>
10500
10501 If not supplied with an explicit origin, <B>mapfile</B> will clear <I>array</I>
10502 before assigning to it.
10503 <P>
10504
10505 <B>mapfile</B> returns successfully unless an invalid option or option
10506 argument is supplied, <I>array</I> is invalid or unassignable, or if
10507 <I>array</I> is not an indexed array.
10508 </DL>
10509
10510 <DT><B>popd</B> [-<B>n</B>] [+<I>n</I>] [-<I>n</I>]<DD>
10511 Removes entries from the directory stack. With no arguments,
10512 removes the top directory from the stack, and performs a
10513 <B>cd</B>
10514
10515 to the new top directory.
10516 Arguments, if supplied, have the following meanings:
10517 <DL COMPACT><DT><DD>
10518
10519 <DL COMPACT>
10520 <DT><B>-n</B>
10521
10522 <DD>
10523 Suppresses the normal change of directory when removing directories
10524 from the stack, so that only the stack is manipulated.
10525 <DT><B>+</B><I>n</I><DD>
10526 Removes the <I>n</I>th entry counting from the left of the list
10527 shown by
10528 <B>dirs</B>,
10529
10530 starting with zero. For example:
10531
10532 <TT>popd +0</TT>
10533 removes the first directory,
10534
10535 <TT>popd +1</TT>
10536 the second.
10537 <DT><B>-</B><I>n</I><DD>
10538 Removes the <I>n</I>th entry counting from the right of the list
10539 shown by
10540 <B>dirs</B>,
10541
10542 starting with zero. For example:
10543
10544 <TT>popd -0</TT>
10545 removes the last directory,
10546
10547 <TT>popd -1</TT>
10548 the next to last.
10549
10550 </DL>
10551 <P>
10552
10553 If the
10554 <B>popd</B>
10555
10556 command is successful, a
10557 <B>dirs</B>
10558
10559 is performed as well, and the return status is 0.
10560 <B>popd</B>
10561
10562 returns false if an invalid option is encountered, the directory stack
10563 is empty, a non-existent directory stack entry is specified, or the
10564 directory change fails.
10565 </DL>
10566
10567 <DT><B>printf</B> [<B>-v</B> <I>var</I>] <I>format</I> [<I>arguments</I>]<DD>
10568 Write the formatted <I>arguments</I> to the standard output under the
10569 control of the <I>format</I>.
10570 The <B>-v</B> option causes the output to be assigned to the variable
10571 <I>var</I> rather than being printed to the standard output.
10572 <P>
10573 The <I>format</I> is a character string which contains three types of objects:
10574 plain characters, which are simply copied to standard output, character
10575 escape sequences, which are converted and copied to the standard output, and
10576 format specifications, each of which causes printing of the next successive
10577 <I>argument</I>.
10578 In addition to the standard <I>printf</I>(1) format specifications,
10579 <B>printf</B> interprets the following extensions:
10580 <DL COMPACT><DT><DD>
10581
10582 <DL COMPACT>
10583 <DT><B>%b</B>
10584
10585 <DD>
10586 causes
10587 <B>printf</B> to expand backslash escape sequences in the corresponding
10588 <I>argument</I> (except that <B>\c</B> terminates output, backslashes in
10589 <B>\aq</B>, <B>\&quot;</B>, and <B>\?</B> are not removed, and octal escapes
10590 beginning with <B>\0</B> may contain up to four digits).
10591 <DT><B>%q</B>
10592
10593 <DD>
10594 causes <B>printf</B> to output the corresponding
10595 <I>argument</I> in a format that can be reused as shell input.
10596 <DT><B>%(</B><I>datefmt</I>)T
10597
10598 <DD>
10599 causes <B>printf</B> to output the date-time string resulting from using
10600 <I>datefmt</I> as a format string for <I>strftime</I>(3). The corresponding
10601 <I>argument</I> is an integer representing the number of seconds since the
10602 epoch. Two special argument values may be used: -1 represents the current
10603 time, and -2 represents the time the shell was invoked.
10604
10605 </DL>
10606 <P>
10607
10608 Arguments to non-string format specifiers are treated as C constants,
10609 except that a leading plus or minus sign is allowed, and if the leading
10610 character is a single or double quote, the value is the ASCII value of
10611 the following character.
10612 <P>
10613
10614 The <I>format</I> is reused as necessary to consume all of the <I>arguments</I>.
10615 If the <I>format</I> requires more <I>arguments</I> than are supplied, the
10616 extra format specifications behave as if a zero value or null string, as
10617 appropriate, had been supplied.
10618 The return value is zero on success, non-zero on failure.
10619 </DL>
10620
10621 <DT><B>pushd</B> [<B>-n</B>] [+<I>n</I>] [-<I>n</I>]<DD>
10622
10623 <DT><B>pushd</B> [<B>-n</B>] [<I>dir</I>]<DD>
10624
10625 Adds a directory to the top of the directory stack, or rotates
10626 the stack, making the new top of the stack the current working
10627 directory. With no arguments, exchanges the top two directories
10628 and returns 0, unless the directory stack is empty.
10629 Arguments, if supplied, have the following meanings:
10630 <DL COMPACT><DT><DD>
10631
10632 <DL COMPACT>
10633 <DT><B>-n</B>
10634
10635 <DD>
10636 Suppresses the normal change of directory when adding directories
10637 to the stack, so that only the stack is manipulated.
10638 <DT><B>+</B><I>n</I><DD>
10639 Rotates the stack so that the <I>n</I>th directory
10640 (counting from the left of the list shown by
10641 <B>dirs</B>,
10642
10643 starting with zero)
10644 is at the top.
10645 <DT><B>-</B><I>n</I><DD>
10646 Rotates the stack so that the <I>n</I>th directory
10647 (counting from the right of the list shown by
10648 <B>dirs</B>,
10649
10650 starting with zero) is at the top.
10651 <DT><I>dir</I>
10652
10653 <DD>
10654 Adds
10655 <I>dir</I>
10656
10657 to the directory stack at the top, making it the
10658 new current working directory as if it had been supplied as the argument
10659 to the <B>cd</B> builtin.
10660
10661 </DL>
10662 <P>
10663
10664 If the
10665 <B>pushd</B>
10666
10667 command is successful, a
10668 <B>dirs</B>
10669
10670 is performed as well.
10671 If the first form is used,
10672 <B>pushd</B>
10673
10674 returns 0 unless the cd to
10675 <I>dir</I>
10676
10677 fails. With the second form,
10678 <B>pushd</B>
10679
10680 returns 0 unless the directory stack is empty,
10681 a non-existent directory stack element is specified,
10682 or the directory change to the specified new current directory
10683 fails.
10684 </DL>
10685
10686 <DT><B>pwd</B> [<B>-LP</B>]<DD>
10687 Print the absolute pathname of the current working directory.
10688 The pathname printed contains no symbolic links if the
10689 <B>-P</B>
10690
10691 option is supplied or the
10692 <B>-o physical</B>
10693
10694 option to the
10695 <B>set</B>
10696
10697 builtin command is enabled.
10698 If the
10699 <B>-L</B>
10700
10701 option is used, the pathname printed may contain symbolic links.
10702 The return status is 0 unless an error occurs while
10703 reading the name of the current directory or an
10704 invalid option is supplied.
10705 <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>
10706 One line is read from the standard input, or from the file descriptor
10707 <I>fd</I> supplied as an argument to the <B>-u</B> option, and the first word
10708 is assigned to the first
10709 <I>name</I>,
10710
10711 the second word to the second
10712 <I>name</I>,
10713
10714 and so on, with leftover words and their intervening separators assigned
10715 to the last
10716 <I>name</I>.
10717
10718 If there are fewer words read from the input stream than names,
10719 the remaining names are assigned empty values.
10720 The characters in
10721 <FONT SIZE=-1><B>IFS</B>
10722
10723 </FONT>
10724 are used to split the line into words.
10725 The backslash character (<B>\</B>) may be used to remove any special
10726 meaning for the next character read and for line continuation.
10727 Options, if supplied, have the following meanings:
10728 <DL COMPACT><DT><DD>
10729
10730 <DL COMPACT>
10731 <DT><B>-a </B><I>aname</I>
10732
10733 <DD>
10734 The words are assigned to sequential indices
10735 of the array variable
10736 <I>aname</I>,
10737
10738 starting at 0.
10739 <I>aname</I>
10740
10741 is unset before any new values are assigned.
10742 Other <I>name</I> arguments are ignored.
10743 <DT><B>-d </B><I>delim</I>
10744
10745 <DD>
10746 The first character of <I>delim</I> is used to terminate the input line,
10747 rather than newline.
10748 <DT><B>-e</B>
10749
10750 <DD>
10751 If the standard input
10752 is coming from a terminal,
10753 <B>readline</B>
10754
10755 (see
10756 <FONT SIZE=-1><B>READLINE</B>
10757
10758 </FONT>
10759 above) is used to obtain the line.
10760 Readline uses the current (or default, if line editing was not previously
10761 active) editing settings.
10762 <DT><B>-i </B><I>text</I>
10763
10764 <DD>
10765 If
10766 <B>readline</B>
10767
10768 is being used to read the line, <I>text</I> is placed into the editing
10769 buffer before editing begins.
10770 <DT><B>-n </B><I>nchars</I>
10771
10772 <DD>
10773 <B>read</B> returns after reading <I>nchars</I> characters rather than
10774 waiting for a complete line of input, but honor a delimiter if fewer
10775 than <I>nchars</I> characters are read before the delimiter.
10776 <DT><B>-N </B><I>nchars</I>
10777
10778 <DD>
10779 <B>read</B> returns after reading exactly <I>nchars</I> characters rather
10780 than waiting for a complete line of input, unless EOF is encountered or
10781 <B>read</B> times out.
10782 Delimiter characters encountered in the input are
10783 not treated specially and do not cause <B>read</B> to return until
10784 <I>nchars</I> characters are read.
10785 <DT><B>-p </B><I>prompt</I>
10786
10787 <DD>
10788 Display <I>prompt</I> on standard error, without a
10789 trailing newline, before attempting to read any input. The prompt
10790 is displayed only if input is coming from a terminal.
10791 <DT><B>-r</B>
10792
10793 <DD>
10794 Backslash does not act as an escape character.
10795 The backslash is considered to be part of the line.
10796 In particular, a backslash-newline pair may not be used as a line
10797 continuation.
10798 <DT><B>-s</B>
10799
10800 <DD>
10801 Silent mode. If input is coming from a terminal, characters are
10802 not echoed.
10803 <DT><B>-t </B><I>timeout</I>
10804
10805 <DD>
10806 Cause <B>read</B> to time out and return failure if a complete line of
10807 input is not read within <I>timeout</I> seconds.
10808 <I>timeout</I> may be a decimal number with a fractional portion following
10809 the decimal point.
10810 This option is only effective if <B>read</B> is reading input from a
10811 terminal, pipe, or other special file; it has no effect when reading
10812 from regular files.
10813 If <I>timeout</I> is 0, <B>read</B> returns immediately, without trying to
10814 read any data. The exit statis is 0 if input is available on
10815 the specified file descriptor, non-zero otherwise.
10816 The exit status is greater than 128 if the timeout is exceeded.
10817 <DT><B>-u </B><I>fd</I>
10818
10819 <DD>
10820 Read input from file descriptor <I>fd</I>.
10821
10822 </DL>
10823 <P>
10824
10825 If no
10826 <I>names</I>
10827
10828 are supplied, the line read is assigned to the variable
10829 <FONT SIZE=-1><B>REPLY</B>.
10830
10831 </FONT>
10832 The return code is zero, unless end-of-file is encountered, <B>read</B>
10833 times out (in which case the return code is greater than 128),
10834 a variable assignment error (such as assigning to a readonly variable) occurs,
10835 or an invalid file descriptor is supplied as the argument to <B>-u</B>.
10836 </DL>
10837
10838 <DT><B>readonly</B> [<B>-aAf</B>] [<B>-p</B>] [<I>name</I>[=<I>word</I>] ...]<DD>
10839
10840 The given
10841 <I>names</I> are marked readonly; the values of these
10842 <I>names</I>
10843
10844 may not be changed by subsequent assignment.
10845 If the
10846 <B>-f</B>
10847
10848 option is supplied, the functions corresponding to the
10849 <I>names</I> are so
10850 marked.
10851 The
10852 <B>-a</B>
10853
10854 option restricts the variables to indexed arrays; the
10855 <B>-A</B>
10856
10857 option restricts the variables to associative arrays.
10858 If both options are supplied,
10859 <B>-A</B>
10860
10861 takes precedence.
10862 If no
10863 <I>name</I>
10864
10865 arguments are given, or if the
10866 <B>-p</B>
10867
10868 option is supplied, a list of all readonly names is printed.
10869 The other options may be used to restrict the output to a subset of
10870 the set of readonly names.
10871 The
10872 <B>-p</B>
10873
10874 option causes output to be displayed in a format that
10875 may be reused as input.
10876 If a variable name is followed by =<I>word</I>, the value of
10877 the variable is set to <I>word</I>.
10878 The return status is 0 unless an invalid option is encountered,
10879 one of the
10880 <I>names</I>
10881
10882 is not a valid shell variable name, or
10883 <B>-f</B>
10884
10885 is supplied with a
10886 <I>name</I>
10887
10888 that is not a function.
10889 <DT><B>return</B> [<I>n</I>]<DD>
10890 Causes a function to stop executing and return the value specified by
10891 <I>n</I>
10892
10893 to its caller.
10894 If
10895 <I>n</I>
10896
10897 is omitted, the return status is that of the last command
10898 executed in the function body. If
10899 <B>return</B>
10900
10901 is used outside a function,
10902 but during execution of a script by the
10903 <B>.</B>
10904
10905 (<B>source</B>) command, it causes the shell to stop executing
10906 that script and return either
10907 <I>n</I>
10908
10909 or the exit status of the last command executed within the
10910 script as the exit status of the script.
10911 If <I>n</I> is supplied, the return value is its least significant
10912 8 bits.
10913 The return status is non-zero if
10914 <B>return</B>
10915
10916 is supplied a non-numeric argument, or
10917 is used outside a
10918 function and not during execution of a script by <B>.</B> or <B>source</B>.
10919 Any command associated with the <B>RETURN</B> trap is executed
10920 before execution resumes after the function or script.
10921 <DT><B>set</B> [<B>--abefhkmnptuvxBCEHPT</B>] [<B>-o</B> <I>option-name</I>] [<I>arg</I> ...]<DD>
10922
10923 <DT><B>set</B> [<B>+abefhkmnptuvxBCEHPT</B>] [<B>+o</B> <I>option-name</I>] [<I>arg</I> ...]<DD>
10924
10925 Without options, the name and value of each shell variable are displayed
10926 in a format that can be reused as input
10927 for setting or resetting the currently-set variables.
10928 Read-only variables cannot be reset.
10929 In <I>posix mode</I>, only shell variables are listed.
10930 The output is sorted according to the current locale.
10931 When options are specified, they set or unset shell attributes.
10932 Any arguments remaining after option processing are treated
10933 as values for the positional parameters and are assigned, in order, to
10934 <B>$1</B>,
10935
10936 <B>$2</B>,
10937
10938 <B>...</B>
10939
10940 <B>$</B><I>n</I>.
10941
10942 Options, if specified, have the following meanings:
10943 <DL COMPACT><DT><DD>
10944
10945 <DL COMPACT>
10946 <DT><B>-a</B>
10947
10948 <DD>
10949 Automatically mark variables and functions which are modified or
10950 created for export to the environment of subsequent commands.
10951 <DT><B>-b</B>
10952
10953 <DD>
10954 Report the status of terminated background jobs
10955 immediately, rather than before the next primary prompt. This is
10956 effective only when job control is enabled.
10957 <DT><B>-e</B>
10958
10959 <DD>
10960 Exit immediately if a
10961 <I>pipeline</I> (which may consist of a single <I>simple command</I>),
10962 a <I>list</I>,
10963 or a <I>compound command</I>
10964 (see
10965 <FONT SIZE=-1><B>SHELL GRAMMAR</B>
10966
10967 </FONT>
10968 above), exits with a non-zero status.
10969 The shell does not exit if the
10970 command that fails is part of the command list immediately following a
10971 <B>while</B>
10972
10973 or
10974 <B>until</B>
10975
10976 keyword,
10977 part of the test following the
10978 <B>if</B>
10979
10980 or
10981 <B>elif</B>
10982
10983 reserved words, part of any command executed in a
10984 <B>&amp;&amp;</B>
10985
10986 or
10987 <B>||</B>
10988
10989 list except the command following the final <B>&amp;&amp;</B> or <B>||</B>,
10990 any command in a pipeline but the last,
10991 or if the command's return value is
10992 being inverted with
10993 <B>!</B>.
10994
10995 If a compound command other than a subshell
10996 returns a non-zero status because a command failed
10997 while <B>-e</B> was being ignored, the shell does not exit.
10998 A trap on <B>ERR</B>, if set, is executed before the shell exits.
10999 This option applies to the shell environment and each subshell environment
11000 separately (see
11001 <FONT SIZE=-1><B>COMMAND EXECUTION ENVIRONMENT</B>
11002
11003 </FONT>
11004 above), and may cause
11005 subshells to exit before executing all the commands in the subshell.
11006 <DT><B>-f</B>
11007
11008 <DD>
11009 Disable pathname expansion.
11010 <DT><B>-h</B>
11011
11012 <DD>
11013 Remember the location of commands as they are looked up for execution.
11014 This is enabled by default.
11015 <DT><B>-k</B>
11016
11017 <DD>
11018 All arguments in the form of assignment statements
11019 are placed in the environment for a command, not just
11020 those that precede the command name.
11021 <DT><B>-m</B>
11022
11023 <DD>
11024 Monitor mode. Job control is enabled. This option is on
11025 by default for interactive shells on systems that support
11026 it (see
11027 <FONT SIZE=-1><B>JOB CONTROL</B>
11028
11029 </FONT>
11030 above).
11031 All processes run in a separate process group.
11032 When a background job completes, the shell prints a line
11033 containing its exit status.
11034 <DT><B>-n</B>
11035
11036 <DD>
11037 Read commands but do not execute them. This may be used to
11038 check a shell script for syntax errors. This is ignored by
11039 interactive shells.
11040 <DT><B>-o </B><I>option-name</I>
11041
11042 <DD>
11043 The <I>option-name</I> can be one of the following:
11044 <DL COMPACT><DT><DD>
11045 <DL COMPACT>
11046 <DT><B>allexport</B>
11047
11048 <DD>
11049 Same as
11050 <B>-a</B>.
11051
11052 <DT><B>braceexpand</B>
11053
11054 <DD>
11055 Same as
11056 <B>-B</B>.
11057
11058 <DT><B>emacs</B>
11059
11060 <DD>
11061 Use an emacs-style command line editing interface. This is enabled
11062 by default when the shell is interactive, unless the shell is started
11063 with the
11064 <B>--noediting</B>
11065
11066 option.
11067 This also affects the editing interface used for <B>read -e</B>.
11068 <DT><B>errexit</B>
11069
11070 <DD>
11071 Same as
11072 <B>-e</B>.
11073
11074 <DT><B>errtrace</B>
11075
11076 <DD>
11077 Same as
11078 <B>-E</B>.
11079
11080 <DT><B>functrace</B>
11081
11082 <DD>
11083 Same as
11084 <B>-T</B>.
11085
11086 <DT><B>hashall</B>
11087
11088 <DD>
11089 Same as
11090 <B>-h</B>.
11091
11092 <DT><B>histexpand</B>
11093
11094 <DD>
11095 Same as
11096 <B>-H</B>.
11097
11098 <DT><B>history</B>
11099
11100 <DD>
11101 Enable command history, as described above under
11102 <FONT SIZE=-1><B>HISTORY</B>.
11103
11104 </FONT>
11105 This option is on by default in interactive shells.
11106 <DT><B>ignoreeof</B>
11107
11108 <DD>
11109 The effect is as if the shell command
11110 <TT>IGNOREEOF=10</TT>
11111
11112 had been executed
11113 (see
11114 <B>Shell Variables</B>
11115
11116 above).
11117 <DT><B>keyword</B>
11118
11119 <DD>
11120 Same as
11121 <B>-k</B>.
11122
11123 <DT><B>monitor</B>
11124
11125 <DD>
11126 Same as
11127 <B>-m</B>.
11128
11129 <DT><B>noclobber</B>
11130
11131 <DD>
11132 Same as
11133 <B>-C</B>.
11134
11135 <DT><B>noexec</B>
11136
11137 <DD>
11138 Same as
11139 <B>-n</B>.
11140
11141 <DT><B>noglob</B>
11142
11143 <DD>
11144 Same as
11145 <B>-f</B>.
11146
11147 <DT><B>nolog</B>
11148
11149 <DD>
11150 Currently ignored.
11151 <DT><B>notify</B>
11152
11153 <DD>
11154 Same as
11155 <B>-b</B>.
11156
11157 <DT><B>nounset</B>
11158
11159 <DD>
11160 Same as
11161 <B>-u</B>.
11162
11163 <DT><B>onecmd</B>
11164
11165 <DD>
11166 Same as
11167 <B>-t</B>.
11168
11169 <DT><B>physical</B>
11170
11171 <DD>
11172 Same as
11173 <B>-P</B>.
11174
11175 <DT><B>pipefail</B>
11176
11177 <DD>
11178 If set, the return value of a pipeline is the value of the last
11179 (rightmost) command to exit with a non-zero status, or zero if all
11180 commands in the pipeline exit successfully.
11181 This option is disabled by default.
11182 <DT><B>posix</B>
11183
11184 <DD>
11185 Change the behavior of
11186 <B>bash</B>
11187
11188 where the default operation differs
11189 from the POSIX standard to match the standard (<I>posix mode</I>).
11190 <DT><B>privileged</B>
11191
11192 <DD>
11193 Same as
11194 <B>-p</B>.
11195
11196 <DT><B>verbose</B>
11197
11198 <DD>
11199 Same as
11200 <B>-v</B>.
11201
11202 <DT><B>vi</B>
11203
11204 <DD>
11205 Use a vi-style command line editing interface.
11206 This also affects the editing interface used for <B>read -e</B>.
11207 <DT><B>xtrace</B>
11208
11209 <DD>
11210 Same as
11211 <B>-x</B>.
11212
11213 <P>
11214 </DL>
11215 <P>
11216
11217 If
11218 <B>-o</B>
11219
11220 is supplied with no <I>option-name</I>, the values of the current options are
11221 printed.
11222 If
11223 <B>+o</B>
11224
11225 is supplied with no <I>option-name</I>, a series of
11226 <B>set</B>
11227
11228 commands to recreate the current option settings is displayed on
11229 the standard output.
11230 </DL>
11231
11232 <DT><B>-p</B>
11233
11234 <DD>
11235 Turn on
11236 <I>privileged</I>
11237
11238 mode. In this mode, the
11239 <FONT SIZE=-1><B>$ENV</B>
11240
11241 </FONT>
11242 and
11243 <FONT SIZE=-1><B>$BASH_ENV</B>
11244
11245 </FONT>
11246 files are not processed, shell functions are not inherited from the
11247 environment, and the
11248 <FONT SIZE=-1><B>SHELLOPTS</B>,
11249
11250 </FONT>
11251 <FONT SIZE=-1><B>BASHOPTS</B>,
11252
11253 </FONT>
11254 <FONT SIZE=-1><B>CDPATH</B>,
11255
11256 </FONT>
11257 and
11258 <FONT SIZE=-1><B>GLOBIGNORE</B>
11259
11260 </FONT>
11261 variables, if they appear in the environment, are ignored.
11262 If the shell is started with the effective user (group) id not equal to the
11263 real user (group) id, and the <B>-p</B> option is not supplied, these actions
11264 are taken and the effective user id is set to the real user id.
11265 If the <B>-p</B> option is supplied at startup, the effective user id is
11266 not reset.
11267 Turning this option off causes the effective user
11268 and group ids to be set to the real user and group ids.
11269 <DT><B>-t</B>
11270
11271 <DD>
11272 Exit after reading and executing one command.
11273 <DT><B>-u</B>
11274
11275 <DD>
11276 Treat unset variables and parameters other than the special
11277 parameters &quot;@&quot; and &quot;*&quot; as an error when performing
11278 parameter expansion. If expansion is attempted on an
11279 unset variable or parameter, the shell prints an error message, and,
11280 if not interactive, exits with a non-zero status.
11281 <DT><B>-v</B>
11282
11283 <DD>
11284 Print shell input lines as they are read.
11285 <DT><B>-x</B>
11286
11287 <DD>
11288 After expanding each <I>simple command</I>,
11289 <B>for</B> command, <B>case</B> command, <B>select</B> command, or
11290 arithmetic <B>for</B> command, display the expanded value of
11291 <FONT SIZE=-1><B>PS4</B>,
11292
11293 </FONT>
11294 followed by the command and its expanded arguments
11295 or associated word list.
11296 <DT><B>-B</B>
11297
11298 <DD>
11299 The shell performs brace expansion (see
11300 <B>Brace Expansion</B>
11301
11302 above). This is on by default.
11303 <DT><B>-C</B>
11304
11305 <DD>
11306 If set,
11307 <B>bash</B>
11308
11309 does not overwrite an existing file with the
11310 <B>&gt;</B>,
11311
11312 <B>&gt;&amp;</B>,
11313
11314 and
11315 <B>&lt;&gt;</B>
11316
11317 redirection operators. This may be overridden when
11318 creating output files by using the redirection operator
11319 <B>&gt;|</B>
11320
11321 instead of
11322 <B>&gt;</B>.
11323
11324 <DT><B>-E</B>
11325
11326 <DD>
11327 If set, any trap on <B>ERR</B> is inherited by shell functions, command
11328 substitutions, and commands executed in a subshell environment.
11329 The <B>ERR</B> trap is normally not inherited in such cases.
11330 <DT><B>-H</B>
11331
11332 <DD>
11333 Enable
11334 <B>!</B>
11335
11336 style history substitution. This option is on by
11337 default when the shell is interactive.
11338 <DT><B>-P</B>
11339
11340 <DD>
11341 If set, the shell does not resolve symbolic links when executing
11342 commands such as
11343 <B>cd</B>
11344
11345 that change the current working directory. It uses the
11346 physical directory structure instead. By default,
11347 <B>bash</B>
11348
11349 follows the logical chain of directories when performing commands
11350 which change the current directory.
11351 <DT><B>-T</B>
11352
11353 <DD>
11354 If set, any traps on <B>DEBUG</B> and <B>RETURN</B> are inherited by shell
11355 functions, command substitutions, and commands executed in a
11356 subshell environment.
11357 The <B>DEBUG</B> and <B>RETURN</B> traps are normally not inherited
11358 in such cases.
11359 <DT><B>--</B>
11360
11361 <DD>
11362 If no arguments follow this option, then the positional parameters are
11363 unset. Otherwise, the positional parameters are set to the
11364 <I>arg</I>s, even if some of them begin with a
11365 <B>-</B>.
11366
11367 <DT><B>-</B>
11368
11369 <DD>
11370 Signal the end of options, cause all remaining <I>arg</I>s to be
11371 assigned to the positional parameters. The
11372 <B>-x</B>
11373
11374 and
11375 <B>-v</B>
11376
11377 options are turned off.
11378 If there are no <I>arg</I>s,
11379 the positional parameters remain unchanged.
11380
11381 </DL>
11382 <P>
11383
11384 The options are off by default unless otherwise noted.
11385 Using + rather than - causes these options to be turned off.
11386 The options can also be specified as arguments to an invocation of
11387 the shell.
11388 The current set of options may be found in
11389 <B>$-</B>.
11390
11391 The return status is always true unless an invalid option is encountered.
11392 </DL>
11393
11394 <DT><B>shift</B> [<I>n</I>]<DD>
11395 The positional parameters from <I>n</I>+1 ... are renamed to
11396 <B>$1</B>
11397
11398 <B>....</B>
11399
11400 Parameters represented by the numbers <B>$#</B>
11401 down to <B>$#</B>-<I>n</I>+1 are unset.
11402 <I>n</I>
11403
11404 must be a non-negative number less than or equal to <B>$#</B>.
11405 If
11406 <I>n</I>
11407
11408 is 0, no parameters are changed.
11409 If
11410 <I>n </I>
11411
11412 is not given, it is assumed to be 1.
11413 If
11414 <I>n</I>
11415
11416 is greater than <B>$#</B>, the positional parameters are not changed.
11417 The return status is greater than zero if
11418 <I>n</I>
11419
11420 is greater than
11421 <B>$#</B>
11422
11423 or less than zero; otherwise 0.
11424 <DT><B>shopt</B> [<B>-pqsu</B>] [<B>-o</B>] [<I>optname</I> ...]<DD>
11425 Toggle the values of variables controlling optional shell behavior.
11426 With no options, or with the
11427 <B>-p</B>
11428
11429 option, a list of all settable options is displayed, with
11430 an indication of whether or not each is set.
11431 The <B>-p</B> option causes output to be displayed in a form that
11432 may be reused as input.
11433 Other options have the following meanings:
11434 <DL COMPACT><DT><DD>
11435
11436 <DL COMPACT>
11437 <DT><B>-s</B>
11438
11439 <DD>
11440 Enable (set) each <I>optname</I>.
11441 <DT><B>-u</B>
11442
11443 <DD>
11444 Disable (unset) each <I>optname</I>.
11445 <DT><B>-q</B>
11446
11447 <DD>
11448 Suppresses normal output (quiet mode); the return status indicates
11449 whether the <I>optname</I> is set or unset.
11450 If multiple <I>optname</I> arguments are given with
11451 <B>-q</B>,
11452
11453 the return status is zero if all <I>optnames</I> are enabled; non-zero
11454 otherwise.
11455 <DT><B>-o</B>
11456
11457 <DD>
11458 Restricts the values of <I>optname</I> to be those defined for the
11459 <B>-o</B>
11460
11461 option to the
11462 <B>set</B>
11463
11464 builtin.
11465
11466 </DL>
11467 <P>
11468
11469 If either
11470 <B>-s</B>
11471
11472 or
11473 <B>-u</B>
11474
11475 is used with no <I>optname</I> arguments,
11476 <B>shopt</B>
11477
11478 shows only those options which are set or unset, respectively.
11479 Unless otherwise noted, the <B>shopt</B> options are disabled (unset)
11480 by default.
11481 <P>
11482
11483 The return status when listing options is zero if all <I>optnames</I>
11484 are enabled, non-zero otherwise. When setting or unsetting options,
11485 the return status is zero unless an <I>optname</I> is not a valid shell
11486 option.
11487 <P>
11488
11489 The list of <B>shopt</B> options is:
11490 <P>
11491
11492
11493
11494 <DL COMPACT>
11495 <DT><B>autocd</B>
11496
11497 <DD>
11498 If set, a command name that is the name of a directory is executed as if
11499 it were the argument to the <B>cd</B> command.
11500 This option is only used by interactive shells.
11501 <DT><B>cdable_vars</B>
11502
11503 <DD>
11504 If set, an argument to the
11505 <B>cd</B>
11506
11507 builtin command that
11508 is not a directory is assumed to be the name of a variable whose
11509 value is the directory to change to.
11510 <DT><B>cdspell</B>
11511
11512 <DD>
11513 If set, minor errors in the spelling of a directory component in a
11514 <B>cd</B>
11515
11516 command will be corrected.
11517 The errors checked for are transposed characters,
11518 a missing character, and one character too many.
11519 If a correction is found, the corrected filename is printed,
11520 and the command proceeds.
11521 This option is only used by interactive shells.
11522 <DT><B>checkhash</B>
11523
11524 <DD>
11525 If set, <B>bash</B> checks that a command found in the hash
11526 table exists before trying to execute it. If a hashed command no
11527 longer exists, a normal path search is performed.
11528 <DT><B>checkjobs</B>
11529
11530 <DD>
11531 If set, <B>bash</B> lists the status of any stopped and running jobs before
11532 exiting an interactive shell. If any jobs are running, this causes
11533 the exit to be deferred until a second exit is attempted without an
11534 intervening command (see
11535 <FONT SIZE=-1><B>JOB CONTROL</B>
11536
11537 </FONT>
11538 above). The shell always
11539 postpones exiting if any jobs are stopped.
11540 <DT><B>checkwinsize</B>
11541
11542 <DD>
11543 If set, <B>bash</B> checks the window size after each command
11544 and, if necessary, updates the values of
11545 <FONT SIZE=-1><B>LINES</B>
11546
11547 </FONT>
11548 and
11549 <FONT SIZE=-1><B>COLUMNS</B>.
11550
11551 </FONT>
11552 <DT><B>cmdhist</B>
11553
11554 <DD>
11555 If set,
11556 <B>bash</B>
11557
11558 attempts to save all lines of a multiple-line
11559 command in the same history entry. This allows
11560 easy re-editing of multi-line commands.
11561 <DT><B>compat31</B>
11562
11563 <DD>
11564 If set,
11565 <B>bash</B>
11566
11567 changes its behavior to that of version 3.1 with respect to quoted
11568 arguments to the <B>[[</B> conditional command's <B>=~</B> operator
11569 and locale-specific string comparison when using the <B>[[</B>
11570 conditional command's <B>&lt;</B> and <B>&gt;</B> operators.
11571 Bash versions prior to bash-4.1 use ASCII collation and
11572 <I>strcmp</I>(3);
11573
11574 bash-4.1 and later use the current locale's collation sequence and
11575 <I>strcoll</I>(3).
11576
11577 <DT><B>compat32</B>
11578
11579 <DD>
11580 If set,
11581 <B>bash</B>
11582
11583 changes its behavior to that of version 3.2 with respect to
11584 locale-specific string comparison when using the <B>[[</B>
11585 conditional command's <B>&lt;</B> and <B>&gt;</B> operators (see previous item).
11586 <DT><B>compat40</B>
11587
11588 <DD>
11589 If set,
11590 <B>bash</B>
11591
11592 changes its behavior to that of version 4.0 with respect to locale-specific
11593 string comparison when using the <B>[[</B>
11594 conditional command's <B>&lt;</B> and <B>&gt;</B> operators (see description of
11595 <B>compat31</B>)
11596 and the effect of interrupting a command list.
11597 Bash versions 4.0 and later interrupt the list as if the shell received the
11598 interrupt; previous versions continue with the next command in the list.
11599 <DT><B>compat41</B>
11600
11601 <DD>
11602 If set,
11603 <B>bash</B>,
11604
11605 when in posix mode, treats a single quote in a double-quoted
11606 parameter expansion as a special character. The single quotes must match
11607 (an even number) and the characters between the single quotes are considered
11608 quoted. This is the behavior of posix mode through version 4.1.
11609 The default bash behavior remains as in previous versions.
11610 <DT><B>complete_fullquote</B>
11611
11612 <DD>
11613 If set,
11614 <B>bash</B>
11615
11616 quotes all shell metacharacters in filenames and directory names when
11617 performing completion.
11618 If not set,
11619 <B>bash</B>
11620
11621 removes metacharacters such as the dollar sign from the set of
11622 characters that will be quoted in completed filenames
11623 when these metacharacters appear in shell variable references in words to be
11624 completed.
11625 This means that dollar signs in variable names that expand to directories
11626 will not be quoted;
11627 however, any dollar signs appearing in filenames will not be quoted, either.
11628 This is active only when bash is using backslashes to quote completed
11629 filenames.
11630 This variable is set by default, which is the default bash behavior in
11631 versions through 4.2.
11632 <DT><B>direxpand</B>
11633
11634 <DD>
11635 If set,
11636 <B>bash</B>
11637
11638 replaces directory names with the results of word expansion when performing
11639 filename completion. This changes the contents of the readline editing
11640 buffer.
11641 If not set,
11642 <B>bash</B>
11643
11644 attempts to preserve what the user typed.
11645 <DT><B>dirspell</B>
11646
11647 <DD>
11648 If set,
11649 <B>bash</B>
11650
11651 attempts spelling correction on directory names during word completion
11652 if the directory name initially supplied does not exist.
11653 <DT><B>dotglob</B>
11654
11655 <DD>
11656 If set,
11657 <B>bash</B>
11658
11659 includes filenames beginning with a `.' in the results of pathname
11660 expansion.
11661 <DT><B>execfail</B>
11662
11663 <DD>
11664 If set, a non-interactive shell will not exit if
11665 it cannot execute the file specified as an argument to the
11666 <B>exec</B>
11667
11668 builtin command. An interactive shell does not exit if
11669 <B>exec</B>
11670
11671 fails.
11672 <DT><B>expand_aliases</B>
11673
11674 <DD>
11675 If set, aliases are expanded as described above under
11676 <FONT SIZE=-1><B>ALIASES</B>.
11677
11678 </FONT>
11679 This option is enabled by default for interactive shells.
11680 <DT><B>extdebug</B>
11681
11682 <DD>
11683 If set, behavior intended for use by debuggers is enabled:
11684 <DL COMPACT><DT><DD>
11685 <DL COMPACT>
11686 <DT><B>1.</B>
11687
11688 <DD>
11689 The <B>-F</B> option to the <B>declare</B> builtin displays the source
11690 file name and line number corresponding to each function name supplied
11691 as an argument.
11692 <DT><B>2.</B>
11693
11694 <DD>
11695 If the command run by the <B>DEBUG</B> trap returns a non-zero value, the
11696 next command is skipped and not executed.
11697 <DT><B>3.</B>
11698
11699 <DD>
11700 If the command run by the <B>DEBUG</B> trap returns a value of 2, and the
11701 shell is executing in a subroutine (a shell function or a shell script
11702 executed by the <B>.</B> or <B>source</B> builtins), a call to
11703 <B>return</B> is simulated.
11704 <DT><B>4.</B>
11705
11706 <DD>
11707 <FONT SIZE=-1><B>BASH_ARGC</B>
11708
11709 </FONT>
11710 and
11711 <FONT SIZE=-1><B>BASH_ARGV</B>
11712
11713 </FONT>
11714 are updated as described in their descriptions above.
11715 <DT><B>5.</B>
11716
11717 <DD>
11718 Function tracing is enabled: command substitution, shell functions, and
11719 subshells invoked with <B>(</B> <I>command</I> <B>)</B> inherit the
11720 <B>DEBUG</B> and <B>RETURN</B> traps.
11721 <DT><B>6.</B>
11722
11723 <DD>
11724 Error tracing is enabled: command substitution, shell functions, and
11725 subshells invoked with <B>(</B> <I>command</I> <B>)</B> inherit the
11726 <B>ERR</B> trap.
11727 </DL></DL>
11728
11729 <DT><B>extglob</B>
11730
11731 <DD>
11732 If set, the extended pattern matching features described above under
11733 <B>Pathname Expansion</B> are enabled.
11734 <DT><B>extquote</B>
11735
11736 <DD>
11737 If set, <B>$</B>aq<I>string</I>aq and <B>$</B>&quot;<I>string</I>&quot; quoting is
11738 performed within <B>${</B><I>parameter</I><B>}</B> expansions
11739 enclosed in double quotes. This option is enabled by default.
11740 <DT><B>failglob</B>
11741
11742 <DD>
11743 If set, patterns which fail to match filenames during pathname expansion
11744 result in an expansion error.
11745 <DT><B>force_fignore</B>
11746
11747 <DD>
11748 If set, the suffixes specified by the
11749 <FONT SIZE=-1><B>FIGNORE</B>
11750
11751 </FONT>
11752 shell variable
11753 cause words to be ignored when performing word completion even if
11754 the ignored words are the only possible completions.
11755 See
11756 <FONT SIZE=-1><B>SHELL VARIABLES</B></FONT>
11757 above for a description of
11758 <FONT SIZE=-1><B>FIGNORE</B>.
11759
11760 </FONT>
11761 This option is enabled by default.
11762 <DT><B>globasciiranges</B>
11763
11764 <DD>
11765 If set, range expressions used in pattern matching (see
11766 <FONT SIZE=-1><B>Pattern Matching</B>
11767
11768 </FONT>
11769 above) behave as if in the traditional C locale when performing
11770 comparisons. That is, the current locale's collating sequence
11771 is not taken into account, so
11772 <B>b</B>
11773
11774 will not collate between
11775 <B>A</B>
11776
11777 and
11778 <B>B</B>,
11779
11780 and upper-case and lower-case ASCII characters will collate together.
11781 <DT><B>globstar</B>
11782
11783 <DD>
11784 If set, the pattern <B>**</B> used in a pathname expansion context will
11785 match all files and zero or more directories and subdirectories.
11786 If the pattern is followed by a <B>/</B>, only directories and
11787 subdirectories match.
11788 <DT><B>gnu_errfmt</B>
11789
11790 <DD>
11791 If set, shell error messages are written in the standard GNU error
11792 message format.
11793 <DT><B>histappend</B>
11794
11795 <DD>
11796 If set, the history list is appended to the file named by the value
11797 of the
11798 <FONT SIZE=-1><B>HISTFILE</B>
11799
11800 </FONT>
11801 variable when the shell exits, rather than overwriting the file.
11802 <DT><B>histreedit</B>
11803
11804 <DD>
11805 If set, and
11806 <B>readline</B>
11807
11808 is being used, a user is given the opportunity to re-edit a
11809 failed history substitution.
11810 <DT><B>histverify</B>
11811
11812 <DD>
11813 If set, and
11814 <B>readline</B>
11815
11816 is being used, the results of history substitution are not immediately
11817 passed to the shell parser. Instead, the resulting line is loaded into
11818 the <B>readline</B> editing buffer, allowing further modification.
11819 <DT><B>hostcomplete</B>
11820
11821 <DD>
11822 If set, and
11823 <B>readline</B>
11824
11825 is being used, <B>bash</B> will attempt to perform hostname completion when a
11826 word containing a <B>@</B> is being completed (see
11827 <B>Completing</B>
11828
11829 under
11830 <FONT SIZE=-1><B>READLINE</B>
11831
11832 </FONT>
11833 above).
11834 This is enabled by default.
11835 <DT><B>huponexit</B>
11836
11837 <DD>
11838 If set, <B>bash</B> will send
11839 <FONT SIZE=-1><B>SIGHUP</B>
11840
11841 </FONT>
11842 to all jobs when an interactive login shell exits.
11843 <DT><B>interactive_comments</B>
11844
11845 <DD>
11846 If set, allow a word beginning with
11847 <B>#</B>
11848
11849 to cause that word and all remaining characters on that
11850 line to be ignored in an interactive shell (see
11851 <FONT SIZE=-1><B>COMMENTS</B>
11852
11853 </FONT>
11854 above). This option is enabled by default.
11855 <DT><B>lastpipe</B>
11856
11857 <DD>
11858 If set, and job control is not active, the shell runs the last command of
11859 a pipeline not executed in the background in the current shell environment.
11860 <DT><B>lithist</B>
11861
11862 <DD>
11863 If set, and the
11864 <B>cmdhist</B>
11865
11866 option is enabled, multi-line commands are saved to the history with
11867 embedded newlines rather than using semicolon separators where possible.
11868 <DT><B>login_shell</B>
11869
11870 <DD>
11871 The shell sets this option if it is started as a login shell (see
11872 <FONT SIZE=-1><B>INVOCATION</B>
11873
11874 </FONT>
11875 above).
11876 The value may not be changed.
11877 <DT><B>mailwarn</B>
11878
11879 <DD>
11880 If set, and a file that <B>bash</B> is checking for mail has been
11881 accessed since the last time it was checked, the message ``The mail in
11882 <I>mailfile</I> has been read'' is displayed.
11883 <DT><B>no_empty_cmd_completion</B>
11884
11885 <DD>
11886 If set, and
11887 <B>readline</B>
11888
11889 is being used,
11890 <B>bash</B>
11891
11892 will not attempt to search the
11893 <FONT SIZE=-1><B>PATH</B>
11894
11895 </FONT>
11896 for possible completions when
11897 completion is attempted on an empty line.
11898 <DT><B>nocaseglob</B>
11899
11900 <DD>
11901 If set,
11902 <B>bash</B>
11903
11904 matches filenames in a case-insensitive fashion when performing pathname
11905 expansion (see
11906 <B>Pathname Expansion</B>
11907
11908 above).
11909 <DT><B>nocasematch</B>
11910
11911 <DD>
11912 If set,
11913 <B>bash</B>
11914
11915 matches patterns in a case-insensitive fashion when performing matching
11916 while executing <B>case</B> or <B>[[</B> conditional commands.
11917 <DT><B>nullglob</B>
11918
11919 <DD>
11920 If set,
11921 <B>bash</B>
11922
11923 allows patterns which match no
11924 files (see
11925 <B>Pathname Expansion</B>
11926
11927 above)
11928 to expand to a null string, rather than themselves.
11929 <DT><B>progcomp</B>
11930
11931 <DD>
11932 If set, the programmable completion facilities (see
11933 <B>Programmable Completion</B> above) are enabled.
11934 This option is enabled by default.
11935 <DT><B>promptvars</B>
11936
11937 <DD>
11938 If set, prompt strings undergo
11939 parameter expansion, command substitution, arithmetic
11940 expansion, and quote removal after being expanded as described in
11941 <FONT SIZE=-1><B>PROMPTING</B>
11942
11943 </FONT>
11944 above. This option is enabled by default.
11945 <DT><B>restricted_shell</B>
11946
11947 <DD>
11948 The shell sets this option if it is started in restricted mode (see
11949 <FONT SIZE=-1><B>RESTRICTED SHELL</B>
11950
11951 </FONT>
11952 below).
11953 The value may not be changed.
11954 This is not reset when the startup files are executed, allowing
11955 the startup files to discover whether or not a shell is restricted.
11956 <DT><B>shift_verbose</B>
11957
11958 <DD>
11959 If set, the
11960 <B>shift</B>
11961
11962 builtin prints an error message when the shift count exceeds the
11963 number of positional parameters.
11964 <DT><B>sourcepath</B>
11965
11966 <DD>
11967 If set, the
11968 <B>source</B> (<B>.</B>) builtin uses the value of
11969 <FONT SIZE=-1><B>PATH</B>
11970
11971 </FONT>
11972 to find the directory containing the file supplied as an argument.
11973 This option is enabled by default.
11974 <DT><B>xpg_echo</B>
11975
11976 <DD>
11977 If set, the <B>echo</B> builtin expands backslash-escape sequences
11978 by default.
11979 </DL></DL>
11980
11981
11982 <DT><B>suspend</B> [<B>-f</B>]<DD>
11983 Suspend the execution of this shell until it receives a
11984 <FONT SIZE=-1><B>SIGCONT</B>
11985
11986 </FONT>
11987 signal. A login shell cannot be suspended; the
11988 <B>-f</B>
11989
11990 option can be used to override this and force the suspension.
11991 The return status is 0 unless the shell is a login shell and
11992 <B>-f</B>
11993
11994 is not supplied, or if job control is not enabled.
11995 <DT><B>test</B> <I>expr</I><DD>
11996
11997 <DT><B>[</B> <I>expr</I> <B>]</B><DD>
11998 Return a status of 0 (true) or 1 (false) depending on
11999 the evaluation of the conditional expression
12000 <I>expr</I>.
12001
12002 Each operator and operand must be a separate argument.
12003 Expressions are composed of the primaries described above under
12004 <FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>.
12005
12006 </FONT>
12007 <B>test</B> does not accept any options, nor does it accept and ignore
12008 an argument of <B>--</B> as signifying the end of options.
12009 <P>
12010
12011
12012 Expressions may be combined using the following operators, listed
12013 in decreasing order of precedence.
12014 The evaluation depends on the number of arguments; see below.
12015 Operator precedence is used when there are five or more arguments.
12016 <DL COMPACT><DT><DD>
12017
12018 <DL COMPACT>
12019 <DT><B>! </B><I>expr</I>
12020
12021 <DD>
12022 True if
12023 <I>expr</I>
12024
12025 is false.
12026 <DT><B>( </B><I>expr</I> )
12027
12028 <DD>
12029 Returns the value of <I>expr</I>.
12030 This may be used to override the normal precedence of operators.
12031 <DT><I>expr1</I> -<B>a</B> <I>expr2</I><DD>
12032 True if both
12033 <I>expr1</I>
12034
12035 and
12036 <I>expr2</I>
12037
12038 are true.
12039 <DT><I>expr1</I> -<B>o</B> <I>expr2</I><DD>
12040 True if either
12041 <I>expr1</I>
12042
12043 or
12044 <I>expr2</I>
12045
12046 is true.
12047
12048 </DL>
12049 <P>
12050
12051 <B>test</B> and <B>[</B> evaluate conditional
12052 expressions using a set of rules based on the number of arguments.
12053 <P>
12054
12055
12056
12057 <DL COMPACT>
12058 <DT>0 arguments<DD>
12059 The expression is false.
12060 <DT>1 argument<DD>
12061 The expression is true if and only if the argument is not null.
12062 <DT>2 arguments<DD>
12063 If the first argument is <B>!</B>, the expression is true if and
12064 only if the second argument is null.
12065 If the first argument is one of the unary conditional operators listed above
12066 under
12067 <FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>,
12068
12069 </FONT>
12070 the expression is true if the unary test is true.
12071 If the first argument is not a valid unary conditional operator, the expression
12072 is false.
12073 <DT>3 arguments<DD>
12074 The following conditions are applied in the order listed.
12075 If the second argument is one of the binary conditional operators listed above
12076 under
12077 <FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>,
12078
12079 </FONT>
12080 the result of the expression is the result of the binary test using
12081 the first and third arguments as operands.
12082 The <B>-a</B> and <B>-o</B> operators are considered binary operators
12083 when there are three arguments.
12084 If the first argument is <B>!</B>, the value is the negation of
12085 the two-argument test using the second and third arguments.
12086 If the first argument is exactly <B>(</B> and the third argument is
12087 exactly <B>)</B>, the result is the one-argument test of the second
12088 argument.
12089 Otherwise, the expression is false.
12090 <DT>4 arguments<DD>
12091 If the first argument is <B>!</B>, the result is the negation of
12092 the three-argument expression composed of the remaining arguments.
12093 Otherwise, the expression is parsed and evaluated according to
12094 precedence using the rules listed above.
12095 <DT>5 or more arguments<DD>
12096 The expression is parsed and evaluated according to precedence
12097 using the rules listed above.
12098 <P>
12099
12100
12101 </DL>
12102 <P>
12103
12104 When used with <B>test</B> or <B>[</B>, the <B>&lt;</B> and <B>&gt;</B> operators
12105 sort lexicographically using ASCII ordering.
12106 </DL>
12107
12108
12109 <DT><B>times</B>
12110
12111 <DD>
12112 Print the accumulated user and system times for the shell and
12113 for processes run from the shell. The return status is 0.
12114 <DT><B>trap</B> [<B>-lp</B>] [[<I>arg</I>] <I>sigspec</I> ...]<DD>
12115 The command
12116 <I>arg</I>
12117
12118 is to be read and executed when the shell receives
12119 signal(s)
12120 <I>sigspec</I>.
12121
12122 If
12123 <I>arg</I>
12124
12125 is absent (and there is a single <I>sigspec</I>) or
12126 <B>-</B>,
12127
12128 each specified signal is
12129 reset to its original disposition (the value it had
12130 upon entrance to the shell).
12131 If
12132 <I>arg</I>
12133
12134 is the null string the signal specified by each
12135 <I>sigspec</I>
12136
12137 is ignored by the shell and by the commands it invokes.
12138 If
12139 <I>arg</I>
12140
12141 is not present and
12142 <B>-p</B>
12143
12144 has been supplied, then the trap commands associated with each
12145 <I>sigspec</I>
12146
12147 are displayed.
12148 If no arguments are supplied or if only
12149 <B>-p</B>
12150
12151 is given,
12152 <B>trap</B>
12153
12154 prints the list of commands associated with each signal.
12155 The
12156 <B>-l</B>
12157
12158 option causes the shell to print a list of signal names and
12159 their corresponding numbers.
12160 Each
12161 <I>sigspec</I>
12162
12163 is either
12164 a signal name defined in &lt;<I>signal.h</I>&gt;, or a signal number.
12165 Signal names are case insensitive and the
12166 <FONT SIZE=-1><B>SIG</B>
12167
12168 </FONT>
12169 prefix is optional.
12170 <P>
12171
12172
12173 If a
12174 <I>sigspec</I>
12175
12176 is
12177 <FONT SIZE=-1><B>EXIT</B>
12178
12179 </FONT>
12180 (0) the command
12181 <I>arg</I>
12182
12183 is executed on exit from the shell.
12184 If a
12185 <I>sigspec</I>
12186
12187 is
12188 <FONT SIZE=-1><B>DEBUG</B>,
12189
12190 </FONT>
12191 the command
12192 <I>arg</I>
12193
12194 is executed before every <I>simple command</I>, <I>for</I> command,
12195 <I>case</I> command, <I>select</I> command, every arithmetic <I>for</I>
12196 command, and before the first command executes in a shell function (see
12197 <FONT SIZE=-1><B>SHELL GRAMMAR</B>
12198
12199 </FONT>
12200 above).
12201 Refer to the description of the <B>extdebug</B> option to the
12202 <B>shopt</B> builtin for details of its effect on the <B>DEBUG</B> trap.
12203 If a
12204 <I>sigspec</I>
12205
12206 is
12207 <FONT SIZE=-1><B>RETURN</B>,
12208
12209 </FONT>
12210 the command
12211 <I>arg</I>
12212
12213 is executed each time a shell function or a script executed with
12214 the <B>.</B> or <B>source</B> builtins finishes executing.
12215 <P>
12216
12217
12218 If a
12219 <I>sigspec</I>
12220
12221 is
12222 <FONT SIZE=-1><B>ERR</B>,
12223
12224 </FONT>
12225 the command
12226 <I>arg</I>
12227
12228 is executed whenever a simple command has a non-zero exit status,
12229 subject to the following conditions.
12230 The
12231 <FONT SIZE=-1><B>ERR</B>
12232
12233 </FONT>
12234 trap is not executed if the failed
12235 command is part of the command list immediately following a
12236 <B>while</B>
12237
12238 or
12239 <B>until</B>
12240
12241 keyword,
12242 part of the test in an
12243 <I>if</I>
12244
12245 statement, part of a command executed in a
12246 <B>&amp;&amp;</B>
12247
12248 or
12249 <B>||</B>
12250
12251 list, or if the command's return value is
12252 being inverted via
12253 <B>!</B>.
12254
12255 These are the same conditions obeyed by the <B>errexit</B> option.
12256 <P>
12257
12258
12259 Signals ignored upon entry to the shell cannot be trapped or reset.
12260 Trapped signals that are not being ignored are reset to their original
12261 values in a subshell or subshell environment when one is created.
12262 The return status is false if any
12263 <I>sigspec</I>
12264
12265 is invalid; otherwise
12266 <B>trap</B>
12267
12268 returns true.
12269 <DT><B>type</B> [<B>-aftpP</B>] <I>name</I> [<I>name</I> ...]<DD>
12270 With no options,
12271 indicate how each
12272 <I>name</I>
12273
12274 would be interpreted if used as a command name.
12275 If the
12276 <B>-t</B>
12277
12278 option is used,
12279 <B>type</B>
12280
12281 prints a string which is one of
12282 <I>alias</I>,
12283
12284 <I>keyword</I>,
12285
12286 <I>function</I>,
12287
12288 <I>builtin</I>,
12289
12290 or
12291 <I>file </I>
12292
12293 if
12294 <I>name</I>
12295
12296 is an alias, shell reserved word, function, builtin, or disk file,
12297 respectively.
12298 If the
12299 <I>name</I>
12300
12301 is not found, then nothing is printed, and an exit status of false
12302 is returned.
12303 If the
12304 <B>-p</B>
12305
12306 option is used,
12307 <B>type</B>
12308
12309 either returns the name of the disk file
12310 that would be executed if
12311 <I>name</I>
12312
12313 were specified as a command name,
12314 or nothing if
12315 <TT>type -t name</TT>
12316
12317 would not return
12318 <I>file</I>.
12319
12320 The
12321 <B>-P</B>
12322
12323 option forces a
12324 <FONT SIZE=-1><B>PATH</B>
12325
12326 </FONT>
12327 search for each <I>name</I>, even if
12328 <TT>type -t name</TT>
12329
12330 would not return
12331 <I>file</I>.
12332
12333 If a command is hashed,
12334 <B>-p</B>
12335
12336 and
12337 <B>-P</B>
12338
12339 print the hashed value, which is not necessarily the file that appears
12340 first in
12341 <FONT SIZE=-1><B>PATH</B>.
12342
12343 </FONT>
12344 If the
12345 <B>-a</B>
12346
12347 option is used,
12348 <B>type</B>
12349
12350 prints all of the places that contain
12351 an executable named
12352 <I>name</I>.
12353
12354 This includes aliases and functions,
12355 if and only if the
12356 <B>-p</B>
12357
12358 option is not also used.
12359 The table of hashed commands is not consulted
12360 when using
12361 <B>-a</B>.
12362
12363 The
12364 <B>-f</B>
12365
12366 option suppresses shell function lookup, as with the <B>command</B> builtin.
12367 <B>type</B>
12368
12369 returns true if all of the arguments are found, false if
12370 any are not found.
12371 <DT><B>ulimit</B> [<B>-HSTabcdefilmnpqrstuvx</B> [<I>limit</I>]]<DD>
12372 Provides control over the resources available to the shell and to
12373 processes started by it, on systems that allow such control.
12374 The <B>-H</B> and <B>-S</B> options specify that the hard or soft limit is
12375 set for the given resource.
12376 A hard limit cannot be increased by a non-root user once it is set;
12377 a soft limit may be increased up to the value of the hard limit.
12378 If neither <B>-H</B> nor <B>-S</B> is specified, both the soft and hard
12379 limits are set.
12380 The value of
12381 <I>limit</I>
12382
12383 can be a number in the unit specified for the resource
12384 or one of the special values
12385 <B>hard</B>,
12386
12387 <B>soft</B>,
12388
12389 or
12390 <B>unlimited</B>,
12391
12392 which stand for the current hard limit, the current soft limit, and
12393 no limit, respectively.
12394 If
12395 <I>limit</I>
12396
12397 is omitted, the current value of the soft limit of the resource is
12398 printed, unless the <B>-H</B> option is given. When more than one
12399 resource is specified, the limit name and unit are printed before the value.
12400 Other options are interpreted as follows:
12401 <DL COMPACT><DT><DD>
12402
12403 <DL COMPACT>
12404 <DT><B>-a</B>
12405
12406 <DD>
12407 All current limits are reported
12408 <DT><B>-b</B>
12409
12410 <DD>
12411 The maximum socket buffer size
12412 <DT><B>-c</B>
12413
12414 <DD>
12415 The maximum size of core files created
12416 <DT><B>-d</B>
12417
12418 <DD>
12419 The maximum size of a process's data segment
12420 <DT><B>-e</B>
12421
12422 <DD>
12423 The maximum scheduling priority (&quot;nice&quot;)
12424 <DT><B>-f</B>
12425
12426 <DD>
12427 The maximum size of files written by the shell and its children
12428 <DT><B>-i</B>
12429
12430 <DD>
12431 The maximum number of pending signals
12432 <DT><B>-l</B>
12433
12434 <DD>
12435 The maximum size that may be locked into memory
12436 <DT><B>-m</B>
12437
12438 <DD>
12439 The maximum resident set size (many systems do not honor this limit)
12440 <DT><B>-n</B>
12441
12442 <DD>
12443 The maximum number of open file descriptors (most systems do not
12444 allow this value to be set)
12445 <DT><B>-p</B>
12446
12447 <DD>
12448 The pipe size in 512-byte blocks (this may not be set)
12449 <DT><B>-q</B>
12450
12451 <DD>
12452 The maximum number of bytes in POSIX message queues
12453 <DT><B>-r</B>
12454
12455 <DD>
12456 The maximum real-time scheduling priority
12457 <DT><B>-s</B>
12458
12459 <DD>
12460 The maximum stack size
12461 <DT><B>-t</B>
12462
12463 <DD>
12464 The maximum amount of cpu time in seconds
12465 <DT><B>-u</B>
12466
12467 <DD>
12468 The maximum number of processes available to a single user
12469 <DT><B>-v</B>
12470
12471 <DD>
12472 The maximum amount of virtual memory available to the shell and, on
12473 some systems, to its children
12474 <DT><B>-x</B>
12475
12476 <DD>
12477 The maximum number of file locks
12478 <DT><B>-T</B>
12479
12480 <DD>
12481 The maximum number of threads
12482
12483 </DL>
12484 <P>
12485
12486 If
12487 <I>limit</I>
12488
12489 is given, and the
12490 <B>-a</B>
12491
12492 option is not used,
12493 <I>limit</I> is the new value of the specified resource.
12494 If no option is given, then
12495 <B>-f</B>
12496
12497 is assumed. Values are in 1024-byte increments, except for
12498 <B>-t</B>,
12499
12500 which is in seconds;
12501 <B>-p</B>,
12502
12503 which is in units of 512-byte blocks;
12504 and
12505 <B>-T</B>,
12506
12507 <B>-b</B>,
12508
12509 <B>-n</B>,
12510
12511 and
12512 <B>-u</B>,
12513
12514 which are unscaled values.
12515 The return status is 0 unless an invalid option or argument is supplied,
12516 or an error occurs while setting a new limit.
12517 </DL>
12518
12519 <DT><B>umask</B> [<B>-p</B>] [<B>-S</B>] [<I>mode</I>]<DD>
12520 The user file-creation mask is set to
12521 <I>mode</I>.
12522
12523 If
12524 <I>mode</I>
12525
12526 begins with a digit, it
12527 is interpreted as an octal number; otherwise
12528 it is interpreted as a symbolic mode mask similar
12529 to that accepted by
12530 <I>chmod</I>(1).
12531
12532 If
12533 <I>mode</I>
12534
12535 is omitted, the current value of the mask is printed.
12536 The
12537 <B>-S</B>
12538
12539 option causes the mask to be printed in symbolic form; the
12540 default output is an octal number.
12541 If the
12542 <B>-p</B>
12543
12544 option is supplied, and
12545 <I>mode</I>
12546
12547 is omitted, the output is in a form that may be reused as input.
12548 The return status is 0 if the mode was successfully changed or if
12549 no <I>mode</I> argument was supplied, and false otherwise.
12550 <DT><B>unalias</B> [-<B>a</B>] [<I>name</I> ...]<DD>
12551 Remove each <I>name</I> from the list of defined aliases. If
12552 <B>-a</B>
12553
12554 is supplied, all alias definitions are removed. The return
12555 value is true unless a supplied
12556 <I>name</I>
12557
12558 is not a defined alias.
12559 <DT><B>unset</B> [-<B>fv</B>] [<I>name</I> ...]<DD>
12560 For each
12561 <I>name</I>,
12562
12563 remove the corresponding variable or function.
12564 If the
12565 <B>-v</B>
12566
12567 option is given, each
12568 <I>name</I>
12569
12570 refers to a shell variable, and that variable is removed.
12571 Read-only variables may not be unset.
12572 If
12573 <B>-f</B>
12574
12575 is specified, each
12576 <I>name</I>
12577
12578 refers to a shell function, and the function definition
12579 is removed.
12580 If no options are supplied, each <I>name</I> refers to a variable; if
12581 there is no variable by that name, any function with that name is
12582 unset.
12583 Each unset variable or function is removed from the environment
12584 passed to subsequent commands.
12585 If any of
12586 <FONT SIZE=-1><B>COMP_WORDBREAKS</B>,
12587
12588 </FONT>
12589 <FONT SIZE=-1><B>RANDOM</B>,
12590
12591 </FONT>
12592 <FONT SIZE=-1><B>SECONDS</B>,
12593
12594 </FONT>
12595 <FONT SIZE=-1><B>LINENO</B>,
12596
12597 </FONT>
12598 <FONT SIZE=-1><B>HISTCMD</B>,
12599
12600 </FONT>
12601 <FONT SIZE=-1><B>FUNCNAME</B>,
12602
12603 </FONT>
12604 <FONT SIZE=-1><B>GROUPS</B>,
12605
12606 </FONT>
12607 or
12608 <FONT SIZE=-1><B>DIRSTACK</B>
12609
12610 </FONT>
12611 are unset, they lose their special properties, even if they are
12612 subsequently reset. The exit status is true unless a
12613 <I>name</I>
12614
12615 is readonly.
12616 <DT><B>wait</B> [<I>n ...</I>]<DD>
12617 Wait for each specified process and return its termination status.
12618 Each
12619 <I>n</I>
12620
12621 may be a process
12622 ID or a job specification; if a job spec is given, all processes
12623 in that job's pipeline are waited for. If
12624 <I>n</I>
12625
12626 is not given, all currently active child processes
12627 are waited for, and the return status is zero. If
12628 <I>n</I>
12629
12630 specifies a non-existent process or job, the return status is
12631 127. Otherwise, the return status is the exit status of the last
12632 process or job waited for.
12633
12634
12635 </DL>
12636 <A NAME="lbDC">&nbsp;</A>
12637 <H3>RESTRICTED SHELL</H3>
12638
12639
12640
12641 <P>
12642
12643 If
12644 <B>bash</B>
12645
12646 is started with the name
12647 <B>rbash</B>,
12648
12649 or the
12650 <B>-r</B>
12651
12652 option is supplied at invocation,
12653 the shell becomes restricted.
12654 A restricted shell is used to
12655 set up an environment more controlled than the standard shell.
12656 It behaves identically to
12657 <B>bash</B>
12658
12659 with the exception that the following are disallowed or not performed:
12660 <DL COMPACT>
12661 <DT>*<DD>
12662 changing directories with <B>cd</B>
12663 <DT>*<DD>
12664 setting or unsetting the values of
12665 <FONT SIZE=-1><B>SHELL</B>,
12666
12667 </FONT>
12668 <FONT SIZE=-1><B>PATH</B>,
12669
12670 </FONT>
12671 <FONT SIZE=-1><B>ENV</B>,
12672
12673 </FONT>
12674 or
12675 <FONT SIZE=-1><B>BASH_ENV</B>
12676
12677 </FONT>
12678 <DT>*<DD>
12679 specifying command names containing
12680 <B>/</B>
12681
12682 <DT>*<DD>
12683 specifying a filename containing a
12684 <B>/</B>
12685
12686 as an argument to the
12687 <B>.</B>
12688
12689 builtin command
12690 <DT>*<DD>
12691 specifying a filename containing a slash as an argument to the
12692 <B>-p</B>
12693
12694 option to the
12695 <B>hash</B>
12696
12697 builtin command
12698 <DT>*<DD>
12699 importing function definitions from the shell environment at startup
12700 <DT>*<DD>
12701 parsing the value of
12702 <FONT SIZE=-1><B>SHELLOPTS</B>
12703
12704 </FONT>
12705 from the shell environment at startup
12706 <DT>*<DD>
12707 redirecting output using the &gt;, &gt;|, &lt;&gt;, &gt;&amp;, &amp;&gt;, and &gt;&gt; redirection operators
12708 <DT>*<DD>
12709 using the
12710 <B>exec</B>
12711
12712 builtin command to replace the shell with another command
12713 <DT>*<DD>
12714 adding or deleting builtin commands with the
12715 <B>-f</B>
12716
12717 and
12718 <B>-d</B>
12719
12720 options to the
12721 <B>enable</B>
12722
12723 builtin command
12724 <DT>*<DD>
12725 using the <B>enable</B> builtin command to enable disabled shell builtins
12726 <DT>*<DD>
12727 specifying the
12728 <B>-p</B>
12729
12730 option to the
12731 <B>command</B>
12732
12733 builtin command
12734 <DT>*<DD>
12735 turning off restricted mode with
12736 <B>set +r</B> or <B>set +o restricted</B>.
12737 </DL>
12738 <P>
12739
12740 These restrictions are enforced after any startup files are read.
12741 <P>
12742
12743
12744 When a command that is found to be a shell script is executed
12745 (see
12746 <FONT SIZE=-1><B>COMMAND EXECUTION</B>
12747
12748 </FONT>
12749
12750 above),
12751
12752 <B>rbash</B>
12753
12754 turns off any restrictions in the shell spawned to execute the
12755 script.
12756
12757
12758 <A NAME="lbDD">&nbsp;</A>
12759 <H3>SEE ALSO</H3>
12760
12761
12762 <DL COMPACT>
12763 <DT><I>Bash Reference Manual</I>, Brian Fox and Chet Ramey<DD>
12764 <DT><I>The Gnu Readline Library</I>, Brian Fox and Chet Ramey<DD>
12765 <DT><I>The Gnu History Library</I>, Brian Fox and Chet Ramey<DD>
12766 <DT><I>Portable Operating System Interface (POSIX) Part 2: Shell and Utilities</I>, IEEE<DD>
12767 <DT><I>sh</I>(1), <I>ksh</I>(1), <I>csh</I>(1)<DD>
12768 <DT><I>emacs</I>(1), <I>vi</I>(1)<DD>
12769 <DT><I>readline</I>(3)<DD>
12770
12771 </DL>
12772 <A NAME="lbDE">&nbsp;</A>
12773 <H3>FILES</H3>
12774
12775
12776 <DL COMPACT>
12777 <DT>
12778 <A HREF="file:/bin/bash"><I>/bin/bash</I></A>
12779
12780 <DD>
12781 The <B>bash</B> executable
12782 <DT>
12783 <A HREF="file:/etc/profile"><I>/etc/profile</I></A>
12784
12785 <DD>
12786 The systemwide initialization file, executed for login shells
12787 <DT>
12788 <A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>
12789
12790 <DD>
12791 The personal initialization file, executed for login shells
12792 <DT>
12793 <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
12794
12795 <DD>
12796 The individual per-interactive-shell startup file
12797 <DT>
12798 <A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A>
12799
12800 <DD>
12801 The individual login shell cleanup file, executed when a login shell exits
12802 <DT>
12803 <A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>
12804
12805 <DD>
12806 Individual <I>readline</I> initialization file
12807
12808 </DL>
12809 <A NAME="lbDF">&nbsp;</A>
12810 <H3>AUTHORS</H3>
12811
12812 Brian Fox, Free Software Foundation
12813 <BR>
12814
12815 <A HREF="mailto:bfox@gnu.org">bfox@gnu.org</A>
12816 <P>
12817
12818 Chet Ramey, Case Western Reserve University
12819 <BR>
12820
12821 <A HREF="mailto:chet.ramey@case.edu">chet.ramey@case.edu</A>
12822 <A NAME="lbDG">&nbsp;</A>
12823 <H3>BUG REPORTS</H3>
12824
12825 If you find a bug in
12826 <B>bash,</B>
12827
12828 you should report it. But first, you should
12829 make sure that it really is a bug, and that it appears in the latest
12830 version of
12831 <B>bash</B>.
12832
12833 The latest version is always available from
12834 <I><A HREF="ftp://ftp.gnu.org/pub/gnu/bash/">ftp://ftp.gnu.org/pub/gnu/bash/</A></I>.
12835 <P>
12836
12837 Once you have determined that a bug actually exists, use the
12838 <I>bashbug</I>
12839
12840 command to submit a bug report.
12841 If you have a fix, you are encouraged to mail that as well!
12842 Suggestions and `philosophical' bug reports may be mailed
12843 to <I><A HREF="mailto:bug-bash@gnu.org">bug-bash@gnu.org</A></I> or posted to the Usenet
12844 newsgroup
12845 <A HREF="news:gnu.bash.bug">gnu.bash.bug</A>.
12846
12847 <P>
12848
12849 ALL bug reports should include:
12850 <P>
12851
12852
12853 <DL COMPACT>
12854 <DT>The version number of <B>bash</B><DD>
12855 <DT>The hardware and operating system<DD>
12856 <DT>The compiler used to compile<DD>
12857 <DT>A description of the bug behaviour<DD>
12858 <DT>A short script or `recipe' which exercises the bug<DD>
12859
12860 </DL>
12861 <P>
12862
12863 <I>bashbug</I>
12864
12865 inserts the first three items automatically into the template
12866 it provides for filing a bug report.
12867 <P>
12868
12869 Comments and bug reports concerning
12870 this manual page should be directed to
12871 <I><A HREF="mailto:chet.ramey@case.edu">chet.ramey@case.edu</A></I>.
12872
12873 <A NAME="lbDH">&nbsp;</A>
12874 <H3>BUGS</H3>
12875
12876 <P>
12877
12878 It's too big and too slow.
12879 <P>
12880
12881 There are some subtle differences between
12882 <B>bash</B>
12883
12884 and traditional versions of
12885 <B>sh</B>,
12886
12887 mostly because of the
12888 <FONT SIZE=-1><B>POSIX</B>
12889
12890 </FONT>
12891 specification.
12892 <P>
12893
12894 Aliases are confusing in some uses.
12895 <P>
12896
12897 Shell builtin commands and functions are not stoppable/restartable.
12898 <P>
12899
12900 Compound commands and command sequences of the form `a ; b ; c'
12901 are not handled gracefully when process suspension is attempted.
12902 When a process is stopped, the shell immediately executes the next
12903 command in the sequence.
12904 It suffices to place the sequence of commands between
12905 parentheses to force it into a subshell, which may be stopped as
12906 a unit.
12907 <P>
12908
12909 Array variables may not (yet) be exported.
12910 <P>
12911
12912 There may be only one active coprocess at a time.
12913
12914
12915
12916 <HR>
12917 <TABLE WIDTH=100%>
12918 <TR>
12919 <TH ALIGN=LEFT width=33%>GNU Bash 4.2<TH ALIGN=CENTER width=33%>2012 January 29<TH ALIGN=RIGHT width=33%>BASH(1)
12920 </TR>
12921 </TABLE>
12922 <HR>
12923 <A NAME="index">&nbsp;</A><H2>Index</H2>
12924 <DL>
12925 <DT><A HREF="#lbAB">NAME</A><DD>
12926 <DT><A HREF="#lbAC">SYNOPSIS</A><DD>
12927 <DT><A HREF="#lbAD">COPYRIGHT</A><DD>
12928 <DT><A HREF="#lbAE">DESCRIPTION</A><DD>
12929 <DT><A HREF="#lbAF">OPTIONS</A><DD>
12930 <DT><A HREF="#lbAG">ARGUMENTS</A><DD>
12931 <DT><A HREF="#lbAH">INVOCATION</A><DD>
12932 <DT><A HREF="#lbAI">DEFINITIONS</A><DD>
12933 <DT><A HREF="#lbAJ">RESERVED WORDS</A><DD>
12934 <DT><A HREF="#lbAK">SHELL GRAMMAR</A><DD>
12935 <DL>
12936 <DT><A HREF="#lbAL">Simple Commands</A><DD>
12937 <DT><A HREF="#lbAM">Pipelines</A><DD>
12938 <DT><A HREF="#lbAN">Lists</A><DD>
12939 <DT><A HREF="#lbAO">Compound Commands</A><DD>
12940 <DT><A HREF="#lbAP">Coprocesses</A><DD>
12941 <DT><A HREF="#lbAQ">Shell Function Definitions</A><DD>
12942 </DL>
12943 <DT><A HREF="#lbAR">COMMENTS</A><DD>
12944 <DT><A HREF="#lbAS">QUOTING</A><DD>
12945 <DT><A HREF="#lbAT">PARAMETERS</A><DD>
12946 <DL>
12947 <DT><A HREF="#lbAU">Positional Parameters</A><DD>
12948 <DT><A HREF="#lbAV">Special Parameters</A><DD>
12949 <DT><A HREF="#lbAW">Shell Variables</A><DD>
12950 <DT><A HREF="#lbAX">Arrays</A><DD>
12951 </DL>
12952 <DT><A HREF="#lbAY">EXPANSION</A><DD>
12953 <DL>
12954 <DT><A HREF="#lbAZ">Brace Expansion</A><DD>
12955 <DT><A HREF="#lbBA">Tilde Expansion</A><DD>
12956 <DT><A HREF="#lbBB">Parameter Expansion</A><DD>
12957 <DT><A HREF="#lbBC">Command Substitution</A><DD>
12958 <DT><A HREF="#lbBD">Arithmetic Expansion</A><DD>
12959 <DT><A HREF="#lbBE">Process Substitution</A><DD>
12960 <DT><A HREF="#lbBF">Word Splitting</A><DD>
12961 <DT><A HREF="#lbBG">Pathname Expansion</A><DD>
12962 <DT><A HREF="#lbBH">Quote Removal</A><DD>
12963 </DL>
12964 <DT><A HREF="#lbBI">REDIRECTION</A><DD>
12965 <DL>
12966 <DT><A HREF="#lbBJ">Redirecting Input</A><DD>
12967 <DT><A HREF="#lbBK">Redirecting Output</A><DD>
12968 <DT><A HREF="#lbBL">Appending Redirected Output</A><DD>
12969 <DT><A HREF="#lbBM">Redirecting Standard Output and Standard Error</A><DD>
12970 <DT><A HREF="#lbBN">Appending Standard Output and Standard Error</A><DD>
12971 <DT><A HREF="#lbBO">Here Documents</A><DD>
12972 <DT><A HREF="#lbBP">Here Strings</A><DD>
12973 <DT><A HREF="#lbBQ">Duplicating File Descriptors</A><DD>
12974 <DT><A HREF="#lbBR">Moving File Descriptors</A><DD>
12975 <DT><A HREF="#lbBS">Opening File Descriptors for Reading and Writing</A><DD>
12976 </DL>
12977 <DT><A HREF="#lbBT">ALIASES</A><DD>
12978 <DT><A HREF="#lbBU">FUNCTIONS</A><DD>
12979 <DT><A HREF="#lbBV">ARITHMETIC EVALUATION</A><DD>
12980 <DT><A HREF="#lbBW">CONDITIONAL EXPRESSIONS</A><DD>
12981 <DT><A HREF="#lbBX">SIMPLE COMMAND EXPANSION</A><DD>
12982 <DT><A HREF="#lbBY">COMMAND EXECUTION</A><DD>
12983 <DT><A HREF="#lbBZ">COMMAND EXECUTION ENVIRONMENT</A><DD>
12984 <DT><A HREF="#lbCA">ENVIRONMENT</A><DD>
12985 <DT><A HREF="#lbCB">EXIT STATUS</A><DD>
12986 <DT><A HREF="#lbCC">SIGNALS</A><DD>
12987 <DT><A HREF="#lbCD">JOB CONTROL</A><DD>
12988 <DT><A HREF="#lbCE">PROMPTING</A><DD>
12989 <DT><A HREF="#lbCF">READLINE</A><DD>
12990 <DL>
12991 <DT><A HREF="#lbCG">Readline Notation</A><DD>
12992 <DT><A HREF="#lbCH">Readline Initialization</A><DD>
12993 <DT><A HREF="#lbCI">Readline Key Bindings</A><DD>
12994 <DT><A HREF="#lbCJ">Readline Variables</A><DD>
12995 <DT><A HREF="#lbCK">Readline Conditional Constructs</A><DD>
12996 <DT><A HREF="#lbCL">Searching</A><DD>
12997 <DT><A HREF="#lbCM">Readline Command Names</A><DD>
12998 <DT><A HREF="#lbCN">Commands for Moving</A><DD>
12999 <DT><A HREF="#lbCO">Commands for Manipulating the History</A><DD>
13000 <DT><A HREF="#lbCP">Commands for Changing Text</A><DD>
13001 <DT><A HREF="#lbCQ">Killing and Yanking</A><DD>
13002 <DT><A HREF="#lbCR">Numeric Arguments</A><DD>
13003 <DT><A HREF="#lbCS">Completing</A><DD>
13004 <DT><A HREF="#lbCT">Keyboard Macros</A><DD>
13005 <DT><A HREF="#lbCU">Miscellaneous</A><DD>
13006 <DT><A HREF="#lbCV">Programmable Completion</A><DD>
13007 </DL>
13008 <DT><A HREF="#lbCW">HISTORY</A><DD>
13009 <DT><A HREF="#lbCX">HISTORY EXPANSION</A><DD>
13010 <DL>
13011 <DT><A HREF="#lbCY">Event Designators</A><DD>
13012 <DT><A HREF="#lbCZ">Word Designators</A><DD>
13013 <DT><A HREF="#lbDA">Modifiers</A><DD>
13014 </DL>
13015 <DT><A HREF="#lbDB">SHELL BUILTIN COMMANDS</A><DD>
13016 <DT><A HREF="#lbDC">RESTRICTED SHELL</A><DD>
13017 <DT><A HREF="#lbDD">SEE ALSO</A><DD>
13018 <DT><A HREF="#lbDE">FILES</A><DD>
13019 <DT><A HREF="#lbDF">AUTHORS</A><DD>
13020 <DT><A HREF="#lbDG">BUG REPORTS</A><DD>
13021 <DT><A HREF="#lbDH">BUGS</A><DD>
13022 </DL>
13023 <HR>
13024 This document was created by man2html from bash.1.<BR>
13025 Time: 30 January 2012 10:38:37 EST
13026 </BODY>
13027 </HTML>