]> git.ipfire.org Git - thirdparty/bash.git/blob - doc/bashref.html
bash-5.0-rc1 release
[thirdparty/bash.git] / doc / bashref.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <!-- This text is a brief description of the features that are present in
4 the Bash shell (version 5.0, 7 December 2018).
5
6 This is Edition 5.0, last updated 7 December 2018,
7 of The GNU Bash Reference Manual,
8 for Bash, Version 5.0.
9
10 Copyright (C) 1988-2018 Free Software Foundation, Inc.
11
12 Permission is granted to copy, distribute and/or modify this document
13 under the terms of the GNU Free Documentation License, Version 1.3 or
14 any later version published by the Free Software Foundation; with no
15 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
16 A copy of the license is included in the section entitled
17 "GNU Free Documentation License". -->
18 <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
19 <head>
20 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
21 <title>Bash Reference Manual</title>
22
23 <meta name="description" content="Bash Reference Manual">
24 <meta name="keywords" content="Bash Reference Manual">
25 <meta name="resource-type" content="document">
26 <meta name="distribution" content="global">
27 <meta name="Generator" content="makeinfo">
28 <link href="#Top" rel="start" title="Top">
29 <link href="#Indexes" rel="index" title="Indexes">
30 <link href="#SEC_Contents" rel="contents" title="Table of Contents">
31 <link href="dir.html#Top" rel="up" title="(dir)">
32 <style type="text/css">
33 <!--
34 a.summary-letter {text-decoration: none}
35 blockquote.indentedblock {margin-right: 0em}
36 blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
37 blockquote.smallquotation {font-size: smaller}
38 div.display {margin-left: 3.2em}
39 div.example {margin-left: 3.2em}
40 div.lisp {margin-left: 3.2em}
41 div.smalldisplay {margin-left: 3.2em}
42 div.smallexample {margin-left: 3.2em}
43 div.smalllisp {margin-left: 3.2em}
44 kbd {font-style: oblique}
45 pre.display {font-family: inherit}
46 pre.format {font-family: inherit}
47 pre.menu-comment {font-family: serif}
48 pre.menu-preformatted {font-family: serif}
49 pre.smalldisplay {font-family: inherit; font-size: smaller}
50 pre.smallexample {font-size: smaller}
51 pre.smallformat {font-family: inherit; font-size: smaller}
52 pre.smalllisp {font-size: smaller}
53 span.nolinebreak {white-space: nowrap}
54 span.roman {font-family: initial; font-weight: normal}
55 span.sansserif {font-family: sans-serif; font-weight: normal}
56 ul.no-bullet {list-style: none}
57 -->
58 </style>
59
60
61 </head>
62
63 <body lang="en">
64 <h1 class="settitle" align="center">Bash Reference Manual</h1>
65
66
67
68
69
70
71
72
73
74
75 <a name="SEC_Contents"></a>
76 <h2 class="contents-heading">Table of Contents</h2>
77
78 <div class="contents">
79
80 <ul class="no-bullet">
81 <li><a name="toc-Introduction-1" href="#Introduction">1 Introduction</a>
82 <ul class="no-bullet">
83 <li><a name="toc-What-is-Bash_003f-1" href="#What-is-Bash_003f">1.1 What is Bash?</a></li>
84 <li><a name="toc-What-is-a-shell_003f-1" href="#What-is-a-shell_003f">1.2 What is a shell?</a></li>
85 </ul></li>
86 <li><a name="toc-Definitions-1" href="#Definitions">2 Definitions</a></li>
87 <li><a name="toc-Basic-Shell-Features-1" href="#Basic-Shell-Features">3 Basic Shell Features</a>
88 <ul class="no-bullet">
89 <li><a name="toc-Shell-Syntax-1" href="#Shell-Syntax">3.1 Shell Syntax</a>
90 <ul class="no-bullet">
91 <li><a name="toc-Shell-Operation-1" href="#Shell-Operation">3.1.1 Shell Operation</a></li>
92 <li><a name="toc-Quoting-1" href="#Quoting">3.1.2 Quoting</a>
93 <ul class="no-bullet">
94 <li><a name="toc-Escape-Character-1" href="#Escape-Character">3.1.2.1 Escape Character</a></li>
95 <li><a name="toc-Single-Quotes-1" href="#Single-Quotes">3.1.2.2 Single Quotes</a></li>
96 <li><a name="toc-Double-Quotes-1" href="#Double-Quotes">3.1.2.3 Double Quotes</a></li>
97 <li><a name="toc-ANSI_002dC-Quoting-1" href="#ANSI_002dC-Quoting">3.1.2.4 ANSI-C Quoting</a></li>
98 <li><a name="toc-Locale_002dSpecific-Translation" href="#Locale-Translation">3.1.2.5 Locale-Specific Translation</a></li>
99 </ul></li>
100 <li><a name="toc-Comments-1" href="#Comments">3.1.3 Comments</a></li>
101 </ul></li>
102 <li><a name="toc-Shell-Commands-1" href="#Shell-Commands">3.2 Shell Commands</a>
103 <ul class="no-bullet">
104 <li><a name="toc-Simple-Commands-1" href="#Simple-Commands">3.2.1 Simple Commands</a></li>
105 <li><a name="toc-Pipelines-1" href="#Pipelines">3.2.2 Pipelines</a></li>
106 <li><a name="toc-Lists-of-Commands" href="#Lists">3.2.3 Lists of Commands</a></li>
107 <li><a name="toc-Compound-Commands-1" href="#Compound-Commands">3.2.4 Compound Commands</a>
108 <ul class="no-bullet">
109 <li><a name="toc-Looping-Constructs-1" href="#Looping-Constructs">3.2.4.1 Looping Constructs</a></li>
110 <li><a name="toc-Conditional-Constructs-1" href="#Conditional-Constructs">3.2.4.2 Conditional Constructs</a></li>
111 <li><a name="toc-Grouping-Commands" href="#Command-Grouping">3.2.4.3 Grouping Commands</a></li>
112 </ul></li>
113 <li><a name="toc-Coprocesses-1" href="#Coprocesses">3.2.5 Coprocesses</a></li>
114 <li><a name="toc-GNU-Parallel-1" href="#GNU-Parallel">3.2.6 GNU Parallel</a></li>
115 </ul></li>
116 <li><a name="toc-Shell-Functions-1" href="#Shell-Functions">3.3 Shell Functions</a></li>
117 <li><a name="toc-Shell-Parameters-1" href="#Shell-Parameters">3.4 Shell Parameters</a>
118 <ul class="no-bullet">
119 <li><a name="toc-Positional-Parameters-1" href="#Positional-Parameters">3.4.1 Positional Parameters</a></li>
120 <li><a name="toc-Special-Parameters-1" href="#Special-Parameters">3.4.2 Special Parameters</a></li>
121 </ul></li>
122 <li><a name="toc-Shell-Expansions-1" href="#Shell-Expansions">3.5 Shell Expansions</a>
123 <ul class="no-bullet">
124 <li><a name="toc-Brace-Expansion-1" href="#Brace-Expansion">3.5.1 Brace Expansion</a></li>
125 <li><a name="toc-Tilde-Expansion-1" href="#Tilde-Expansion">3.5.2 Tilde Expansion</a></li>
126 <li><a name="toc-Shell-Parameter-Expansion-1" href="#Shell-Parameter-Expansion">3.5.3 Shell Parameter Expansion</a></li>
127 <li><a name="toc-Command-Substitution-1" href="#Command-Substitution">3.5.4 Command Substitution</a></li>
128 <li><a name="toc-Arithmetic-Expansion-1" href="#Arithmetic-Expansion">3.5.5 Arithmetic Expansion</a></li>
129 <li><a name="toc-Process-Substitution-1" href="#Process-Substitution">3.5.6 Process Substitution</a></li>
130 <li><a name="toc-Word-Splitting-1" href="#Word-Splitting">3.5.7 Word Splitting</a></li>
131 <li><a name="toc-Filename-Expansion-1" href="#Filename-Expansion">3.5.8 Filename Expansion</a>
132 <ul class="no-bullet">
133 <li><a name="toc-Pattern-Matching-1" href="#Pattern-Matching">3.5.8.1 Pattern Matching</a></li>
134 </ul></li>
135 <li><a name="toc-Quote-Removal-1" href="#Quote-Removal">3.5.9 Quote Removal</a></li>
136 </ul></li>
137 <li><a name="toc-Redirections-1" href="#Redirections">3.6 Redirections</a>
138 <ul class="no-bullet">
139 <li><a name="toc-Redirecting-Input" href="#Redirecting-Input">3.6.1 Redirecting Input</a></li>
140 <li><a name="toc-Redirecting-Output" href="#Redirecting-Output">3.6.2 Redirecting Output</a></li>
141 <li><a name="toc-Appending-Redirected-Output" href="#Appending-Redirected-Output">3.6.3 Appending Redirected Output</a></li>
142 <li><a name="toc-Redirecting-Standard-Output-and-Standard-Error" href="#Redirecting-Standard-Output-and-Standard-Error">3.6.4 Redirecting Standard Output and Standard Error</a></li>
143 <li><a name="toc-Appending-Standard-Output-and-Standard-Error" href="#Appending-Standard-Output-and-Standard-Error">3.6.5 Appending Standard Output and Standard Error</a></li>
144 <li><a name="toc-Here-Documents" href="#Here-Documents">3.6.6 Here Documents</a></li>
145 <li><a name="toc-Here-Strings" href="#Here-Strings">3.6.7 Here Strings</a></li>
146 <li><a name="toc-Duplicating-File-Descriptors" href="#Duplicating-File-Descriptors">3.6.8 Duplicating File Descriptors</a></li>
147 <li><a name="toc-Moving-File-Descriptors" href="#Moving-File-Descriptors">3.6.9 Moving File Descriptors</a></li>
148 <li><a name="toc-Opening-File-Descriptors-for-Reading-and-Writing" href="#Opening-File-Descriptors-for-Reading-and-Writing">3.6.10 Opening File Descriptors for Reading and Writing</a></li>
149 </ul></li>
150 <li><a name="toc-Executing-Commands-1" href="#Executing-Commands">3.7 Executing Commands</a>
151 <ul class="no-bullet">
152 <li><a name="toc-Simple-Command-Expansion-1" href="#Simple-Command-Expansion">3.7.1 Simple Command Expansion</a></li>
153 <li><a name="toc-Command-Search-and-Execution-1" href="#Command-Search-and-Execution">3.7.2 Command Search and Execution</a></li>
154 <li><a name="toc-Command-Execution-Environment-1" href="#Command-Execution-Environment">3.7.3 Command Execution Environment</a></li>
155 <li><a name="toc-Environment-1" href="#Environment">3.7.4 Environment</a></li>
156 <li><a name="toc-Exit-Status-1" href="#Exit-Status">3.7.5 Exit Status</a></li>
157 <li><a name="toc-Signals-1" href="#Signals">3.7.6 Signals</a></li>
158 </ul></li>
159 <li><a name="toc-Shell-Scripts-1" href="#Shell-Scripts">3.8 Shell Scripts</a></li>
160 </ul></li>
161 <li><a name="toc-Shell-Builtin-Commands-1" href="#Shell-Builtin-Commands">4 Shell Builtin Commands</a>
162 <ul class="no-bullet">
163 <li><a name="toc-Bourne-Shell-Builtins-1" href="#Bourne-Shell-Builtins">4.1 Bourne Shell Builtins</a></li>
164 <li><a name="toc-Bash-Builtin-Commands" href="#Bash-Builtins">4.2 Bash Builtin Commands</a></li>
165 <li><a name="toc-Modifying-Shell-Behavior-1" href="#Modifying-Shell-Behavior">4.3 Modifying Shell Behavior</a>
166 <ul class="no-bullet">
167 <li><a name="toc-The-Set-Builtin-1" href="#The-Set-Builtin">4.3.1 The Set Builtin</a></li>
168 <li><a name="toc-The-Shopt-Builtin-1" href="#The-Shopt-Builtin">4.3.2 The Shopt Builtin</a></li>
169 </ul></li>
170 <li><a name="toc-Special-Builtins-1" href="#Special-Builtins">4.4 Special Builtins</a></li>
171 </ul></li>
172 <li><a name="toc-Shell-Variables-1" href="#Shell-Variables">5 Shell Variables</a>
173 <ul class="no-bullet">
174 <li><a name="toc-Bourne-Shell-Variables-1" href="#Bourne-Shell-Variables">5.1 Bourne Shell Variables</a></li>
175 <li><a name="toc-Bash-Variables-1" href="#Bash-Variables">5.2 Bash Variables</a></li>
176 </ul></li>
177 <li><a name="toc-Bash-Features-2" href="#Bash-Features">6 Bash Features</a>
178 <ul class="no-bullet">
179 <li><a name="toc-Invoking-Bash-1" href="#Invoking-Bash">6.1 Invoking Bash</a></li>
180 <li><a name="toc-Bash-Startup-Files-1" href="#Bash-Startup-Files">6.2 Bash Startup Files</a></li>
181 <li><a name="toc-Interactive-Shells-1" href="#Interactive-Shells">6.3 Interactive Shells</a>
182 <ul class="no-bullet">
183 <li><a name="toc-What-is-an-Interactive-Shell_003f-1" href="#What-is-an-Interactive-Shell_003f">6.3.1 What is an Interactive Shell?</a></li>
184 <li><a name="toc-Is-this-Shell-Interactive_003f-1" href="#Is-this-Shell-Interactive_003f">6.3.2 Is this Shell Interactive?</a></li>
185 <li><a name="toc-Interactive-Shell-Behavior-1" href="#Interactive-Shell-Behavior">6.3.3 Interactive Shell Behavior</a></li>
186 </ul></li>
187 <li><a name="toc-Bash-Conditional-Expressions-1" href="#Bash-Conditional-Expressions">6.4 Bash Conditional Expressions</a></li>
188 <li><a name="toc-Shell-Arithmetic-1" href="#Shell-Arithmetic">6.5 Shell Arithmetic</a></li>
189 <li><a name="toc-Aliases-1" href="#Aliases">6.6 Aliases</a></li>
190 <li><a name="toc-Arrays-1" href="#Arrays">6.7 Arrays</a></li>
191 <li><a name="toc-The-Directory-Stack-1" href="#The-Directory-Stack">6.8 The Directory Stack</a>
192 <ul class="no-bullet">
193 <li><a name="toc-Directory-Stack-Builtins-1" href="#Directory-Stack-Builtins">6.8.1 Directory Stack Builtins</a></li>
194 </ul></li>
195 <li><a name="toc-Controlling-the-Prompt-1" href="#Controlling-the-Prompt">6.9 Controlling the Prompt</a></li>
196 <li><a name="toc-The-Restricted-Shell-1" href="#The-Restricted-Shell">6.10 The Restricted Shell</a></li>
197 <li><a name="toc-Bash-POSIX-Mode-1" href="#Bash-POSIX-Mode">6.11 Bash POSIX Mode</a></li>
198 </ul></li>
199 <li><a name="toc-Job-Control-1" href="#Job-Control">7 Job Control</a>
200 <ul class="no-bullet">
201 <li><a name="toc-Job-Control-Basics-1" href="#Job-Control-Basics">7.1 Job Control Basics</a></li>
202 <li><a name="toc-Job-Control-Builtins-1" href="#Job-Control-Builtins">7.2 Job Control Builtins</a></li>
203 <li><a name="toc-Job-Control-Variables-1" href="#Job-Control-Variables">7.3 Job Control Variables</a></li>
204 </ul></li>
205 <li><a name="toc-Command-Line-Editing-1" href="#Command-Line-Editing">8 Command Line Editing</a>
206 <ul class="no-bullet">
207 <li><a name="toc-Introduction-to-Line-Editing" href="#Introduction-and-Notation">8.1 Introduction to Line Editing</a></li>
208 <li><a name="toc-Readline-Interaction-1" href="#Readline-Interaction">8.2 Readline Interaction</a>
209 <ul class="no-bullet">
210 <li><a name="toc-Readline-Bare-Essentials-1" href="#Readline-Bare-Essentials">8.2.1 Readline Bare Essentials</a></li>
211 <li><a name="toc-Readline-Movement-Commands-1" href="#Readline-Movement-Commands">8.2.2 Readline Movement Commands</a></li>
212 <li><a name="toc-Readline-Killing-Commands-1" href="#Readline-Killing-Commands">8.2.3 Readline Killing Commands</a></li>
213 <li><a name="toc-Readline-Arguments-1" href="#Readline-Arguments">8.2.4 Readline Arguments</a></li>
214 <li><a name="toc-Searching-for-Commands-in-the-History" href="#Searching">8.2.5 Searching for Commands in the History</a></li>
215 </ul></li>
216 <li><a name="toc-Readline-Init-File-1" href="#Readline-Init-File">8.3 Readline Init File</a>
217 <ul class="no-bullet">
218 <li><a name="toc-Readline-Init-File-Syntax-1" href="#Readline-Init-File-Syntax">8.3.1 Readline Init File Syntax</a></li>
219 <li><a name="toc-Conditional-Init-Constructs-1" href="#Conditional-Init-Constructs">8.3.2 Conditional Init Constructs</a></li>
220 <li><a name="toc-Sample-Init-File-1" href="#Sample-Init-File">8.3.3 Sample Init File</a></li>
221 </ul></li>
222 <li><a name="toc-Bindable-Readline-Commands-1" href="#Bindable-Readline-Commands">8.4 Bindable Readline Commands</a>
223 <ul class="no-bullet">
224 <li><a name="toc-Commands-For-Moving-1" href="#Commands-For-Moving">8.4.1 Commands For Moving</a></li>
225 <li><a name="toc-Commands-For-Manipulating-The-History" href="#Commands-For-History">8.4.2 Commands For Manipulating The History</a></li>
226 <li><a name="toc-Commands-For-Changing-Text" href="#Commands-For-Text">8.4.3 Commands For Changing Text</a></li>
227 <li><a name="toc-Killing-And-Yanking" href="#Commands-For-Killing">8.4.4 Killing And Yanking</a></li>
228 <li><a name="toc-Specifying-Numeric-Arguments" href="#Numeric-Arguments">8.4.5 Specifying Numeric Arguments</a></li>
229 <li><a name="toc-Letting-Readline-Type-For-You" href="#Commands-For-Completion">8.4.6 Letting Readline Type For You</a></li>
230 <li><a name="toc-Keyboard-Macros-1" href="#Keyboard-Macros">8.4.7 Keyboard Macros</a></li>
231 <li><a name="toc-Some-Miscellaneous-Commands" href="#Miscellaneous-Commands">8.4.8 Some Miscellaneous Commands</a></li>
232 </ul></li>
233 <li><a name="toc-Readline-vi-Mode-1" href="#Readline-vi-Mode">8.5 Readline vi Mode</a></li>
234 <li><a name="toc-Programmable-Completion-1" href="#Programmable-Completion">8.6 Programmable Completion</a></li>
235 <li><a name="toc-Programmable-Completion-Builtins-1" href="#Programmable-Completion-Builtins">8.7 Programmable Completion Builtins</a></li>
236 <li><a name="toc-A-Programmable-Completion-Example-1" href="#A-Programmable-Completion-Example">8.8 A Programmable Completion Example</a></li>
237 </ul></li>
238 <li><a name="toc-Using-History-Interactively-1" href="#Using-History-Interactively">9 Using History Interactively</a>
239 <ul class="no-bullet">
240 <li><a name="toc-Bash-History-Facilities-1" href="#Bash-History-Facilities">9.1 Bash History Facilities</a></li>
241 <li><a name="toc-Bash-History-Builtins-1" href="#Bash-History-Builtins">9.2 Bash History Builtins</a></li>
242 <li><a name="toc-History-Expansion" href="#History-Interaction">9.3 History Expansion</a>
243 <ul class="no-bullet">
244 <li><a name="toc-Event-Designators-1" href="#Event-Designators">9.3.1 Event Designators</a></li>
245 <li><a name="toc-Word-Designators-1" href="#Word-Designators">9.3.2 Word Designators</a></li>
246 <li><a name="toc-Modifiers-1" href="#Modifiers">9.3.3 Modifiers</a></li>
247 </ul></li>
248 </ul></li>
249 <li><a name="toc-Installing-Bash-1" href="#Installing-Bash">10 Installing Bash</a>
250 <ul class="no-bullet">
251 <li><a name="toc-Basic-Installation-1" href="#Basic-Installation">10.1 Basic Installation</a></li>
252 <li><a name="toc-Compilers-and-Options-1" href="#Compilers-and-Options">10.2 Compilers and Options</a></li>
253 <li><a name="toc-Compiling-For-Multiple-Architectures-1" href="#Compiling-For-Multiple-Architectures">10.3 Compiling For Multiple Architectures</a></li>
254 <li><a name="toc-Installation-Names-1" href="#Installation-Names">10.4 Installation Names</a></li>
255 <li><a name="toc-Specifying-the-System-Type-1" href="#Specifying-the-System-Type">10.5 Specifying the System Type</a></li>
256 <li><a name="toc-Sharing-Defaults-1" href="#Sharing-Defaults">10.6 Sharing Defaults</a></li>
257 <li><a name="toc-Operation-Controls-1" href="#Operation-Controls">10.7 Operation Controls</a></li>
258 <li><a name="toc-Optional-Features-1" href="#Optional-Features">10.8 Optional Features</a></li>
259 </ul></li>
260 <li><a name="toc-Reporting-Bugs-1" href="#Reporting-Bugs">Appendix A Reporting Bugs</a></li>
261 <li><a name="toc-Major-Differences-From-The-Bourne-Shell-1" href="#Major-Differences-From-The-Bourne-Shell">Appendix B Major Differences From The Bourne Shell</a>
262 <ul class="no-bullet">
263 <li><a name="toc-Implementation-Differences-From-The-SVR4_002e2-Shell" href="#Implementation-Differences-From-The-SVR4_002e2-Shell">B.1 Implementation Differences From The SVR4.2 Shell</a></li>
264 </ul></li>
265 <li><a name="toc-GNU-Free-Documentation-License-1" href="#GNU-Free-Documentation-License">Appendix C GNU Free Documentation License</a></li>
266 <li><a name="toc-Indexes-1" href="#Indexes">Appendix D Indexes</a>
267 <ul class="no-bullet">
268 <li><a name="toc-Index-of-Shell-Builtin-Commands" href="#Builtin-Index">D.1 Index of Shell Builtin Commands</a></li>
269 <li><a name="toc-Index-of-Shell-Reserved-Words" href="#Reserved-Word-Index">D.2 Index of Shell Reserved Words</a></li>
270 <li><a name="toc-Parameter-and-Variable-Index" href="#Variable-Index">D.3 Parameter and Variable Index</a></li>
271 <li><a name="toc-Function-Index-1" href="#Function-Index">D.4 Function Index</a></li>
272 <li><a name="toc-Concept-Index-1" href="#Concept-Index">D.5 Concept Index</a></li>
273 </ul></li>
274 </ul>
275 </div>
276
277
278 <a name="Top"></a>
279 <div class="header">
280 <p>
281 Next: <a href="#Introduction" accesskey="n" rel="next">Introduction</a>, Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href="dir.html#Top" accesskey="u" rel="up">(dir)</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
282 </div>
283 <a name="Bash-Features-1"></a>
284 <h1 class="top">Bash Features</h1>
285
286 <p>This text is a brief description of the features that are present in
287 the Bash shell (version 5.0, 7 December 2018).
288 The Bash home page is <a href="http://www.gnu.org/software/bash/">http://www.gnu.org/software/bash/</a>.
289 </p>
290 <p>This is Edition 5.0, last updated 7 December 2018,
291 of <cite>The GNU Bash Reference Manual</cite>,
292 for <code>Bash</code>, Version 5.0.
293 </p>
294 <p>Bash contains features that appear in other popular shells, and some
295 features that only appear in Bash. Some of the shells that Bash has
296 borrowed concepts from are the Bourne Shell (<samp>sh</samp>), the Korn Shell
297 (<samp>ksh</samp>), and the C-shell (<samp>csh</samp> and its successor,
298 <samp>tcsh</samp>). The following menu breaks the features up into
299 categories, noting which features were inspired by other shells and
300 which are specific to Bash.
301 </p>
302 <p>This manual is meant as a brief introduction to features found in
303 Bash. The Bash manual page should be used as the definitive
304 reference on shell behavior.
305 </p>
306 <table class="menu" border="0" cellspacing="0">
307 <tr><td align="left" valign="top">&bull; <a href="#Introduction" accesskey="1">Introduction</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">An introduction to the shell.
308 </td></tr>
309 <tr><td align="left" valign="top">&bull; <a href="#Definitions" accesskey="2">Definitions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Some definitions used in the rest of this
310 manual.
311 </td></tr>
312 <tr><td align="left" valign="top">&bull; <a href="#Basic-Shell-Features" accesskey="3">Basic Shell Features</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The shell &quot;building blocks&quot;.
313 </td></tr>
314 <tr><td align="left" valign="top">&bull; <a href="#Shell-Builtin-Commands" accesskey="4">Shell Builtin Commands</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Commands that are a part of the shell.
315 </td></tr>
316 <tr><td align="left" valign="top">&bull; <a href="#Shell-Variables" accesskey="5">Shell Variables</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Variables used or set by Bash.
317 </td></tr>
318 <tr><td align="left" valign="top">&bull; <a href="#Bash-Features" accesskey="6">Bash Features</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Features found only in Bash.
319 </td></tr>
320 <tr><td align="left" valign="top">&bull; <a href="#Job-Control" accesskey="7">Job Control</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What job control is and how Bash allows you
321 to use it.
322 </td></tr>
323 <tr><td align="left" valign="top">&bull; <a href="#Command-Line-Editing" accesskey="8">Command Line Editing</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Chapter describing the command line
324 editing features.
325 </td></tr>
326 <tr><td align="left" valign="top">&bull; <a href="#Using-History-Interactively" accesskey="9">Using History Interactively</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Command History Expansion
327 </td></tr>
328 <tr><td align="left" valign="top">&bull; <a href="#Installing-Bash">Installing Bash</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to build and install Bash on your system.
329 </td></tr>
330 <tr><td align="left" valign="top">&bull; <a href="#Reporting-Bugs">Reporting Bugs</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to report bugs in Bash.
331 </td></tr>
332 <tr><td align="left" valign="top">&bull; <a href="#Major-Differences-From-The-Bourne-Shell">Major Differences From The Bourne Shell</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A terse list of the differences
333 between Bash and historical
334 versions of /bin/sh.
335 </td></tr>
336 <tr><td align="left" valign="top">&bull; <a href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Copying and sharing this documentation.
337 </td></tr>
338 <tr><td align="left" valign="top">&bull; <a href="#Indexes">Indexes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Various indexes for this manual.
339 </td></tr>
340 </table>
341
342 <hr>
343 <a name="Introduction"></a>
344 <div class="header">
345 <p>
346 Next: <a href="#Definitions" accesskey="n" rel="next">Definitions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
347 </div>
348 <a name="Introduction-1"></a>
349 <h2 class="chapter">1 Introduction</h2>
350 <table class="menu" border="0" cellspacing="0">
351 <tr><td align="left" valign="top">&bull; <a href="#What-is-Bash_003f" accesskey="1">What is Bash?</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A short description of Bash.
352 </td></tr>
353 <tr><td align="left" valign="top">&bull; <a href="#What-is-a-shell_003f" accesskey="2">What is a shell?</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A brief introduction to shells.
354 </td></tr>
355 </table>
356
357 <hr>
358 <a name="What-is-Bash_003f"></a>
359 <div class="header">
360 <p>
361 Next: <a href="#What-is-a-shell_003f" accesskey="n" rel="next">What is a shell?</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
362 </div>
363 <a name="What-is-Bash_003f-1"></a>
364 <h3 class="section">1.1 What is Bash?</h3>
365
366 <p>Bash is the shell, or command language interpreter,
367 for the <small>GNU</small> operating system.
368 The name is an acronym for the &lsquo;<samp>Bourne-Again SHell</samp>&rsquo;,
369 a pun on Stephen Bourne, the author of the direct ancestor of
370 the current Unix shell <code>sh</code>,
371 which appeared in the Seventh Edition Bell Labs Research version
372 of Unix.
373 </p>
374 <p>Bash is largely compatible with <code>sh</code> and incorporates useful
375 features from the Korn shell <code>ksh</code> and the C shell <code>csh</code>.
376 It is intended to be a conformant implementation of the <small>IEEE</small>
377 <small>POSIX</small> Shell and Tools portion of the <small>IEEE</small> <small>POSIX</small>
378 specification (<small>IEEE</small> Standard 1003.1).
379 It offers functional improvements over <code>sh</code> for both interactive and
380 programming use.
381 </p>
382 <p>While the <small>GNU</small> operating system provides other shells, including
383 a version of <code>csh</code>, Bash is the default shell.
384 Like other <small>GNU</small> software, Bash is quite portable. It currently runs
385 on nearly every version of Unix and a few other operating systems -
386 independently-supported ports exist for <small>MS-DOS</small>, <small>OS/2</small>,
387 and Windows platforms.
388 </p>
389 <hr>
390 <a name="What-is-a-shell_003f"></a>
391 <div class="header">
392 <p>
393 Previous: <a href="#What-is-Bash_003f" accesskey="p" rel="prev">What is Bash?</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
394 </div>
395 <a name="What-is-a-shell_003f-1"></a>
396 <h3 class="section">1.2 What is a shell?</h3>
397
398 <p>At its base, a shell is simply a macro processor that executes
399 commands. The term macro processor means functionality where text
400 and symbols are expanded to create larger expressions.
401 </p>
402 <p>A Unix shell is both a command interpreter and a programming
403 language. As a command interpreter, the shell provides the user
404 interface to the rich set of <small>GNU</small> utilities. The programming
405 language features allow these utilities to be combined.
406 Files containing commands can be created, and become
407 commands themselves. These new commands have the same status as
408 system commands in directories such as <samp>/bin</samp>, allowing users
409 or groups to establish custom environments to automate their common
410 tasks.
411 </p>
412 <p>Shells may be used interactively or non-interactively. In
413 interactive mode, they accept input typed from the keyboard.
414 When executing non-interactively, shells execute commands read
415 from a file.
416 </p>
417 <p>A shell allows execution of <small>GNU</small> commands, both synchronously and
418 asynchronously.
419 The shell waits for synchronous commands to complete before accepting
420 more input; asynchronous commands continue to execute in parallel
421 with the shell while it reads and executes additional commands.
422 The <em>redirection</em> constructs permit
423 fine-grained control of the input and output of those commands.
424 Moreover, the shell allows control over the contents of commands&rsquo;
425 environments.
426 </p>
427 <p>Shells also provide a small set of built-in
428 commands (<em>builtins</em>) implementing functionality impossible
429 or inconvenient to obtain via separate utilities.
430 For example, <code>cd</code>, <code>break</code>, <code>continue</code>, and
431 <code>exec</code> cannot be implemented outside of the shell because
432 they directly manipulate the shell itself.
433 The <code>history</code>, <code>getopts</code>, <code>kill</code>, or <code>pwd</code>
434 builtins, among others, could be implemented in separate utilities,
435 but they are more convenient to use as builtin commands.
436 All of the shell builtins are described in
437 subsequent sections.
438 </p>
439 <p>While executing commands is essential, most of the power (and
440 complexity) of shells is due to their embedded programming
441 languages. Like any high-level language, the shell provides
442 variables, flow control constructs, quoting, and functions.
443 </p>
444 <p>Shells offer features geared specifically for
445 interactive use rather than to augment the programming language.
446 These interactive features include job control, command line
447 editing, command history and aliases. Each of these features is
448 described in this manual.
449 </p>
450 <hr>
451 <a name="Definitions"></a>
452 <div class="header">
453 <p>
454 Next: <a href="#Basic-Shell-Features" accesskey="n" rel="next">Basic Shell Features</a>, Previous: <a href="#Introduction" accesskey="p" rel="prev">Introduction</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
455 </div>
456 <a name="Definitions-1"></a>
457 <h2 class="chapter">2 Definitions</h2>
458 <p>These definitions are used throughout the remainder of this manual.
459 </p>
460 <dl compact="compact">
461 <dt><code>POSIX</code></dt>
462 <dd><a name="index-POSIX"></a>
463 <p>A family of open system standards based on Unix. Bash
464 is primarily concerned with the Shell and Utilities portion of the
465 <small>POSIX</small> 1003.1 standard.
466 </p>
467 </dd>
468 <dt><code>blank</code></dt>
469 <dd><p>A space or tab character.
470 </p>
471 </dd>
472 <dt><code>builtin</code></dt>
473 <dd><a name="index-builtin-1"></a>
474 <p>A command that is implemented internally by the shell itself, rather
475 than by an executable program somewhere in the file system.
476 </p>
477 </dd>
478 <dt><code>control operator</code></dt>
479 <dd><a name="index-control-operator"></a>
480 <p>A <code>token</code> that performs a control function. It is a <code>newline</code>
481 or one of the following:
482 &lsquo;<samp>||</samp>&rsquo;, &lsquo;<samp>&amp;&amp;</samp>&rsquo;, &lsquo;<samp>&amp;</samp>&rsquo;, &lsquo;<samp>;</samp>&rsquo;, &lsquo;<samp>;;</samp>&rsquo;, &lsquo;<samp>;&amp;</samp>&rsquo;, &lsquo;<samp>;;&amp;</samp>&rsquo;,
483 &lsquo;<samp>|</samp>&rsquo;, &lsquo;<samp>|&amp;</samp>&rsquo;, &lsquo;<samp>(</samp>&rsquo;, or &lsquo;<samp>)</samp>&rsquo;.
484 </p>
485 </dd>
486 <dt><code>exit status</code></dt>
487 <dd><a name="index-exit-status"></a>
488 <p>The value returned by a command to its caller. The value is restricted
489 to eight bits, so the maximum value is 255.
490 </p>
491 </dd>
492 <dt><code>field</code></dt>
493 <dd><a name="index-field"></a>
494 <p>A unit of text that is the result of one of the shell expansions. After
495 expansion, when executing a command, the resulting fields are used as
496 the command name and arguments.
497 </p>
498 </dd>
499 <dt><code>filename</code></dt>
500 <dd><a name="index-filename"></a>
501 <p>A string of characters used to identify a file.
502 </p>
503 </dd>
504 <dt><code>job</code></dt>
505 <dd><a name="index-job"></a>
506 <p>A set of processes comprising a pipeline, and any processes descended
507 from it, that are all in the same process group.
508 </p>
509 </dd>
510 <dt><code>job control</code></dt>
511 <dd><a name="index-job-control"></a>
512 <p>A mechanism by which users can selectively stop (suspend) and restart
513 (resume) execution of processes.
514 </p>
515 </dd>
516 <dt><code>metacharacter</code></dt>
517 <dd><a name="index-metacharacter"></a>
518 <p>A character that, when unquoted, separates words. A metacharacter is
519 a <code>space</code>, <code>tab</code>, <code>newline</code>, or one of the following characters:
520 &lsquo;<samp>|</samp>&rsquo;, &lsquo;<samp>&amp;</samp>&rsquo;, &lsquo;<samp>;</samp>&rsquo;, &lsquo;<samp>(</samp>&rsquo;, &lsquo;<samp>)</samp>&rsquo;, &lsquo;<samp>&lt;</samp>&rsquo;, or
521 &lsquo;<samp>&gt;</samp>&rsquo;.
522 </p>
523 </dd>
524 <dt><code>name</code></dt>
525 <dd><a name="index-name"></a>
526 <a name="index-identifier"></a>
527 <p>A <code>word</code> consisting solely of letters, numbers, and underscores,
528 and beginning with a letter or underscore. <code>Name</code>s are used as
529 shell variable and function names.
530 Also referred to as an <code>identifier</code>.
531 </p>
532 </dd>
533 <dt><code>operator</code></dt>
534 <dd><a name="index-operator_002c-shell"></a>
535 <p>A <code>control operator</code> or a <code>redirection operator</code>.
536 See <a href="#Redirections">Redirections</a>, for a list of redirection operators.
537 Operators contain at least one unquoted <code>metacharacter</code>.
538 </p>
539 </dd>
540 <dt><code>process group</code></dt>
541 <dd><a name="index-process-group"></a>
542 <p>A collection of related processes each having the same process
543 group <small>ID</small>.
544 </p>
545 </dd>
546 <dt><code>process group ID</code></dt>
547 <dd><a name="index-process-group-ID"></a>
548 <p>A unique identifier that represents a <code>process group</code>
549 during its lifetime.
550 </p>
551 </dd>
552 <dt><code>reserved word</code></dt>
553 <dd><a name="index-reserved-word"></a>
554 <p>A <code>word</code> that has a special meaning to the shell. Most reserved
555 words introduce shell flow control constructs, such as <code>for</code> and
556 <code>while</code>.
557 </p>
558 </dd>
559 <dt><code>return status</code></dt>
560 <dd><a name="index-return-status"></a>
561 <p>A synonym for <code>exit status</code>.
562 </p>
563 </dd>
564 <dt><code>signal</code></dt>
565 <dd><a name="index-signal"></a>
566 <p>A mechanism by which a process may be notified by the kernel
567 of an event occurring in the system.
568 </p>
569 </dd>
570 <dt><code>special builtin</code></dt>
571 <dd><a name="index-special-builtin"></a>
572 <p>A shell builtin command that has been classified as special by the
573 <small>POSIX</small> standard.
574 </p>
575 </dd>
576 <dt><code>token</code></dt>
577 <dd><a name="index-token"></a>
578 <p>A sequence of characters considered a single unit by the shell.
579 It is either a <code>word</code> or an <code>operator</code>.
580 </p>
581 </dd>
582 <dt><code>word</code></dt>
583 <dd><a name="index-word"></a>
584 <p>A sequence of characters treated as a unit by the shell.
585 Words may not include unquoted <code>metacharacters</code>.
586 </p></dd>
587 </dl>
588
589 <hr>
590 <a name="Basic-Shell-Features"></a>
591 <div class="header">
592 <p>
593 Next: <a href="#Shell-Builtin-Commands" accesskey="n" rel="next">Shell Builtin Commands</a>, Previous: <a href="#Definitions" accesskey="p" rel="prev">Definitions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
594 </div>
595 <a name="Basic-Shell-Features-1"></a>
596 <h2 class="chapter">3 Basic Shell Features</h2>
597 <a name="index-Bourne-shell"></a>
598
599 <p>Bash is an acronym for &lsquo;<samp>Bourne-Again SHell</samp>&rsquo;.
600 The Bourne shell is
601 the traditional Unix shell originally written by Stephen Bourne.
602 All of the Bourne shell builtin commands are available in Bash,
603 The rules for evaluation and quoting are taken from the <small>POSIX</small>
604 specification for the &lsquo;standard&rsquo; Unix shell.
605 </p>
606 <p>This chapter briefly summarizes the shell&rsquo;s &lsquo;building blocks&rsquo;:
607 commands, control structures, shell functions, shell <i>parameters</i>,
608 shell expansions,
609 <i>redirections</i>, which are a way to direct input and output from
610 and to named files, and how the shell executes commands.
611 </p>
612 <table class="menu" border="0" cellspacing="0">
613 <tr><td align="left" valign="top">&bull; <a href="#Shell-Syntax" accesskey="1">Shell Syntax</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What your input means to the shell.
614 </td></tr>
615 <tr><td align="left" valign="top">&bull; <a href="#Shell-Commands" accesskey="2">Shell Commands</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The types of commands you can use.
616 </td></tr>
617 <tr><td align="left" valign="top">&bull; <a href="#Shell-Functions" accesskey="3">Shell Functions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Grouping commands by name.
618 </td></tr>
619 <tr><td align="left" valign="top">&bull; <a href="#Shell-Parameters" accesskey="4">Shell Parameters</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How the shell stores values.
620 </td></tr>
621 <tr><td align="left" valign="top">&bull; <a href="#Shell-Expansions" accesskey="5">Shell Expansions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How Bash expands parameters and the various
622 expansions available.
623 </td></tr>
624 <tr><td align="left" valign="top">&bull; <a href="#Redirections" accesskey="6">Redirections</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A way to control where input and output go.
625 </td></tr>
626 <tr><td align="left" valign="top">&bull; <a href="#Executing-Commands" accesskey="7">Executing Commands</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What happens when you run a command.
627 </td></tr>
628 <tr><td align="left" valign="top">&bull; <a href="#Shell-Scripts" accesskey="8">Shell Scripts</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Executing files of shell commands.
629 </td></tr>
630 </table>
631
632 <hr>
633 <a name="Shell-Syntax"></a>
634 <div class="header">
635 <p>
636 Next: <a href="#Shell-Commands" accesskey="n" rel="next">Shell Commands</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
637 </div>
638 <a name="Shell-Syntax-1"></a>
639 <h3 class="section">3.1 Shell Syntax</h3>
640 <table class="menu" border="0" cellspacing="0">
641 <tr><td align="left" valign="top">&bull; <a href="#Shell-Operation" accesskey="1">Shell Operation</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The basic operation of the shell.
642 </td></tr>
643 <tr><td align="left" valign="top">&bull; <a href="#Quoting" accesskey="2">Quoting</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to remove the special meaning from characters.
644 </td></tr>
645 <tr><td align="left" valign="top">&bull; <a href="#Comments" accesskey="3">Comments</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to specify comments.
646 </td></tr>
647 </table>
648
649 <p>When the shell reads input, it proceeds through a
650 sequence of operations. If the input indicates the beginning of a
651 comment, the shell ignores the comment symbol (&lsquo;<samp>#</samp>&rsquo;), and the rest
652 of that line.
653 </p>
654 <p>Otherwise, roughly speaking, the shell reads its input and
655 divides the input into words and operators, employing the quoting rules
656 to select which meanings to assign various words and characters.
657 </p>
658 <p>The shell then parses these tokens into commands and other constructs,
659 removes the special meaning of certain words or characters, expands
660 others, redirects input and output as needed, executes the specified
661 command, waits for the command&rsquo;s exit status, and makes that exit status
662 available for further inspection or processing.
663 </p>
664 <hr>
665 <a name="Shell-Operation"></a>
666 <div class="header">
667 <p>
668 Next: <a href="#Quoting" accesskey="n" rel="next">Quoting</a>, Up: <a href="#Shell-Syntax" accesskey="u" rel="up">Shell Syntax</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
669 </div>
670 <a name="Shell-Operation-1"></a>
671 <h4 class="subsection">3.1.1 Shell Operation</h4>
672
673 <p>The following is a brief description of the shell&rsquo;s operation when it
674 reads and executes a command. Basically, the shell does the
675 following:
676 </p>
677 <ol>
678 <li> Reads its input from a file (see <a href="#Shell-Scripts">Shell Scripts</a>), from a string
679 supplied as an argument to the <samp>-c</samp> invocation option
680 (see <a href="#Invoking-Bash">Invoking Bash</a>), or from the user&rsquo;s terminal.
681
682 </li><li> Breaks the input into words and operators, obeying the quoting rules
683 described in <a href="#Quoting">Quoting</a>. These tokens are separated by
684 <code>metacharacters</code>. Alias expansion is performed by this step
685 (see <a href="#Aliases">Aliases</a>).
686
687 </li><li> Parses the tokens into simple and compound commands
688 (see <a href="#Shell-Commands">Shell Commands</a>).
689
690 </li><li> Performs the various shell expansions (see <a href="#Shell-Expansions">Shell Expansions</a>), breaking
691 the expanded tokens into lists of filenames (see <a href="#Filename-Expansion">Filename Expansion</a>)
692 and commands and arguments.
693
694 </li><li> Performs any necessary redirections (see <a href="#Redirections">Redirections</a>) and removes
695 the redirection operators and their operands from the argument list.
696
697 </li><li> Executes the command (see <a href="#Executing-Commands">Executing Commands</a>).
698
699 </li><li> Optionally waits for the command to complete and collects its exit
700 status (see <a href="#Exit-Status">Exit Status</a>).
701
702 </li></ol>
703
704 <hr>
705 <a name="Quoting"></a>
706 <div class="header">
707 <p>
708 Next: <a href="#Comments" accesskey="n" rel="next">Comments</a>, Previous: <a href="#Shell-Operation" accesskey="p" rel="prev">Shell Operation</a>, Up: <a href="#Shell-Syntax" accesskey="u" rel="up">Shell Syntax</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
709 </div>
710 <a name="Quoting-1"></a>
711 <h4 class="subsection">3.1.2 Quoting</h4>
712 <a name="index-quoting"></a>
713 <table class="menu" border="0" cellspacing="0">
714 <tr><td align="left" valign="top">&bull; <a href="#Escape-Character" accesskey="1">Escape Character</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to remove the special meaning from a single
715 character.
716 </td></tr>
717 <tr><td align="left" valign="top">&bull; <a href="#Single-Quotes" accesskey="2">Single Quotes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to inhibit all interpretation of a sequence
718 of characters.
719 </td></tr>
720 <tr><td align="left" valign="top">&bull; <a href="#Double-Quotes" accesskey="3">Double Quotes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to suppress most of the interpretation of a
721 sequence of characters.
722 </td></tr>
723 <tr><td align="left" valign="top">&bull; <a href="#ANSI_002dC-Quoting" accesskey="4">ANSI-C Quoting</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to expand ANSI-C sequences in quoted strings.
724 </td></tr>
725 <tr><td align="left" valign="top">&bull; <a href="#Locale-Translation" accesskey="5">Locale Translation</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to translate strings into different languages.
726 </td></tr>
727 </table>
728
729 <p>Quoting is used to remove the special meaning of certain
730 characters or words to the shell. Quoting can be used to
731 disable special treatment for special characters, to prevent
732 reserved words from being recognized as such, and to prevent
733 parameter expansion.
734 </p>
735 <p>Each of the shell metacharacters (see <a href="#Definitions">Definitions</a>)
736 has special meaning to the shell and must be quoted if it is to
737 represent itself.
738 When the command history expansion facilities are being used
739 (see <a href="#History-Interaction">History Interaction</a>), the
740 <var>history expansion</var> character, usually &lsquo;<samp>!</samp>&rsquo;, must be quoted
741 to prevent history expansion. See <a href="#Bash-History-Facilities">Bash History Facilities</a>, for
742 more details concerning history expansion.
743 </p>
744 <p>There are three quoting mechanisms: the
745 <var>escape character</var>, single quotes, and double quotes.
746 </p>
747 <hr>
748 <a name="Escape-Character"></a>
749 <div class="header">
750 <p>
751 Next: <a href="#Single-Quotes" accesskey="n" rel="next">Single Quotes</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
752 </div>
753 <a name="Escape-Character-1"></a>
754 <h4 class="subsubsection">3.1.2.1 Escape Character</h4>
755 <p>A non-quoted backslash &lsquo;<samp>\</samp>&rsquo; is the Bash escape character.
756 It preserves the literal value of the next character that follows,
757 with the exception of <code>newline</code>. If a <code>\newline</code> pair
758 appears, and the backslash itself is not quoted, the <code>\newline</code>
759 is treated as a line continuation (that is, it is removed from
760 the input stream and effectively ignored).
761 </p>
762 <hr>
763 <a name="Single-Quotes"></a>
764 <div class="header">
765 <p>
766 Next: <a href="#Double-Quotes" accesskey="n" rel="next">Double Quotes</a>, Previous: <a href="#Escape-Character" accesskey="p" rel="prev">Escape Character</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
767 </div>
768 <a name="Single-Quotes-1"></a>
769 <h4 class="subsubsection">3.1.2.2 Single Quotes</h4>
770
771 <p>Enclosing characters in single quotes (&lsquo;<samp>'</samp>&rsquo;) preserves the literal value
772 of each character within the quotes. A single quote may not occur
773 between single quotes, even when preceded by a backslash.
774 </p>
775 <hr>
776 <a name="Double-Quotes"></a>
777 <div class="header">
778 <p>
779 Next: <a href="#ANSI_002dC-Quoting" accesskey="n" rel="next">ANSI-C Quoting</a>, Previous: <a href="#Single-Quotes" accesskey="p" rel="prev">Single Quotes</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
780 </div>
781 <a name="Double-Quotes-1"></a>
782 <h4 class="subsubsection">3.1.2.3 Double Quotes</h4>
783
784 <p>Enclosing characters in double quotes (&lsquo;<samp>&quot;</samp>&rsquo;) preserves the literal value
785 of all characters within the quotes, with the exception of
786 &lsquo;<samp>$</samp>&rsquo;, &lsquo;<samp>`</samp>&rsquo;, &lsquo;<samp>\</samp>&rsquo;,
787 and, when history expansion is enabled, &lsquo;<samp>!</samp>&rsquo;.
788 When the shell is in
789 <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>),
790 the &lsquo;<samp>!</samp>&rsquo; has no special meaning
791 within double quotes, even when history expansion is enabled.
792 The characters &lsquo;<samp>$</samp>&rsquo; and &lsquo;<samp>`</samp>&rsquo;
793 retain their special meaning within double quotes (see <a href="#Shell-Expansions">Shell Expansions</a>).
794 The backslash retains its special meaning only when followed by one of
795 the following characters:
796 &lsquo;<samp>$</samp>&rsquo;, &lsquo;<samp>`</samp>&rsquo;, &lsquo;<samp>&quot;</samp>&rsquo;, &lsquo;<samp>\</samp>&rsquo;, or <code>newline</code>.
797 Within double quotes, backslashes that are followed by one of these
798 characters are removed. Backslashes preceding characters without a
799 special meaning are left unmodified.
800 A double quote may be quoted within double quotes by preceding it with
801 a backslash.
802 If enabled, history expansion will be performed unless an &lsquo;<samp>!</samp>&rsquo;
803 appearing in double quotes is escaped using a backslash.
804 The backslash preceding the &lsquo;<samp>!</samp>&rsquo; is not removed.
805 </p>
806 <p>The special parameters &lsquo;<samp>*</samp>&rsquo; and &lsquo;<samp>@</samp>&rsquo; have special meaning
807 when in double quotes (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
808 </p>
809 <hr>
810 <a name="ANSI_002dC-Quoting"></a>
811 <div class="header">
812 <p>
813 Next: <a href="#Locale-Translation" accesskey="n" rel="next">Locale Translation</a>, Previous: <a href="#Double-Quotes" accesskey="p" rel="prev">Double Quotes</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
814 </div>
815 <a name="ANSI_002dC-Quoting-1"></a>
816 <h4 class="subsubsection">3.1.2.4 ANSI-C Quoting</h4>
817 <a name="index-quoting_002c-ANSI"></a>
818
819 <p>Words of the form <code>$'<var>string</var>'</code> are treated specially. The
820 word expands to <var>string</var>, with backslash-escaped characters replaced
821 as specified by the ANSI C standard. Backslash escape sequences, if
822 present, are decoded as follows:
823 </p>
824 <dl compact="compact">
825 <dt><code>\a</code></dt>
826 <dd><p>alert (bell)
827 </p></dd>
828 <dt><code>\b</code></dt>
829 <dd><p>backspace
830 </p></dd>
831 <dt><code>\e</code></dt>
832 <dt><code>\E</code></dt>
833 <dd><p>an escape character (not ANSI C)
834 </p></dd>
835 <dt><code>\f</code></dt>
836 <dd><p>form feed
837 </p></dd>
838 <dt><code>\n</code></dt>
839 <dd><p>newline
840 </p></dd>
841 <dt><code>\r</code></dt>
842 <dd><p>carriage return
843 </p></dd>
844 <dt><code>\t</code></dt>
845 <dd><p>horizontal tab
846 </p></dd>
847 <dt><code>\v</code></dt>
848 <dd><p>vertical tab
849 </p></dd>
850 <dt><code>\\</code></dt>
851 <dd><p>backslash
852 </p></dd>
853 <dt><code>\'</code></dt>
854 <dd><p>single quote
855 </p></dd>
856 <dt><code>\&quot;</code></dt>
857 <dd><p>double quote
858 </p></dd>
859 <dt><code>\?</code></dt>
860 <dd><p>question mark
861 </p></dd>
862 <dt><code>\<var>nnn</var></code></dt>
863 <dd><p>the eight-bit character whose value is the octal value <var>nnn</var>
864 (one to three octal digits)
865 </p></dd>
866 <dt><code>\x<var>HH</var></code></dt>
867 <dd><p>the eight-bit character whose value is the hexadecimal value <var>HH</var>
868 (one or two hex digits)
869 </p></dd>
870 <dt><code>\u<var>HHHH</var></code></dt>
871 <dd><p>the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
872 <var>HHHH</var> (one to four hex digits)
873 </p></dd>
874 <dt><code>\U<var>HHHHHHHH</var></code></dt>
875 <dd><p>the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
876 <var>HHHHHHHH</var> (one to eight hex digits)
877 </p></dd>
878 <dt><code>\c<var>x</var></code></dt>
879 <dd><p>a control-<var>x</var> character
880 </p></dd>
881 </dl>
882
883 <p>The expanded result is single-quoted, as if the dollar sign had not
884 been present.
885 </p>
886 <hr>
887 <a name="Locale-Translation"></a>
888 <div class="header">
889 <p>
890 Previous: <a href="#ANSI_002dC-Quoting" accesskey="p" rel="prev">ANSI-C Quoting</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
891 </div>
892 <a name="Locale_002dSpecific-Translation"></a>
893 <h4 class="subsubsection">3.1.2.5 Locale-Specific Translation</h4>
894 <a name="index-localization"></a>
895 <a name="index-internationalization"></a>
896 <a name="index-native-languages"></a>
897 <a name="index-translation_002c-native-languages"></a>
898
899 <p>A double-quoted string preceded by a dollar sign (&lsquo;<samp>$</samp>&rsquo;) will cause
900 the string to be translated according to the current locale.
901 If the current locale is <code>C</code> or <code>POSIX</code>, the dollar sign
902 is ignored.
903 If the string is translated and replaced, the replacement is
904 double-quoted.
905 </p>
906 <a name="index-LC_005fMESSAGES"></a>
907 <a name="index-TEXTDOMAIN"></a>
908 <a name="index-TEXTDOMAINDIR"></a>
909 <p>Some systems use the message catalog selected by the <code>LC_MESSAGES</code>
910 shell variable. Others create the name of the message catalog from the
911 value of the <code>TEXTDOMAIN</code> shell variable, possibly adding a
912 suffix of &lsquo;<samp>.mo</samp>&rsquo;. If you use the <code>TEXTDOMAIN</code> variable, you
913 may need to set the <code>TEXTDOMAINDIR</code> variable to the location of
914 the message catalog files. Still others use both variables in this
915 fashion:
916 <code>TEXTDOMAINDIR</code>/<code>LC_MESSAGES</code>/LC_MESSAGES/<code>TEXTDOMAIN</code>.mo.
917 </p>
918 <hr>
919 <a name="Comments"></a>
920 <div class="header">
921 <p>
922 Previous: <a href="#Quoting" accesskey="p" rel="prev">Quoting</a>, Up: <a href="#Shell-Syntax" accesskey="u" rel="up">Shell Syntax</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
923 </div>
924 <a name="Comments-1"></a>
925 <h4 class="subsection">3.1.3 Comments</h4>
926 <a name="index-comments_002c-shell"></a>
927
928 <p>In a non-interactive shell, or an interactive shell in which the
929 <code>interactive_comments</code> option to the <code>shopt</code>
930 builtin is enabled (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>),
931 a word beginning with &lsquo;<samp>#</samp>&rsquo;
932 causes that word and all remaining characters on that line to
933 be ignored. An interactive shell without the <code>interactive_comments</code>
934 option enabled does not allow comments. The <code>interactive_comments</code>
935 option is on by default in interactive shells.
936 See <a href="#Interactive-Shells">Interactive Shells</a>, for a description of what makes
937 a shell interactive.
938 </p>
939 <hr>
940 <a name="Shell-Commands"></a>
941 <div class="header">
942 <p>
943 Next: <a href="#Shell-Functions" accesskey="n" rel="next">Shell Functions</a>, Previous: <a href="#Shell-Syntax" accesskey="p" rel="prev">Shell Syntax</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
944 </div>
945 <a name="Shell-Commands-1"></a>
946 <h3 class="section">3.2 Shell Commands</h3>
947 <a name="index-commands_002c-shell"></a>
948
949 <p>A simple shell command such as <code>echo a b c</code> consists of the command
950 itself followed by arguments, separated by spaces.
951 </p>
952 <p>More complex shell commands are composed of simple commands arranged together
953 in a variety of ways: in a pipeline in which the output of one command
954 becomes the input of a second, in a loop or conditional construct, or in
955 some other grouping.
956 </p>
957 <table class="menu" border="0" cellspacing="0">
958 <tr><td align="left" valign="top">&bull; <a href="#Simple-Commands" accesskey="1">Simple Commands</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The most common type of command.
959 </td></tr>
960 <tr><td align="left" valign="top">&bull; <a href="#Pipelines" accesskey="2">Pipelines</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Connecting the input and output of several
961 commands.
962 </td></tr>
963 <tr><td align="left" valign="top">&bull; <a href="#Lists" accesskey="3">Lists</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to execute commands sequentially.
964 </td></tr>
965 <tr><td align="left" valign="top">&bull; <a href="#Compound-Commands" accesskey="4">Compound Commands</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Shell commands for control flow.
966 </td></tr>
967 <tr><td align="left" valign="top">&bull; <a href="#Coprocesses" accesskey="5">Coprocesses</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Two-way communication between commands.
968 </td></tr>
969 <tr><td align="left" valign="top">&bull; <a href="#GNU-Parallel" accesskey="6">GNU Parallel</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Running commands in parallel.
970 </td></tr>
971 </table>
972
973 <hr>
974 <a name="Simple-Commands"></a>
975 <div class="header">
976 <p>
977 Next: <a href="#Pipelines" accesskey="n" rel="next">Pipelines</a>, Up: <a href="#Shell-Commands" accesskey="u" rel="up">Shell Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
978 </div>
979 <a name="Simple-Commands-1"></a>
980 <h4 class="subsection">3.2.1 Simple Commands</h4>
981 <a name="index-commands_002c-simple"></a>
982
983 <p>A simple command is the kind of command encountered most often.
984 It&rsquo;s just a sequence of words separated by <code>blank</code>s, terminated
985 by one of the shell&rsquo;s control operators (see <a href="#Definitions">Definitions</a>). The
986 first word generally specifies a command to be executed, with the
987 rest of the words being that command&rsquo;s arguments.
988 </p>
989 <p>The return status (see <a href="#Exit-Status">Exit Status</a>) of a simple command is
990 its exit status as provided
991 by the <small>POSIX</small> 1003.1 <code>waitpid</code> function, or 128+<var>n</var> if
992 the command was terminated by signal <var>n</var>.
993 </p>
994 <hr>
995 <a name="Pipelines"></a>
996 <div class="header">
997 <p>
998 Next: <a href="#Lists" accesskey="n" rel="next">Lists</a>, Previous: <a href="#Simple-Commands" accesskey="p" rel="prev">Simple Commands</a>, Up: <a href="#Shell-Commands" accesskey="u" rel="up">Shell Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
999 </div>
1000 <a name="Pipelines-1"></a>
1001 <h4 class="subsection">3.2.2 Pipelines</h4>
1002 <a name="index-pipeline"></a>
1003 <a name="index-commands_002c-pipelines"></a>
1004
1005 <p>A <code>pipeline</code> is a sequence of one or more commands separated by
1006 one of the control operators &lsquo;<samp>|</samp>&rsquo; or &lsquo;<samp>|&amp;</samp>&rsquo;.
1007 </p>
1008 <a name="index-time"></a>
1009 <a name="index-_0021"></a>
1010 <a name="index-command-timing"></a>
1011 <p>The format for a pipeline is
1012 </p><div class="example">
1013 <pre class="example">[time [-p]] [!] <var>command1</var> [ | or |&amp; <var>command2</var> ] &hellip;
1014 </pre></div>
1015
1016 <p>The output of each command in the pipeline is connected via a pipe
1017 to the input of the next command.
1018 That is, each command reads the previous command&rsquo;s output. This
1019 connection is performed before any redirections specified by the
1020 command.
1021 </p>
1022 <p>If &lsquo;<samp>|&amp;</samp>&rsquo; is used, <var>command1</var>&rsquo;s standard error, in addition to
1023 its standard output, is connected to
1024 <var>command2</var>&rsquo;s standard input through the pipe;
1025 it is shorthand for <code>2&gt;&amp;1 |</code>.
1026 This implicit redirection of the standard error to the standard output is
1027 performed after any redirections specified by the command.
1028 </p>
1029 <p>The reserved word <code>time</code> causes timing statistics
1030 to be printed for the pipeline once it finishes.
1031 The statistics currently consist of elapsed (wall-clock) time and
1032 user and system time consumed by the command&rsquo;s execution.
1033 The <samp>-p</samp> option changes the output format to that specified
1034 by <small>POSIX</small>.
1035 When the shell is in <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>),
1036 it does not recognize <code>time</code> as a reserved word if the next
1037 token begins with a &lsquo;<samp>-</samp>&rsquo;.
1038 The <code>TIMEFORMAT</code> variable may be set to a format string that
1039 specifies how the timing information should be displayed.
1040 See <a href="#Bash-Variables">Bash Variables</a>, for a description of the available formats.
1041 The use of <code>time</code> as a reserved word permits the timing of
1042 shell builtins, shell functions, and pipelines. An external
1043 <code>time</code> command cannot time these easily.
1044 </p>
1045 <p>When the shell is in <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>), <code>time</code>
1046 may be followed by a newline. In this case, the shell displays the
1047 total user and system time consumed by the shell and its children.
1048 The <code>TIMEFORMAT</code> variable may be used to specify the format of
1049 the time information.
1050 </p>
1051 <p>If the pipeline is not executed asynchronously (see <a href="#Lists">Lists</a>), the
1052 shell waits for all commands in the pipeline to complete.
1053 </p>
1054 <p>Each command in a pipeline is executed in its own subshell, which is a
1055 separate process (see <a href="#Command-Execution-Environment">Command Execution Environment</a>).
1056 If the <code>lastpipe</code> option is enabled using the <code>shopt</code> builtin
1057 (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>),
1058 the last element of a pipeline may be run by the shell process.
1059 </p>
1060 <p>The exit
1061 status of a pipeline is the exit status of the last command in the
1062 pipeline, unless the <code>pipefail</code> option is enabled
1063 (see <a href="#The-Set-Builtin">The Set Builtin</a>).
1064 If <code>pipefail</code> is enabled, the pipeline&rsquo;s return status is the
1065 value of the last (rightmost) command to exit with a non-zero status,
1066 or zero if all commands exit successfully.
1067 If the reserved word &lsquo;<samp>!</samp>&rsquo; precedes the pipeline, the
1068 exit status is the logical negation of the exit status as described
1069 above.
1070 The shell waits for all commands in the pipeline to terminate before
1071 returning a value.
1072 </p>
1073 <hr>
1074 <a name="Lists"></a>
1075 <div class="header">
1076 <p>
1077 Next: <a href="#Compound-Commands" accesskey="n" rel="next">Compound Commands</a>, Previous: <a href="#Pipelines" accesskey="p" rel="prev">Pipelines</a>, Up: <a href="#Shell-Commands" accesskey="u" rel="up">Shell Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
1078 </div>
1079 <a name="Lists-of-Commands"></a>
1080 <h4 class="subsection">3.2.3 Lists of Commands</h4>
1081 <a name="index-commands_002c-lists"></a>
1082
1083 <p>A <code>list</code> is a sequence of one or more pipelines separated by one
1084 of the operators &lsquo;<samp>;</samp>&rsquo;, &lsquo;<samp>&amp;</samp>&rsquo;, &lsquo;<samp>&amp;&amp;</samp>&rsquo;, or &lsquo;<samp>||</samp>&rsquo;,
1085 and optionally terminated by one of &lsquo;<samp>;</samp>&rsquo;, &lsquo;<samp>&amp;</samp>&rsquo;, or a
1086 <code>newline</code>.
1087 </p>
1088 <p>Of these list operators, &lsquo;<samp>&amp;&amp;</samp>&rsquo; and &lsquo;<samp>||</samp>&rsquo;
1089 have equal precedence, followed by &lsquo;<samp>;</samp>&rsquo; and &lsquo;<samp>&amp;</samp>&rsquo;,
1090 which have equal precedence.
1091 </p>
1092 <p>A sequence of one or more newlines may appear in a <code>list</code>
1093 to delimit commands, equivalent to a semicolon.
1094 </p>
1095 <p>If a command is terminated by the control operator &lsquo;<samp>&amp;</samp>&rsquo;,
1096 the shell executes the command asynchronously in a subshell.
1097 This is known as executing the command in the <var>background</var>,
1098 and these are referred to as <var>asynchronous</var> commands.
1099 The shell does not wait for the command to finish, and the return
1100 status is 0 (true).
1101 When job control is not active (see <a href="#Job-Control">Job Control</a>),
1102 the standard input for asynchronous commands, in the absence of any
1103 explicit redirections, is redirected from <code>/dev/null</code>.
1104 </p>
1105 <p>Commands separated by a &lsquo;<samp>;</samp>&rsquo; are executed sequentially; the shell
1106 waits for each command to terminate in turn. The return status is the
1107 exit status of the last command executed.
1108 </p>
1109 <p><small>AND</small> and <small>OR</small> lists are sequences of one or more pipelines
1110 separated by the control operators &lsquo;<samp>&amp;&amp;</samp>&rsquo; and &lsquo;<samp>||</samp>&rsquo;,
1111 respectively. <small>AND</small> and <small>OR</small> lists are executed with left
1112 associativity.
1113 </p>
1114 <p>An <small>AND</small> list has the form
1115 </p><div class="example">
1116 <pre class="example"><var>command1</var> &amp;&amp; <var>command2</var>
1117 </pre></div>
1118
1119 <p><var>command2</var> is executed if, and only if, <var>command1</var>
1120 returns an exit status of zero (success).
1121 </p>
1122 <p>An <small>OR</small> list has the form
1123 </p><div class="example">
1124 <pre class="example"><var>command1</var> || <var>command2</var>
1125 </pre></div>
1126
1127 <p><var>command2</var> is executed if, and only if, <var>command1</var>
1128 returns a non-zero exit status.
1129 </p>
1130 <p>The return status of
1131 <small>AND</small> and <small>OR</small> lists is the exit status of the last command
1132 executed in the list.
1133 </p>
1134 <hr>
1135 <a name="Compound-Commands"></a>
1136 <div class="header">
1137 <p>
1138 Next: <a href="#Coprocesses" accesskey="n" rel="next">Coprocesses</a>, Previous: <a href="#Lists" accesskey="p" rel="prev">Lists</a>, Up: <a href="#Shell-Commands" accesskey="u" rel="up">Shell Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
1139 </div>
1140 <a name="Compound-Commands-1"></a>
1141 <h4 class="subsection">3.2.4 Compound Commands</h4>
1142 <a name="index-commands_002c-compound"></a>
1143
1144 <table class="menu" border="0" cellspacing="0">
1145 <tr><td align="left" valign="top">&bull; <a href="#Looping-Constructs" accesskey="1">Looping Constructs</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Shell commands for iterative action.
1146 </td></tr>
1147 <tr><td align="left" valign="top">&bull; <a href="#Conditional-Constructs" accesskey="2">Conditional Constructs</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Shell commands for conditional execution.
1148 </td></tr>
1149 <tr><td align="left" valign="top">&bull; <a href="#Command-Grouping" accesskey="3">Command Grouping</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Ways to group commands.
1150 </td></tr>
1151 </table>
1152
1153 <p>Compound commands are the shell programming language constructs.
1154 Each construct begins with a reserved word or control operator and is
1155 terminated by a corresponding reserved word or operator.
1156 Any redirections (see <a href="#Redirections">Redirections</a>) associated with a compound command
1157 apply to all commands within that compound command unless explicitly overridden.
1158 </p>
1159 <p>In most cases a list of commands in a compound command&rsquo;s description may be
1160 separated from the rest of the command by one or more newlines, and may be
1161 followed by a newline in place of a semicolon.
1162 </p>
1163 <p>Bash provides looping constructs, conditional commands, and mechanisms
1164 to group commands and execute them as a unit.
1165 </p>
1166 <hr>
1167 <a name="Looping-Constructs"></a>
1168 <div class="header">
1169 <p>
1170 Next: <a href="#Conditional-Constructs" accesskey="n" rel="next">Conditional Constructs</a>, Up: <a href="#Compound-Commands" accesskey="u" rel="up">Compound Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
1171 </div>
1172 <a name="Looping-Constructs-1"></a>
1173 <h4 class="subsubsection">3.2.4.1 Looping Constructs</h4>
1174 <a name="index-commands_002c-looping"></a>
1175
1176 <p>Bash supports the following looping constructs.
1177 </p>
1178 <p>Note that wherever a &lsquo;<samp>;</samp>&rsquo; appears in the description of a
1179 command&rsquo;s syntax, it may be replaced with one or more newlines.
1180 </p>
1181 <dl compact="compact">
1182 <dt><code>until</code></dt>
1183 <dd><a name="index-until"></a>
1184 <a name="index-do"></a>
1185 <a name="index-done"></a>
1186 <p>The syntax of the <code>until</code> command is:
1187 </p>
1188 <div class="example">
1189 <pre class="example">until <var>test-commands</var>; do <var>consequent-commands</var>; done
1190 </pre></div>
1191
1192 <p>Execute <var>consequent-commands</var> as long as
1193 <var>test-commands</var> has an exit status which is not zero.
1194 The return status is the exit status of the last command executed
1195 in <var>consequent-commands</var>, or zero if none was executed.
1196 </p>
1197 </dd>
1198 <dt><code>while</code></dt>
1199 <dd><a name="index-while"></a>
1200 <p>The syntax of the <code>while</code> command is:
1201 </p>
1202 <div class="example">
1203 <pre class="example">while <var>test-commands</var>; do <var>consequent-commands</var>; done
1204 </pre></div>
1205
1206 <p>Execute <var>consequent-commands</var> as long as
1207 <var>test-commands</var> has an exit status of zero.
1208 The return status is the exit status of the last command executed
1209 in <var>consequent-commands</var>, or zero if none was executed.
1210 </p>
1211 </dd>
1212 <dt><code>for</code></dt>
1213 <dd><a name="index-for"></a>
1214 <p>The syntax of the <code>for</code> command is:
1215 </p>
1216 <div class="example">
1217 <pre class="example">for <var>name</var> [ [in [<var>words</var> &hellip;] ] ; ] do <var>commands</var>; done
1218 </pre></div>
1219
1220 <p>Expand <var>words</var> (see <a href="#Shell-Expansions">Shell Expansions</a>), and execute <var>commands</var>
1221 once for each member
1222 in the resultant list, with <var>name</var> bound to the current member.
1223 If &lsquo;<samp>in <var>words</var></samp>&rsquo; is not present, the <code>for</code> command
1224 executes the <var>commands</var> once for each positional parameter that is
1225 set, as if &lsquo;<samp>in &quot;$@&quot;</samp>&rsquo; had been specified
1226 (see <a href="#Special-Parameters">Special Parameters</a>).
1227 </p>
1228 <p>The return status is the exit status of the last command that executes.
1229 If there are no items in the expansion of <var>words</var>, no commands are
1230 executed, and the return status is zero.
1231 </p>
1232 <p>An alternate form of the <code>for</code> command is also supported:
1233 </p>
1234 <div class="example">
1235 <pre class="example">for (( <var>expr1</var> ; <var>expr2</var> ; <var>expr3</var> )) ; do <var>commands</var> ; done
1236 </pre></div>
1237
1238 <p>First, the arithmetic expression <var>expr1</var> is evaluated according
1239 to the rules described below (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>).
1240 The arithmetic expression <var>expr2</var> is then evaluated repeatedly
1241 until it evaluates to zero.
1242 Each time <var>expr2</var> evaluates to a non-zero value, <var>commands</var> are
1243 executed and the arithmetic expression <var>expr3</var> is evaluated.
1244 If any expression is omitted, it behaves as if it evaluates to 1.
1245 The return value is the exit status of the last command in <var>commands</var>
1246 that is executed, or false if any of the expressions is invalid.
1247 </p></dd>
1248 </dl>
1249
1250 <p>The <code>break</code> and <code>continue</code> builtins (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>)
1251 may be used to control loop execution.
1252 </p>
1253 <hr>
1254 <a name="Conditional-Constructs"></a>
1255 <div class="header">
1256 <p>
1257 Next: <a href="#Command-Grouping" accesskey="n" rel="next">Command Grouping</a>, Previous: <a href="#Looping-Constructs" accesskey="p" rel="prev">Looping Constructs</a>, Up: <a href="#Compound-Commands" accesskey="u" rel="up">Compound Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
1258 </div>
1259 <a name="Conditional-Constructs-1"></a>
1260 <h4 class="subsubsection">3.2.4.2 Conditional Constructs</h4>
1261 <a name="index-commands_002c-conditional"></a>
1262
1263 <dl compact="compact">
1264 <dt><code>if</code></dt>
1265 <dd><a name="index-if"></a>
1266 <a name="index-then"></a>
1267 <a name="index-else"></a>
1268 <a name="index-elif"></a>
1269 <a name="index-fi"></a>
1270 <p>The syntax of the <code>if</code> command is:
1271 </p>
1272 <div class="example">
1273 <pre class="example">if <var>test-commands</var>; then
1274 <var>consequent-commands</var>;
1275 [elif <var>more-test-commands</var>; then
1276 <var>more-consequents</var>;]
1277 [else <var>alternate-consequents</var>;]
1278 fi
1279 </pre></div>
1280
1281 <p>The <var>test-commands</var> list is executed, and if its return status is zero,
1282 the <var>consequent-commands</var> list is executed.
1283 If <var>test-commands</var> returns a non-zero status, each <code>elif</code> list
1284 is executed in turn, and if its exit status is zero,
1285 the corresponding <var>more-consequents</var> is executed and the
1286 command completes.
1287 If &lsquo;<samp>else <var>alternate-consequents</var></samp>&rsquo; is present, and
1288 the final command in the final <code>if</code> or <code>elif</code> clause
1289 has a non-zero exit status, then <var>alternate-consequents</var> is executed.
1290 The return status is the exit status of the last command executed, or
1291 zero if no condition tested true.
1292 </p>
1293 </dd>
1294 <dt><code>case</code></dt>
1295 <dd><a name="index-case"></a>
1296 <a name="index-in"></a>
1297 <a name="index-esac"></a>
1298 <p>The syntax of the <code>case</code> command is:
1299 </p>
1300 <div class="example">
1301 <pre class="example">case <var>word</var> in
1302 [ [(] <var>pattern</var> [| <var>pattern</var>]&hellip;) <var>command-list</var> ;;]&hellip;
1303 esac
1304 </pre></div>
1305
1306 <p><code>case</code> will selectively execute the <var>command-list</var> corresponding to
1307 the first <var>pattern</var> that matches <var>word</var>.
1308 The match is performed according
1309 to the rules described below in <a href="#Pattern-Matching">Pattern Matching</a>.
1310 If the <code>nocasematch</code> shell option
1311 (see the description of <code>shopt</code> in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>)
1312 is enabled, the match is performed without regard to the case
1313 of alphabetic characters.
1314 The &lsquo;<samp>|</samp>&rsquo; is used to separate multiple patterns, and the &lsquo;<samp>)</samp>&rsquo;
1315 operator terminates a pattern list.
1316 A list of patterns and an associated command-list is known
1317 as a <var>clause</var>.
1318 </p>
1319 <p>Each clause must be terminated with &lsquo;<samp>;;</samp>&rsquo;, &lsquo;<samp>;&amp;</samp>&rsquo;, or &lsquo;<samp>;;&amp;</samp>&rsquo;.
1320 The <var>word</var> undergoes tilde expansion, parameter expansion, command
1321 substitution, arithmetic expansion, and quote removal
1322 (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>)
1323 before matching is
1324 attempted. Each <var>pattern</var> undergoes tilde expansion, parameter
1325 expansion, command substitution, and arithmetic expansion.
1326 </p>
1327 <p>There may be an arbitrary number of <code>case</code> clauses, each terminated
1328 by a &lsquo;<samp>;;</samp>&rsquo;, &lsquo;<samp>;&amp;</samp>&rsquo;, or &lsquo;<samp>;;&amp;</samp>&rsquo;.
1329 The first pattern that matches determines the
1330 command-list that is executed.
1331 It&rsquo;s a common idiom to use &lsquo;<samp>*</samp>&rsquo; as the final pattern to define the
1332 default case, since that pattern will always match.
1333 </p>
1334 <p>Here is an example using <code>case</code> in a script that could be used to
1335 describe one interesting feature of an animal:
1336 </p>
1337 <div class="example">
1338 <pre class="example">echo -n &quot;Enter the name of an animal: &quot;
1339 read ANIMAL
1340 echo -n &quot;The $ANIMAL has &quot;
1341 case $ANIMAL in
1342 horse | dog | cat) echo -n &quot;four&quot;;;
1343 man | kangaroo ) echo -n &quot;two&quot;;;
1344 *) echo -n &quot;an unknown number of&quot;;;
1345 esac
1346 echo &quot; legs.&quot;
1347 </pre></div>
1348
1349
1350 <p>If the &lsquo;<samp>;;</samp>&rsquo; operator is used, no subsequent matches are attempted after
1351 the first pattern match.
1352 Using &lsquo;<samp>;&amp;</samp>&rsquo; in place of &lsquo;<samp>;;</samp>&rsquo; causes execution to continue with
1353 the <var>command-list</var> associated with the next clause, if any.
1354 Using &lsquo;<samp>;;&amp;</samp>&rsquo; in place of &lsquo;<samp>;;</samp>&rsquo; causes the shell to test the patterns
1355 in the next clause, if any, and execute any associated <var>command-list</var>
1356 on a successful match.
1357 </p>
1358 <p>The return status is zero if no <var>pattern</var> is matched. Otherwise, the
1359 return status is the exit status of the <var>command-list</var> executed.
1360 </p>
1361 </dd>
1362 <dt><code>select</code></dt>
1363 <dd><a name="index-select"></a>
1364
1365 <p>The <code>select</code> construct allows the easy generation of menus.
1366 It has almost the same syntax as the <code>for</code> command:
1367 </p>
1368 <div class="example">
1369 <pre class="example">select <var>name</var> [in <var>words</var> &hellip;]; do <var>commands</var>; done
1370 </pre></div>
1371
1372 <p>The list of words following <code>in</code> is expanded, generating a list
1373 of items. The set of expanded words is printed on the standard
1374 error output stream, each preceded by a number. If the
1375 &lsquo;<samp>in <var>words</var></samp>&rsquo; is omitted, the positional parameters are printed,
1376 as if &lsquo;<samp>in &quot;$@&quot;</samp>&rsquo; had been specified.
1377 The <code>PS3</code> prompt is then displayed and a line is read from the
1378 standard input.
1379 If the line consists of a number corresponding to one of the displayed
1380 words, then the value of <var>name</var> is set to that word.
1381 If the line is empty, the words and prompt are displayed again.
1382 If <code>EOF</code> is read, the <code>select</code> command completes.
1383 Any other value read causes <var>name</var> to be set to null.
1384 The line read is saved in the variable <code>REPLY</code>.
1385 </p>
1386 <p>The <var>commands</var> are executed after each selection until a
1387 <code>break</code> command is executed, at which
1388 point the <code>select</code> command completes.
1389 </p>
1390 <p>Here is an example that allows the user to pick a filename from the
1391 current directory, and displays the name and index of the file
1392 selected.
1393 </p>
1394 <div class="example">
1395 <pre class="example">select fname in *;
1396 do
1397 echo you picked $fname \($REPLY\)
1398 break;
1399 done
1400 </pre></div>
1401
1402 </dd>
1403 <dt><code>((&hellip;))</code></dt>
1404 <dd><div class="example">
1405 <pre class="example">(( <var>expression</var> ))
1406 </pre></div>
1407
1408 <p>The arithmetic <var>expression</var> is evaluated according to the rules
1409 described below (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>).
1410 If the value of the expression is non-zero, the return status is 0;
1411 otherwise the return status is 1. This is exactly equivalent to
1412 </p><div class="example">
1413 <pre class="example">let &quot;<var>expression</var>&quot;
1414 </pre></div>
1415 <p>See <a href="#Bash-Builtins">Bash Builtins</a>, for a full description of the <code>let</code> builtin.
1416 </p>
1417 </dd>
1418 <dt><code>[[&hellip;]]</code></dt>
1419 <dd><a name="index-_005b_005b"></a>
1420 <a name="index-_005d_005d"></a>
1421 <div class="example">
1422 <pre class="example">[[ <var>expression</var> ]]
1423 </pre></div>
1424
1425 <p>Return a status of 0 or 1 depending on the evaluation of
1426 the conditional expression <var>expression</var>.
1427 Expressions are composed of the primaries described below in
1428 <a href="#Bash-Conditional-Expressions">Bash Conditional Expressions</a>.
1429 Word splitting and filename expansion are not performed on the words
1430 between the <code>[[</code> and <code>]]</code>; tilde expansion, parameter and
1431 variable expansion, arithmetic expansion, command substitution, process
1432 substitution, and quote removal are performed.
1433 Conditional operators such as &lsquo;<samp>-f</samp>&rsquo; must be unquoted to be recognized
1434 as primaries.
1435 </p>
1436 <p>When used with <code>[[</code>, the &lsquo;<samp>&lt;</samp>&rsquo; and &lsquo;<samp>&gt;</samp>&rsquo; operators sort
1437 lexicographically using the current locale.
1438 </p>
1439 <p>When the &lsquo;<samp>==</samp>&rsquo; and &lsquo;<samp>!=</samp>&rsquo; operators are used, the string to the
1440 right of the operator is considered a pattern and matched according
1441 to the rules described below in <a href="#Pattern-Matching">Pattern Matching</a>,
1442 as if the <code>extglob</code> shell option were enabled.
1443 The &lsquo;<samp>=</samp>&rsquo; operator is identical to &lsquo;<samp>==</samp>&rsquo;.
1444 If the <code>nocasematch</code> shell option
1445 (see the description of <code>shopt</code> in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>)
1446 is enabled, the match is performed without regard to the case
1447 of alphabetic characters.
1448 The return value is 0 if the string matches (&lsquo;<samp>==</samp>&rsquo;) or does not
1449 match (&lsquo;<samp>!=</samp>&rsquo;) the pattern, and 1 otherwise.
1450 Any part of the pattern may be quoted to force the quoted portion
1451 to be matched as a string.
1452 </p>
1453 <p>An additional binary operator, &lsquo;<samp>=~</samp>&rsquo;, is available, with the same
1454 precedence as &lsquo;<samp>==</samp>&rsquo; and &lsquo;<samp>!=</samp>&rsquo;.
1455 When it is used, the string to the right of the operator is considered
1456 a <small>POSIX</small> extended regular expression and matched accordingly
1457 (as in <i>regex</i>3)).
1458 The return value is 0 if the string matches
1459 the pattern, and 1 otherwise.
1460 If the regular expression is syntactically incorrect, the conditional
1461 expression&rsquo;s return value is 2.
1462 If the <code>nocasematch</code> shell option
1463 (see the description of <code>shopt</code> in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>)
1464 is enabled, the match is performed without regard to the case
1465 of alphabetic characters.
1466 Any part of the pattern may be quoted to force the quoted portion
1467 to be matched as a string.
1468 Bracket expressions in regular expressions must be treated carefully,
1469 since normal quoting characters lose their meanings between brackets.
1470 If the pattern is stored in a shell variable, quoting the variable
1471 expansion forces the entire pattern to be matched as a string.
1472 Substrings matched by parenthesized subexpressions within the regular
1473 expression are saved in the array variable <code>BASH_REMATCH</code>.
1474 The element of <code>BASH_REMATCH</code> with index 0 is the portion of the string
1475 matching the entire regular expression.
1476 The element of <code>BASH_REMATCH</code> with index <var>n</var> is the portion of the
1477 string matching the <var>n</var>th parenthesized subexpression.
1478 </p>
1479 <p>For example, the following will match a line
1480 (stored in the shell variable <var>line</var>)
1481 if there is a sequence of characters in the value consisting of
1482 any number, including zero, of
1483 space characters, zero or one instances of &lsquo;<samp>a</samp>&rsquo;, then a &lsquo;<samp>b</samp>&rsquo;:
1484 </p><div class="example">
1485 <pre class="example">[[ $line =~ [[:space:]]*?(a)b ]]
1486 </pre></div>
1487
1488 <p>That means values like &lsquo;<samp>aab</samp>&rsquo; and &lsquo;<samp> aaaaaab</samp>&rsquo; will match, as
1489 will a line containing a &lsquo;<samp>b</samp>&rsquo; anywhere in its value.
1490 </p>
1491 <p>Storing the regular expression in a shell variable is often a useful
1492 way to avoid problems with quoting characters that are special to the
1493 shell.
1494 It is sometimes difficult to specify a regular expression literally
1495 without using quotes, or to keep track of the quoting used by regular
1496 expressions while paying attention to the shell&rsquo;s quote removal.
1497 Using a shell variable to store the pattern decreases these problems.
1498 For example, the following is equivalent to the above:
1499 </p><div class="example">
1500 <pre class="example">pattern='[[:space:]]*?(a)b'
1501 [[ $line =~ $pattern ]]
1502 </pre></div>
1503
1504 <p>If you want to match a character that&rsquo;s special to the regular expression
1505 grammar, it has to be quoted to remove its special meaning.
1506 This means that in the pattern &lsquo;<samp>xxx.txt</samp>&rsquo;, the &lsquo;<samp>.</samp>&rsquo; matches any
1507 character in the string (its usual regular expression meaning), but in the
1508 pattern &lsquo;<samp>&quot;xxx.txt&quot;</samp>&rsquo; it can only match a literal &lsquo;<samp>.</samp>&rsquo;.
1509 Shell programmers should take special care with backslashes, since backslashes
1510 are used both by the shell and regular expressions to remove the special
1511 meaning from the following character.
1512 The following two sets of commands are <em>not</em> equivalent:
1513 </p><div class="example">
1514 <pre class="example">pattern='\.'
1515
1516 [[ . =~ $pattern ]]
1517 [[ . =~ \. ]]
1518
1519 [[ . =~ &quot;$pattern&quot; ]]
1520 [[ . =~ '\.' ]]
1521 </pre></div>
1522
1523 <p>The first two matches will succeed, but the second two will not, because
1524 in the second two the backslash will be part of the pattern to be matched.
1525 In the first two examples, the backslash removes the special meaning from
1526 &lsquo;<samp>.</samp>&rsquo;, so the literal &lsquo;<samp>.</samp>&rsquo; matches.
1527 If the string in the first examples were anything other than &lsquo;<samp>.</samp>&rsquo;, say
1528 &lsquo;<samp>a</samp>&rsquo;, the pattern would not match, because the quoted &lsquo;<samp>.</samp>&rsquo; in the
1529 pattern loses its special meaning of matching any single character.
1530 </p>
1531 <p>Expressions may be combined using the following operators, listed
1532 in decreasing order of precedence:
1533 </p>
1534 <dl compact="compact">
1535 <dt><code>( <var>expression</var> )</code></dt>
1536 <dd><p>Returns the value of <var>expression</var>.
1537 This may be used to override the normal precedence of operators.
1538 </p>
1539 </dd>
1540 <dt><code>! <var>expression</var></code></dt>
1541 <dd><p>True if <var>expression</var> is false.
1542 </p>
1543 </dd>
1544 <dt><code><var>expression1</var> &amp;&amp; <var>expression2</var></code></dt>
1545 <dd><p>True if both <var>expression1</var> and <var>expression2</var> are true.
1546 </p>
1547 </dd>
1548 <dt><code><var>expression1</var> || <var>expression2</var></code></dt>
1549 <dd><p>True if either <var>expression1</var> or <var>expression2</var> is true.
1550 </p></dd>
1551 </dl>
1552
1553 <p>The <code>&amp;&amp;</code> and <code>||</code> operators do not evaluate <var>expression2</var> if the
1554 value of <var>expression1</var> is sufficient to determine the return
1555 value of the entire conditional expression.
1556 </p></dd>
1557 </dl>
1558
1559 <hr>
1560 <a name="Command-Grouping"></a>
1561 <div class="header">
1562 <p>
1563 Previous: <a href="#Conditional-Constructs" accesskey="p" rel="prev">Conditional Constructs</a>, Up: <a href="#Compound-Commands" accesskey="u" rel="up">Compound Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
1564 </div>
1565 <a name="Grouping-Commands"></a>
1566 <h4 class="subsubsection">3.2.4.3 Grouping Commands</h4>
1567 <a name="index-commands_002c-grouping"></a>
1568
1569 <p>Bash provides two ways to group a list of commands to be executed
1570 as a unit. When commands are grouped, redirections may be applied
1571 to the entire command list. For example, the output of all the
1572 commands in the list may be redirected to a single stream.
1573 </p>
1574 <dl compact="compact">
1575 <dt><code>()</code></dt>
1576 <dd><div class="example">
1577 <pre class="example">( <var>list</var> )
1578 </pre></div>
1579
1580 <p>Placing a list of commands between parentheses causes a subshell
1581 environment to be created (see <a href="#Command-Execution-Environment">Command Execution Environment</a>), and each
1582 of the commands in <var>list</var> to be executed in that subshell. Since the
1583 <var>list</var> is executed in a subshell, variable assignments do not remain in
1584 effect after the subshell completes.
1585 </p>
1586 </dd>
1587 <dt><code>{}</code></dt>
1588 <dd><a name="index-_007b"></a>
1589 <a name="index-_007d"></a>
1590 <div class="example">
1591 <pre class="example">{ <var>list</var>; }
1592 </pre></div>
1593
1594 <p>Placing a list of commands between curly braces causes the list to
1595 be executed in the current shell context. No subshell is created.
1596 The semicolon (or newline) following <var>list</var> is required.
1597 </p></dd>
1598 </dl>
1599
1600 <p>In addition to the creation of a subshell, there is a subtle difference
1601 between these two constructs due to historical reasons. The braces
1602 are <code>reserved words</code>, so they must be separated from the <var>list</var>
1603 by <code>blank</code>s or other shell metacharacters.
1604 The parentheses are <code>operators</code>, and are
1605 recognized as separate tokens by the shell even if they are not separated
1606 from the <var>list</var> by whitespace.
1607 </p>
1608 <p>The exit status of both of these constructs is the exit status of
1609 <var>list</var>.
1610 </p>
1611 <hr>
1612 <a name="Coprocesses"></a>
1613 <div class="header">
1614 <p>
1615 Next: <a href="#GNU-Parallel" accesskey="n" rel="next">GNU Parallel</a>, Previous: <a href="#Compound-Commands" accesskey="p" rel="prev">Compound Commands</a>, Up: <a href="#Shell-Commands" accesskey="u" rel="up">Shell Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
1616 </div>
1617 <a name="Coprocesses-1"></a>
1618 <h4 class="subsection">3.2.5 Coprocesses</h4>
1619 <a name="index-coprocess"></a>
1620
1621 <p>A <code>coprocess</code> is a shell command preceded by the <code>coproc</code>
1622 reserved word.
1623 A coprocess is executed asynchronously in a subshell, as if the command
1624 had been terminated with the &lsquo;<samp>&amp;</samp>&rsquo; control operator, with a two-way pipe
1625 established between the executing shell and the coprocess.
1626 </p>
1627 <p>The format for a coprocess is:
1628 </p><div class="example">
1629 <pre class="example">coproc [<var>NAME</var>] <var>command</var> [<var>redirections</var>]
1630 </pre></div>
1631
1632 <p>This creates a coprocess named <var>NAME</var>.
1633 If <var>NAME</var> is not supplied, the default name is <var>COPROC</var>.
1634 <var>NAME</var> must not be supplied if <var>command</var> is a simple
1635 command (see <a href="#Simple-Commands">Simple Commands</a>); otherwise, it is interpreted as
1636 the first word of the simple command.
1637 </p>
1638 <p>When the coprocess is executed, the shell creates an array variable
1639 (see <a href="#Arrays">Arrays</a>)
1640 named <code>NAME</code> in the context of the executing shell.
1641 The standard output of <var>command</var>
1642 is connected via a pipe to a file descriptor in the executing shell,
1643 and that file descriptor is assigned to <code>NAME</code>[0].
1644 The standard input of <var>command</var>
1645 is connected via a pipe to a file descriptor in the executing shell,
1646 and that file descriptor is assigned to <code>NAME</code>[1].
1647 This pipe is established before any redirections specified by the
1648 command (see <a href="#Redirections">Redirections</a>).
1649 The file descriptors can be utilized as arguments to shell commands
1650 and redirections using standard word expansions.
1651 Other than those created to execute command and process substitutions,
1652 the file descriptors are not available in subshells.
1653 </p>
1654 <p>The process ID of the shell spawned to execute the coprocess is
1655 available as the value of the variable <code>NAME</code>_PID.
1656 The <code>wait</code>
1657 builtin command may be used to wait for the coprocess to terminate.
1658 </p>
1659 <p>Since the coprocess is created as an asynchronous command,
1660 the <code>coproc</code> command always returns success.
1661 The return status of a coprocess is the exit status of <var>command</var>.
1662 </p>
1663 <hr>
1664 <a name="GNU-Parallel"></a>
1665 <div class="header">
1666 <p>
1667 Previous: <a href="#Coprocesses" accesskey="p" rel="prev">Coprocesses</a>, Up: <a href="#Shell-Commands" accesskey="u" rel="up">Shell Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
1668 </div>
1669 <a name="GNU-Parallel-1"></a>
1670 <h4 class="subsection">3.2.6 GNU Parallel</h4>
1671
1672 <p>There are ways to run commands in parallel that are not built into Bash.
1673 GNU Parallel is a tool to do just that.
1674 </p>
1675 <p>GNU Parallel, as its name suggests, can be used to build and run commands
1676 in parallel. You may run the same command with different arguments, whether
1677 they are filenames, usernames, hostnames, or lines read from files. GNU
1678 Parallel provides shorthand references to many of the most common operations
1679 (input lines, various portions of the input line, different ways to specify
1680 the input source, and so on). Parallel can replace <code>xargs</code> or feed
1681 commands from its input sources to several different instances of Bash.
1682 </p>
1683 <p>For a complete description, refer to the GNU Parallel documentation. A few
1684 examples should provide a brief introduction to its use.
1685 </p>
1686 <p>For example, it is easy to replace <code>xargs</code> to gzip all html files in the
1687 current directory and its subdirectories:
1688 </p><div class="example">
1689 <pre class="example">find . -type f -name '*.html' -print | parallel gzip
1690 </pre></div>
1691 <p>If you need to protect special characters such as newlines in file names,
1692 use find&rsquo;s <samp>-print0</samp> option and parallel&rsquo;s <samp>-0</samp> option.
1693 </p>
1694 <p>You can use Parallel to move files from the current directory when the
1695 number of files is too large to process with one <code>mv</code> invocation:
1696 </p><div class="example">
1697 <pre class="example">ls | parallel mv {} destdir
1698 </pre></div>
1699
1700 <p>As you can see, the {} is replaced with each line read from standard input.
1701 While using <code>ls</code> will work in most instances, it is not sufficient to
1702 deal with all filenames.
1703 If you need to accommodate special characters in filenames, you can use
1704 </p>
1705 <div class="example">
1706 <pre class="example">find . -depth 1 \! -name '.*' -print0 | parallel -0 mv {} destdir
1707 </pre></div>
1708
1709 <p>as alluded to above.
1710 </p>
1711 <p>This will run as many <code>mv</code> commands as there are files in the current
1712 directory.
1713 You can emulate a parallel <code>xargs</code> by adding the <samp>-X</samp> option:
1714 </p><div class="example">
1715 <pre class="example">find . -depth 1 \! -name '.*' -print0 | parallel -0 -X mv {} destdir
1716 </pre></div>
1717
1718 <p>GNU Parallel can replace certain common idioms that operate on lines read
1719 from a file (in this case, filenames listed one per line):
1720 </p><div class="example">
1721 <pre class="example"> while IFS= read -r x; do
1722 do-something1 &quot;$x&quot; &quot;config-$x&quot;
1723 do-something2 &lt; &quot;$x&quot;
1724 done &lt; file | process-output
1725 </pre></div>
1726
1727 <p>with a more compact syntax reminiscent of lambdas:
1728 </p><div class="example">
1729 <pre class="example">cat list | parallel &quot;do-something1 {} config-{} ; do-something2 &lt; {}&quot; |
1730 process-output
1731 </pre></div>
1732
1733 <p>Parallel provides a built-in mechanism to remove filename extensions, which
1734 lends itself to batch file transformations or renaming:
1735 </p><div class="example">
1736 <pre class="example">ls *.gz | parallel -j+0 &quot;zcat {} | bzip2 &gt;{.}.bz2 &amp;&amp; rm {}&quot;
1737 </pre></div>
1738 <p>This will recompress all files in the current directory with names ending
1739 in .gz using bzip2, running one job per CPU (-j+0) in parallel.
1740 (We use <code>ls</code> for brevity here; using <code>find</code> as above is more
1741 robust in the face of filenames containing unexpected characters.)
1742 Parallel can take arguments from the command line; the above can also be
1743 written as
1744 </p>
1745 <div class="example">
1746 <pre class="example">parallel &quot;zcat {} | bzip2 &gt;{.}.bz2 &amp;&amp; rm {}&quot; ::: *.gz
1747 </pre></div>
1748
1749 <p>If a command generates output, you may want to preserve the input order in
1750 the output. For instance, the following command
1751 </p><div class="example">
1752 <pre class="example">{
1753 echo foss.org.my ;
1754 echo debian.org ;
1755 echo freenetproject.org ;
1756 } | parallel traceroute
1757 </pre></div>
1758 <p>will display as output the traceroute invocation that finishes first.
1759 Adding the <samp>-k</samp> option
1760 </p><div class="example">
1761 <pre class="example">{
1762 echo foss.org.my ;
1763 echo debian.org ;
1764 echo freenetproject.org ;
1765 } | parallel -k traceroute
1766 </pre></div>
1767 <p>will ensure that the output of <code>traceroute foss.org.my</code> is displayed first.
1768 </p>
1769 <p>Finally, Parallel can be used to run a sequence of shell commands in parallel,
1770 similar to &lsquo;<samp>cat file | bash</samp>&rsquo;.
1771 It is not uncommon to take a list of filenames, create a series of shell
1772 commands to operate on them, and feed that list of commands to a shell.
1773 Parallel can speed this up. Assuming that <samp>file</samp> contains a list of
1774 shell commands, one per line,
1775 </p>
1776 <div class="example">
1777 <pre class="example">parallel -j 10 &lt; file
1778 </pre></div>
1779
1780 <p>will evaluate the commands using the shell (since no explicit command is
1781 supplied as an argument), in blocks of ten shell jobs at a time.
1782 </p>
1783 <hr>
1784 <a name="Shell-Functions"></a>
1785 <div class="header">
1786 <p>
1787 Next: <a href="#Shell-Parameters" accesskey="n" rel="next">Shell Parameters</a>, Previous: <a href="#Shell-Commands" accesskey="p" rel="prev">Shell Commands</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
1788 </div>
1789 <a name="Shell-Functions-1"></a>
1790 <h3 class="section">3.3 Shell Functions</h3>
1791 <a name="index-shell-function"></a>
1792 <a name="index-functions_002c-shell"></a>
1793
1794 <p>Shell functions are a way to group commands for later execution
1795 using a single name for the group. They are executed just like
1796 a &quot;regular&quot; command.
1797 When the name of a shell function is used as a simple command name,
1798 the list of commands associated with that function name is executed.
1799 Shell functions are executed in the current
1800 shell context; no new process is created to interpret them.
1801 </p>
1802 <p>Functions are declared using this syntax:
1803 <a name="index-function"></a>
1804 </p><div class="example">
1805 <pre class="example"><var>name</var> () <var>compound-command</var> [ <var>redirections</var> ]
1806 </pre></div>
1807
1808 <p>or
1809 </p>
1810 <div class="example">
1811 <pre class="example">function <var>name</var> [()] <var>compound-command</var> [ <var>redirections</var> ]
1812 </pre></div>
1813
1814 <p>This defines a shell function named <var>name</var>. The reserved
1815 word <code>function</code> is optional.
1816 If the <code>function</code> reserved
1817 word is supplied, the parentheses are optional.
1818 The <var>body</var> of the function is the compound command
1819 <var>compound-command</var> (see <a href="#Compound-Commands">Compound Commands</a>).
1820 That command is usually a <var>list</var> enclosed between { and }, but
1821 may be any compound command listed above,
1822 with one exception: If the <code>function</code> reserved word is used, but the
1823 parentheses are not supplied, the braces are required.
1824 <var>compound-command</var> is executed whenever <var>name</var> is specified as the
1825 name of a command.
1826 When the shell is in <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>),
1827 <var>name</var> may not be the same as one of the special builtins
1828 (see <a href="#Special-Builtins">Special Builtins</a>).
1829 Any redirections (see <a href="#Redirections">Redirections</a>) associated with the shell function
1830 are performed when the function is executed.
1831 </p>
1832 <p>A function definition may be deleted using the <samp>-f</samp> option to the
1833 <code>unset</code> builtin (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
1834 </p>
1835 <p>The exit status of a function definition is zero unless a syntax error
1836 occurs or a readonly function with the same name already exists.
1837 When executed, the exit status of a function is the exit status of the
1838 last command executed in the body.
1839 </p>
1840 <p>Note that for historical reasons, in the most common usage the curly braces
1841 that surround the body of the function must be separated from the body by
1842 <code>blank</code>s or newlines.
1843 This is because the braces are reserved words and are only recognized
1844 as such when they are separated from the command list
1845 by whitespace or another shell metacharacter.
1846 Also, when using the braces, the <var>list</var> must be terminated by a semicolon,
1847 a &lsquo;<samp>&amp;</samp>&rsquo;, or a newline.
1848 </p>
1849 <p>When a function is executed, the arguments to the
1850 function become the positional parameters
1851 during its execution (see <a href="#Positional-Parameters">Positional Parameters</a>).
1852 The special parameter &lsquo;<samp>#</samp>&rsquo; that expands to the number of
1853 positional parameters is updated to reflect the change.
1854 Special parameter <code>0</code> is unchanged.
1855 The first element of the <code>FUNCNAME</code> variable is set to the
1856 name of the function while the function is executing.
1857 </p>
1858 <p>All other aspects of the shell execution
1859 environment are identical between a function and its caller
1860 with these exceptions:
1861 the <code>DEBUG</code> and <code>RETURN</code> traps
1862 are not inherited unless the function has been given the
1863 <code>trace</code> attribute using the <code>declare</code> builtin or
1864 the <code>-o functrace</code> option has been enabled with
1865 the <code>set</code> builtin,
1866 (in which case all functions inherit the <code>DEBUG</code> and <code>RETURN</code> traps),
1867 and the <code>ERR</code> trap is not inherited unless the <code>-o errtrace</code>
1868 shell option has been enabled.
1869 See <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>, for the description of the
1870 <code>trap</code> builtin.
1871 </p>
1872 <p>The <code>FUNCNEST</code> variable, if set to a numeric value greater
1873 than 0, defines a maximum function nesting level. Function
1874 invocations that exceed the limit cause the entire command to
1875 abort.
1876 </p>
1877 <p>If the builtin command <code>return</code>
1878 is executed in a function, the function completes and
1879 execution resumes with the next command after the function
1880 call.
1881 Any command associated with the <code>RETURN</code> trap is executed
1882 before execution resumes.
1883 When a function completes, the values of the
1884 positional parameters and the special parameter &lsquo;<samp>#</samp>&rsquo;
1885 are restored to the values they had prior to the function&rsquo;s
1886 execution. If a numeric argument is given to <code>return</code>,
1887 that is the function&rsquo;s return status; otherwise the function&rsquo;s
1888 return status is the exit status of the last command executed
1889 before the <code>return</code>.
1890 </p>
1891 <p>Variables local to the function may be declared with the
1892 <code>local</code> builtin. These variables are visible only to
1893 the function and the commands it invokes. This is particularly
1894 important when a shell function calls other functions.
1895 </p>
1896 <p>Local variables &quot;shadow&quot; variables with the same name declared at
1897 previous scopes. For instance, a local variable declared in a function
1898 hides a global variable of the same name: references and assignments
1899 refer to the local variable, leaving the global variable unmodified.
1900 When the function returns, the global variable is once again visible.
1901 </p>
1902 <p>The shell uses <var>dynamic scoping</var> to control a variable&rsquo;s visibility
1903 within functions.
1904 With dynamic scoping, visible variables and their values
1905 are a result of the sequence of function calls that caused execution
1906 to reach the current function.
1907 The value of a variable that a function sees depends
1908 on its value within its caller, if any, whether that caller is
1909 the &quot;global&quot; scope or another shell function.
1910 This is also the value that a local variable
1911 declaration &quot;shadows&quot;, and the value that is restored when the function
1912 returns.
1913 </p>
1914 <p>For example, if a variable <var>var</var> is declared as local in function
1915 <var>func1</var>, and <var>func1</var> calls another function <var>func2</var>,
1916 references to <var>var</var> made from within <var>func2</var> will resolve to the
1917 local variable <var>var</var> from <var>func1</var>, shadowing any global variable
1918 named <var>var</var>.
1919 </p>
1920 <p>The following script demonstrates this behavior.
1921 When executed, the script displays
1922 </p>
1923 <div class="example">
1924 <pre class="example">In func2, var = func1 local
1925 </pre></div>
1926
1927 <div class="example">
1928 <pre class="example">func1()
1929 {
1930 local var='func1 local'
1931 func2
1932 }
1933
1934 func2()
1935 {
1936 echo &quot;In func2, var = $var&quot;
1937 }
1938
1939 var=global
1940 func1
1941 </pre></div>
1942
1943 <p>The <code>unset</code> builtin also acts using the same dynamic scope: if a
1944 variable is local to the current scope, <code>unset</code> will unset it;
1945 otherwise the unset will refer to the variable found in any calling scope
1946 as described above.
1947 If a variable at the current local scope is unset, it will remain so
1948 until it is reset in that scope or until the function returns.
1949 Once the function returns, any instance of the variable at a previous
1950 scope will become visible.
1951 If the unset acts on a variable at a previous scope, any instance of a
1952 variable with that name that had been shadowed will become visible.
1953 </p>
1954 <p>Function names and definitions may be listed with the
1955 <samp>-f</samp> option to the <code>declare</code> (<code>typeset</code>)
1956 builtin command (see <a href="#Bash-Builtins">Bash Builtins</a>).
1957 The <samp>-F</samp> option to <code>declare</code> or <code>typeset</code>
1958 will list the function names only
1959 (and optionally the source file and line number, if the <code>extdebug</code>
1960 shell option is enabled).
1961 Functions may be exported so that subshells
1962 automatically have them defined with the
1963 <samp>-f</samp> option to the <code>export</code> builtin
1964 (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
1965 </p>
1966 <p>Functions may be recursive.
1967 The <code>FUNCNEST</code> variable may be used to limit the depth of the
1968 function call stack and restrict the number of function invocations.
1969 By default, no limit is placed on the number of recursive calls.
1970 </p>
1971 <hr>
1972 <a name="Shell-Parameters"></a>
1973 <div class="header">
1974 <p>
1975 Next: <a href="#Shell-Expansions" accesskey="n" rel="next">Shell Expansions</a>, Previous: <a href="#Shell-Functions" accesskey="p" rel="prev">Shell Functions</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
1976 </div>
1977 <a name="Shell-Parameters-1"></a>
1978 <h3 class="section">3.4 Shell Parameters</h3>
1979 <a name="index-parameters"></a>
1980 <a name="index-variable_002c-shell"></a>
1981 <a name="index-shell-variable"></a>
1982
1983 <table class="menu" border="0" cellspacing="0">
1984 <tr><td align="left" valign="top">&bull; <a href="#Positional-Parameters" accesskey="1">Positional Parameters</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The shell&rsquo;s command-line arguments.
1985 </td></tr>
1986 <tr><td align="left" valign="top">&bull; <a href="#Special-Parameters" accesskey="2">Special Parameters</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Parameters denoted by special characters.
1987 </td></tr>
1988 </table>
1989
1990 <p>A <var>parameter</var> is an entity that stores values.
1991 It can be a <code>name</code>, a number, or one of the special characters
1992 listed below.
1993 A <var>variable</var> is a parameter denoted by a <code>name</code>.
1994 A variable has a <var>value</var> and zero or more <var>attributes</var>.
1995 Attributes are assigned using the <code>declare</code> builtin command
1996 (see the description of the <code>declare</code> builtin in <a href="#Bash-Builtins">Bash Builtins</a>).
1997 </p>
1998 <p>A parameter is set if it has been assigned a value. The null string is
1999 a valid value. Once a variable is set, it may be unset only by using
2000 the <code>unset</code> builtin command.
2001 </p>
2002 <p>A variable may be assigned to by a statement of the form
2003 </p><div class="example">
2004 <pre class="example"><var>name</var>=[<var>value</var>]
2005 </pre></div>
2006 <p>If <var>value</var>
2007 is not given, the variable is assigned the null string. All
2008 <var>value</var>s undergo tilde expansion, parameter and variable expansion,
2009 command substitution, arithmetic expansion, and quote
2010 removal (detailed below). If the variable has its <code>integer</code>
2011 attribute set, then <var>value</var>
2012 is evaluated as an arithmetic expression even if the <code>$((&hellip;))</code>
2013 expansion is not used (see <a href="#Arithmetic-Expansion">Arithmetic Expansion</a>).
2014 Word splitting is not performed, with the exception
2015 of <code>&quot;$@&quot;</code> as explained below.
2016 Filename expansion is not performed.
2017 Assignment statements may also appear as arguments to the
2018 <code>alias</code>,
2019 <code>declare</code>, <code>typeset</code>, <code>export</code>, <code>readonly</code>,
2020 and <code>local</code> builtin commands (<var>declaration</var> commands).
2021 When in <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>), these builtins may appear
2022 in a command after one or more instances of the <code>command</code> builtin
2023 and retain these assignment statement properties.
2024 </p>
2025 <p>In the context where an assignment statement is assigning a value
2026 to a shell variable or array index (see <a href="#Arrays">Arrays</a>), the &lsquo;<samp>+=</samp>&rsquo;
2027 operator can be used to
2028 append to or add to the variable&rsquo;s previous value.
2029 This includes arguments to builtin commands such as <code>declare</code> that
2030 accept assignment statements (<var>declaration</var> commands).
2031 When &lsquo;<samp>+=</samp>&rsquo; is applied to a variable for which the <var>integer</var> attribute
2032 has been set, <var>value</var> is evaluated as an arithmetic expression and
2033 added to the variable&rsquo;s current value, which is also evaluated.
2034 When &lsquo;<samp>+=</samp>&rsquo; is applied to an array variable using compound assignment
2035 (see <a href="#Arrays">Arrays</a>), the
2036 variable&rsquo;s value is not unset (as it is when using &lsquo;<samp>=</samp>&rsquo;), and new
2037 values are appended to the array beginning at one greater than the array&rsquo;s
2038 maximum index (for indexed arrays), or added as additional key-value pairs
2039 in an associative array.
2040 When applied to a string-valued variable, <var>value</var> is expanded and
2041 appended to the variable&rsquo;s value.
2042 </p>
2043 <p>A variable can be assigned the <var>nameref</var> attribute using the
2044 <samp>-n</samp> option to the <code>declare</code> or <code>local</code> builtin commands
2045 (see <a href="#Bash-Builtins">Bash Builtins</a>)
2046 to create a <var>nameref</var>, or a reference to another variable.
2047 This allows variables to be manipulated indirectly.
2048 Whenever the nameref variable is referenced, assigned to, unset, or has
2049 its attributes modified (other than using or changing the nameref
2050 attribute itself), the
2051 operation is actually performed on the variable specified by the nameref
2052 variable&rsquo;s value.
2053 A nameref is commonly used within shell functions to refer to a variable
2054 whose name is passed as an argument to the function.
2055 For instance, if a variable name is passed to a shell function as its first
2056 argument, running
2057 </p><div class="example">
2058 <pre class="example">declare -n ref=$1
2059 </pre></div>
2060 <p>inside the function creates a nameref variable <var>ref</var> whose value is
2061 the variable name passed as the first argument.
2062 References and assignments to <var>ref</var>, and changes to its attributes,
2063 are treated as references, assignments, and attribute modifications
2064 to the variable whose name was passed as <code>$1</code>.
2065 </p>
2066 <p>If the control variable in a <code>for</code> loop has the nameref attribute,
2067 the list of words can be a list of shell variables, and a name reference
2068 will be established for each word in the list, in turn, when the loop is
2069 executed.
2070 Array variables cannot be given the nameref attribute.
2071 However, nameref variables can reference array variables and subscripted
2072 array variables.
2073 Namerefs can be unset using the <samp>-n</samp> option to the <code>unset</code> builtin
2074 (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
2075 Otherwise, if <code>unset</code> is executed with the name of a nameref variable
2076 as an argument, the variable referenced by the nameref variable will be unset.
2077 </p>
2078 <hr>
2079 <a name="Positional-Parameters"></a>
2080 <div class="header">
2081 <p>
2082 Next: <a href="#Special-Parameters" accesskey="n" rel="next">Special Parameters</a>, Up: <a href="#Shell-Parameters" accesskey="u" rel="up">Shell Parameters</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
2083 </div>
2084 <a name="Positional-Parameters-1"></a>
2085 <h4 class="subsection">3.4.1 Positional Parameters</h4>
2086 <a name="index-parameters_002c-positional"></a>
2087
2088 <p>A <var>positional parameter</var> is a parameter denoted by one or more
2089 digits, other than the single digit <code>0</code>. Positional parameters are
2090 assigned from the shell&rsquo;s arguments when it is invoked,
2091 and may be reassigned using the <code>set</code> builtin command.
2092 Positional parameter <code>N</code> may be referenced as <code>${N}</code>, or
2093 as <code>$N</code> when <code>N</code> consists of a single digit.
2094 Positional parameters may not be assigned to with assignment statements.
2095 The <code>set</code> and <code>shift</code> builtins are used to set and
2096 unset them (see <a href="#Shell-Builtin-Commands">Shell Builtin Commands</a>).
2097 The positional parameters are
2098 temporarily replaced when a shell function is executed
2099 (see <a href="#Shell-Functions">Shell Functions</a>).
2100 </p>
2101 <p>When a positional parameter consisting of more than a single
2102 digit is expanded, it must be enclosed in braces.
2103 </p>
2104 <hr>
2105 <a name="Special-Parameters"></a>
2106 <div class="header">
2107 <p>
2108 Previous: <a href="#Positional-Parameters" accesskey="p" rel="prev">Positional Parameters</a>, Up: <a href="#Shell-Parameters" accesskey="u" rel="up">Shell Parameters</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
2109 </div>
2110 <a name="Special-Parameters-1"></a>
2111 <h4 class="subsection">3.4.2 Special Parameters</h4>
2112 <a name="index-parameters_002c-special"></a>
2113
2114 <p>The shell treats several parameters specially. These parameters may
2115 only be referenced; assignment to them is not allowed.
2116 </p>
2117 <dl compact="compact">
2118 <dt><code>*</code>
2119 <a name="index-_002a"></a>
2120 </dt>
2121 <dd><a name="index-_0024_002a"></a>
2122 <p>($*) Expands to the positional parameters, starting from one.
2123 When the expansion is not within double quotes, each positional parameter
2124 expands to a separate word.
2125 In contexts where it is performed, those words
2126 are subject to further word splitting and pathname expansion.
2127 When the expansion occurs within double quotes, it expands to a single word
2128 with the value of each parameter separated by the first character of the
2129 <code>IFS</code> special variable. That is, <code>&quot;$*&quot;</code> is equivalent
2130 to <code>&quot;$1<var>c</var>$2<var>c</var>&hellip;&quot;</code>, where <var>c</var>
2131 is the first character of the value of the <code>IFS</code>
2132 variable.
2133 If <code>IFS</code> is unset, the parameters are separated by spaces.
2134 If <code>IFS</code> is null, the parameters are joined without intervening
2135 separators.
2136 </p>
2137 </dd>
2138 <dt><code>@</code>
2139 <a name="index-_0040"></a>
2140 </dt>
2141 <dd><a name="index-_0024_0040"></a>
2142 <p>($@) Expands to the positional parameters, starting from one.
2143 In contexts where word splitting is performed, this expands each
2144 positional parameter to a separate word; if not within double
2145 quotes, these words are subject to word splitting.
2146 In contexts where word splitting is not performed,
2147 this expands to a single word
2148 with each positional parameter separated by a space.
2149 When the
2150 expansion occurs within double quotes, and word splitting is performed,
2151 each parameter expands to a
2152 separate word. That is, <code>&quot;$@&quot;</code> is equivalent to
2153 <code>&quot;$1&quot; &quot;$2&quot; &hellip;</code>.
2154 If the double-quoted expansion occurs within a word, the expansion of
2155 the first parameter is joined with the beginning part of the original
2156 word, and the expansion of the last parameter is joined with the last
2157 part of the original word.
2158 When there are no positional parameters, <code>&quot;$@&quot;</code> and
2159 <code>$@</code>
2160 expand to nothing (i.e., they are removed).
2161 </p>
2162 </dd>
2163 <dt><code>#</code>
2164 <a name="index-_0023"></a>
2165 </dt>
2166 <dd><a name="index-_0024_0023"></a>
2167 <p>($#) Expands to the number of positional parameters in decimal.
2168 </p>
2169 </dd>
2170 <dt><code>?</code>
2171 <a name="index-_003f"></a>
2172 </dt>
2173 <dd><a name="index-_0024_003f"></a>
2174 <p>($?) Expands to the exit status of the most recently executed foreground
2175 pipeline.
2176 </p>
2177 </dd>
2178 <dt><code>-</code>
2179 <a name="index-_002d"></a>
2180 </dt>
2181 <dd><a name="index-_0024_002d"></a>
2182 <p>($-, a hyphen.) Expands to the current option flags as specified upon
2183 invocation, by the <code>set</code>
2184 builtin command, or those set by the shell itself
2185 (such as the <samp>-i</samp> option).
2186 </p>
2187 </dd>
2188 <dt><code>$</code>
2189 <a name="index-_0024"></a>
2190 </dt>
2191 <dd><a name="index-_0024_0024"></a>
2192 <p>($$) Expands to the process <small>ID</small> of the shell. In a <code>()</code> subshell, it
2193 expands to the process <small>ID</small> of the invoking shell, not the subshell.
2194 </p>
2195 </dd>
2196 <dt><code>!</code>
2197 <a name="index-_0021-1"></a>
2198 </dt>
2199 <dd><a name="index-_0024_0021"></a>
2200 <p>($!) Expands to the process <small>ID</small> of the job most recently placed into the
2201 background, whether executed as an asynchronous command or using
2202 the <code>bg</code> builtin (see <a href="#Job-Control-Builtins">Job Control Builtins</a>).
2203 </p>
2204 </dd>
2205 <dt><code>0</code>
2206 <a name="index-0"></a>
2207 </dt>
2208 <dd><a name="index-_00240"></a>
2209 <p>($0) Expands to the name of the shell or shell script. This is set at
2210 shell initialization. If Bash is invoked with a file of commands
2211 (see <a href="#Shell-Scripts">Shell Scripts</a>), <code>$0</code> is set to the name of that file.
2212 If Bash is started with the <samp>-c</samp> option (see <a href="#Invoking-Bash">Invoking Bash</a>),
2213 then <code>$0</code> is set to the first argument after the string to be
2214 executed, if one is present. Otherwise, it is set
2215 to the filename used to invoke Bash, as given by argument zero.
2216 </p>
2217 </dd>
2218 <dt><code>_</code>
2219 <a name="index-_005f"></a>
2220 </dt>
2221 <dd><a name="index-_0024_005f"></a>
2222 <p>($_, an underscore.)
2223 At shell startup, set to the absolute pathname used to invoke the
2224 shell or shell script being executed as passed in the environment
2225 or argument list.
2226 Subsequently, expands to the last argument to the previous simple
2227 command executed in the foreground, after expansion.
2228 Also set to the full pathname used to invoke each command executed
2229 and placed in the environment exported to that command.
2230 When checking mail, this parameter holds the name of the mail file.
2231 </p></dd>
2232 </dl>
2233
2234 <hr>
2235 <a name="Shell-Expansions"></a>
2236 <div class="header">
2237 <p>
2238 Next: <a href="#Redirections" accesskey="n" rel="next">Redirections</a>, Previous: <a href="#Shell-Parameters" accesskey="p" rel="prev">Shell Parameters</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
2239 </div>
2240 <a name="Shell-Expansions-1"></a>
2241 <h3 class="section">3.5 Shell Expansions</h3>
2242 <a name="index-expansion"></a>
2243
2244 <p>Expansion is performed on the command line after it has been split into
2245 <code>token</code>s. There are seven kinds of expansion performed:
2246 </p>
2247 <ul>
2248 <li> brace expansion
2249 </li><li> tilde expansion
2250 </li><li> parameter and variable expansion
2251 </li><li> command substitution
2252 </li><li> arithmetic expansion
2253 </li><li> word splitting
2254 </li><li> filename expansion
2255 </li></ul>
2256
2257 <table class="menu" border="0" cellspacing="0">
2258 <tr><td align="left" valign="top">&bull; <a href="#Brace-Expansion" accesskey="1">Brace Expansion</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Expansion of expressions within braces.
2259 </td></tr>
2260 <tr><td align="left" valign="top">&bull; <a href="#Tilde-Expansion" accesskey="2">Tilde Expansion</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Expansion of the ~ character.
2261 </td></tr>
2262 <tr><td align="left" valign="top">&bull; <a href="#Shell-Parameter-Expansion" accesskey="3">Shell Parameter Expansion</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How Bash expands variables to their values.
2263 </td></tr>
2264 <tr><td align="left" valign="top">&bull; <a href="#Command-Substitution" accesskey="4">Command Substitution</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Using the output of a command as an argument.
2265 </td></tr>
2266 <tr><td align="left" valign="top">&bull; <a href="#Arithmetic-Expansion" accesskey="5">Arithmetic Expansion</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to use arithmetic in shell expansions.
2267 </td></tr>
2268 <tr><td align="left" valign="top">&bull; <a href="#Process-Substitution" accesskey="6">Process Substitution</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A way to write and read to and from a
2269 command.
2270 </td></tr>
2271 <tr><td align="left" valign="top">&bull; <a href="#Word-Splitting" accesskey="7">Word Splitting</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How the results of expansion are split into separate
2272 arguments.
2273 </td></tr>
2274 <tr><td align="left" valign="top">&bull; <a href="#Filename-Expansion" accesskey="8">Filename Expansion</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A shorthand for specifying filenames matching patterns.
2275 </td></tr>
2276 <tr><td align="left" valign="top">&bull; <a href="#Quote-Removal" accesskey="9">Quote Removal</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How and when quote characters are removed from
2277 words.
2278 </td></tr>
2279 </table>
2280
2281 <p>The order of expansions is:
2282 brace expansion;
2283 tilde expansion, parameter and variable expansion, arithmetic expansion,
2284 and command substitution (done in a left-to-right fashion);
2285 word splitting;
2286 and filename expansion.
2287 </p>
2288 <p>On systems that can support it, there is an additional expansion
2289 available: <var>process substitution</var>.
2290 This is performed at the
2291 same time as tilde, parameter, variable, and arithmetic expansion and
2292 command substitution.
2293 </p>
2294 <p>After these expansions are performed, quote characters present in the
2295 original word are removed unless they have been quoted themselves
2296 (<var>quote removal</var>).
2297 </p>
2298 <p>Only brace expansion, word splitting, and filename expansion
2299 can increase the number of words of the expansion; other expansions
2300 expand a single word to a single word.
2301 The only exceptions to this are the expansions of
2302 <code>&quot;$@&quot;</code> and <code>$*</code> (see <a href="#Special-Parameters">Special Parameters</a>), and
2303 <code>&quot;${<var>name</var>[@]}&quot;</code> and <code>${<var>name</var>[*]}</code>
2304 (see <a href="#Arrays">Arrays</a>).
2305 </p>
2306 <p>After all expansions, <code>quote removal</code> (see <a href="#Quote-Removal">Quote Removal</a>)
2307 is performed.
2308 </p>
2309 <hr>
2310 <a name="Brace-Expansion"></a>
2311 <div class="header">
2312 <p>
2313 Next: <a href="#Tilde-Expansion" accesskey="n" rel="next">Tilde Expansion</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
2314 </div>
2315 <a name="Brace-Expansion-1"></a>
2316 <h4 class="subsection">3.5.1 Brace Expansion</h4>
2317 <a name="index-brace-expansion"></a>
2318 <a name="index-expansion_002c-brace"></a>
2319
2320 <p>Brace expansion is a mechanism by which arbitrary strings may be generated.
2321 This mechanism is similar to
2322 <var>filename expansion</var> (see <a href="#Filename-Expansion">Filename Expansion</a>),
2323 but the filenames generated need not exist.
2324 Patterns to be brace expanded take the form of an optional <var>preamble</var>,
2325 followed by either a series of comma-separated strings or a sequence expression
2326 between a pair of braces,
2327 followed by an optional <var>postscript</var>.
2328 The preamble is prefixed to each string contained within the braces, and
2329 the postscript is then appended to each resulting string, expanding left
2330 to right.
2331 </p>
2332 <p>Brace expansions may be nested.
2333 The results of each expanded string are not sorted; left to right order
2334 is preserved.
2335 For example,
2336 </p><div class="example">
2337 <pre class="example">bash$ echo a{d,c,b}e
2338 ade ace abe
2339 </pre></div>
2340
2341 <p>A sequence expression takes the form <code>{<var>x</var>..<var>y</var>[..<var>incr</var>]}</code>,
2342 where <var>x</var> and <var>y</var> are either integers or single characters,
2343 and <var>incr</var>, an optional increment, is an integer.
2344 When integers are supplied, the expression expands to each number between
2345 <var>x</var> and <var>y</var>, inclusive.
2346 Supplied integers may be prefixed with &lsquo;<samp>0</samp>&rsquo; to force each term to have the
2347 same width.
2348 When either <var>x</var> or <var>y</var> begins with a zero, the shell
2349 attempts to force all generated terms to contain the same number of digits,
2350 zero-padding where necessary.
2351 When characters are supplied, the expression expands to each character
2352 lexicographically between <var>x</var> and <var>y</var>, inclusive,
2353 using the default C locale.
2354 Note that both <var>x</var> and <var>y</var> must be of the same type.
2355 When the increment is supplied, it is used as the difference between
2356 each term. The default increment is 1 or -1 as appropriate.
2357 </p>
2358 <p>Brace expansion is performed before any other expansions,
2359 and any characters special to other expansions are preserved
2360 in the result. It is strictly textual. Bash
2361 does not apply any syntactic interpretation to the context of the
2362 expansion or the text between the braces.
2363 </p>
2364 <p>A correctly-formed brace expansion must contain unquoted opening
2365 and closing braces, and at least one unquoted comma or a valid
2366 sequence expression.
2367 Any incorrectly formed brace expansion is left unchanged.
2368 </p>
2369 <p>A { or &lsquo;<samp>,</samp>&rsquo; may be quoted with a backslash to prevent its
2370 being considered part of a brace expression.
2371 To avoid conflicts with parameter expansion, the string &lsquo;<samp>${</samp>&rsquo;
2372 is not considered eligible for brace expansion,
2373 and inhibits brace expansion until the closing &lsquo;<samp>}</samp>&rsquo;..
2374 </p>
2375 <p>This construct is typically used as shorthand when the common
2376 prefix of the strings to be generated is longer than in the
2377 above example:
2378 </p><div class="example">
2379 <pre class="example">mkdir /usr/local/src/bash/{old,new,dist,bugs}
2380 </pre></div>
2381 <p>or
2382 </p><div class="example">
2383 <pre class="example">chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
2384 </pre></div>
2385
2386 <hr>
2387 <a name="Tilde-Expansion"></a>
2388 <div class="header">
2389 <p>
2390 Next: <a href="#Shell-Parameter-Expansion" accesskey="n" rel="next">Shell Parameter Expansion</a>, Previous: <a href="#Brace-Expansion" accesskey="p" rel="prev">Brace Expansion</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
2391 </div>
2392 <a name="Tilde-Expansion-1"></a>
2393 <h4 class="subsection">3.5.2 Tilde Expansion</h4>
2394 <a name="index-tilde-expansion"></a>
2395 <a name="index-expansion_002c-tilde"></a>
2396
2397 <p>If a word begins with an unquoted tilde character (&lsquo;<samp>~</samp>&rsquo;), all of the
2398 characters up to the first unquoted slash (or all characters,
2399 if there is no unquoted slash) are considered a <var>tilde-prefix</var>.
2400 If none of the characters in the tilde-prefix are quoted, the
2401 characters in the tilde-prefix following the tilde are treated as a
2402 possible <var>login name</var>.
2403 If this login name is the null string, the tilde is replaced with the
2404 value of the <code>HOME</code> shell variable.
2405 If <code>HOME</code> is unset, the home directory of the user executing the
2406 shell is substituted instead.
2407 Otherwise, the tilde-prefix is replaced with the home directory
2408 associated with the specified login name.
2409 </p>
2410 <p>If the tilde-prefix is &lsquo;<samp>~+</samp>&rsquo;, the value of
2411 the shell variable <code>PWD</code> replaces the tilde-prefix.
2412 If the tilde-prefix is &lsquo;<samp>~-</samp>&rsquo;, the value of the shell variable
2413 <code>OLDPWD</code>, if it is set, is substituted.
2414 </p>
2415 <p>If the characters following the tilde in the tilde-prefix consist of a
2416 number <var>N</var>, optionally prefixed by a &lsquo;<samp>+</samp>&rsquo; or a &lsquo;<samp>-</samp>&rsquo;,
2417 the tilde-prefix is replaced with the
2418 corresponding element from the directory stack, as it would be displayed
2419 by the <code>dirs</code> builtin invoked with the characters following tilde
2420 in the tilde-prefix as an argument (see <a href="#The-Directory-Stack">The Directory Stack</a>).
2421 If the tilde-prefix, sans the tilde, consists of a number without a
2422 leading &lsquo;<samp>+</samp>&rsquo; or &lsquo;<samp>-</samp>&rsquo;, &lsquo;<samp>+</samp>&rsquo; is assumed.
2423 </p>
2424 <p>If the login name is invalid, or the tilde expansion fails, the word is
2425 left unchanged.
2426 </p>
2427 <p>Each variable assignment is checked for unquoted tilde-prefixes immediately
2428 following a &lsquo;<samp>:</samp>&rsquo; or the first &lsquo;<samp>=</samp>&rsquo;.
2429 In these cases, tilde expansion is also performed.
2430 Consequently, one may use filenames with tildes in assignments to
2431 <code>PATH</code>, <code>MAILPATH</code>, and <code>CDPATH</code>,
2432 and the shell assigns the expanded value.
2433 </p>
2434 <p>The following table shows how Bash treats unquoted tilde-prefixes:
2435 </p>
2436 <dl compact="compact">
2437 <dt><code>~</code></dt>
2438 <dd><p>The value of <code>$HOME</code>
2439 </p></dd>
2440 <dt><code>~/foo</code></dt>
2441 <dd><p><samp>$HOME/foo</samp>
2442 </p>
2443 </dd>
2444 <dt><code>~fred/foo</code></dt>
2445 <dd><p>The subdirectory <code>foo</code> of the home directory of the user
2446 <code>fred</code>
2447 </p>
2448 </dd>
2449 <dt><code>~+/foo</code></dt>
2450 <dd><p><samp>$PWD/foo</samp>
2451 </p>
2452 </dd>
2453 <dt><code>~-/foo</code></dt>
2454 <dd><p><samp>${OLDPWD-'~-'}/foo</samp>
2455 </p>
2456 </dd>
2457 <dt><code>~<var>N</var></code></dt>
2458 <dd><p>The string that would be displayed by &lsquo;<samp>dirs +<var>N</var></samp>&rsquo;
2459 </p>
2460 </dd>
2461 <dt><code>~+<var>N</var></code></dt>
2462 <dd><p>The string that would be displayed by &lsquo;<samp>dirs +<var>N</var></samp>&rsquo;
2463 </p>
2464 </dd>
2465 <dt><code>~-<var>N</var></code></dt>
2466 <dd><p>The string that would be displayed by &lsquo;<samp>dirs -<var>N</var></samp>&rsquo;
2467 </p></dd>
2468 </dl>
2469
2470 <p>Bash also performs tilde expansion on words satisfying the conditions of
2471 variable assignments (see <a href="#Shell-Parameters">Shell Parameters</a>)
2472 when they appear as arguments to simple commands.
2473 Bash does not do this, except for the <var>declaration</var> commands listed
2474 above, when in <small>POSIX</small> mode.
2475 </p>
2476 <hr>
2477 <a name="Shell-Parameter-Expansion"></a>
2478 <div class="header">
2479 <p>
2480 Next: <a href="#Command-Substitution" accesskey="n" rel="next">Command Substitution</a>, Previous: <a href="#Tilde-Expansion" accesskey="p" rel="prev">Tilde Expansion</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
2481 </div>
2482 <a name="Shell-Parameter-Expansion-1"></a>
2483 <h4 class="subsection">3.5.3 Shell Parameter Expansion</h4>
2484 <a name="index-parameter-expansion"></a>
2485 <a name="index-expansion_002c-parameter"></a>
2486
2487 <p>The &lsquo;<samp>$</samp>&rsquo; character introduces parameter expansion,
2488 command substitution, or arithmetic expansion. The parameter name
2489 or symbol to be expanded may be enclosed in braces, which
2490 are optional but serve to protect the variable to be expanded from
2491 characters immediately following it which could be
2492 interpreted as part of the name.
2493 </p>
2494 <p>When braces are used, the matching ending brace is the first &lsquo;<samp>}</samp>&rsquo;
2495 not escaped by a backslash or within a quoted string, and not within an
2496 embedded arithmetic expansion, command substitution, or parameter
2497 expansion.
2498 </p>
2499 <p>The basic form of parameter expansion is ${<var>parameter</var>}.
2500 The value of <var>parameter</var> is substituted.
2501 The <var>parameter</var> is a shell parameter as described above
2502 (see <a href="#Shell-Parameters">Shell Parameters</a>) or an array reference (see <a href="#Arrays">Arrays</a>).
2503 The braces are required when <var>parameter</var>
2504 is a positional parameter with more than one digit,
2505 or when <var>parameter</var> is followed by a character that is not to be
2506 interpreted as part of its name.
2507 </p>
2508 <p>If the first character of <var>parameter</var> is an exclamation point (!),
2509 and <var>parameter</var> is not a <var>nameref</var>,
2510 it introduces a level of indirection.
2511 Bash uses the value formed by expanding the rest of
2512 <var>parameter</var> as the new <var>parameter</var>; this is then
2513 expanded and that value is used in the rest of the expansion, rather
2514 than the expansion of the original <var>parameter</var>.
2515 This is known as <code>indirect expansion</code>.
2516 The value is subject to tilde expansion,
2517 parameter expansion, command substitution, and arithmetic expansion.
2518 If <var>parameter</var> is a nameref, this expands to the name of the
2519 variable referenced by <var>parameter</var> instead of performing the
2520 complete indirect expansion.
2521 The exceptions to this are the expansions of ${!<var>prefix</var>*}
2522 and ${!<var>name</var>[@]}
2523 described below.
2524 The exclamation point must immediately follow the left brace in order to
2525 introduce indirection.
2526 </p>
2527 <p>In each of the cases below, <var>word</var> is subject to tilde expansion,
2528 parameter expansion, command substitution, and arithmetic expansion.
2529 </p>
2530 <p>When not performing substring expansion, using the form described
2531 below (e.g., &lsquo;<samp>:-</samp>&rsquo;), Bash tests for a parameter that is unset or null.
2532 Omitting the colon results in a test only for a parameter that is unset.
2533 Put another way, if the colon is included,
2534 the operator tests for both <var>parameter</var>&rsquo;s existence and that its value
2535 is not null; if the colon is omitted, the operator tests only for existence.
2536 </p>
2537 <dl compact="compact">
2538 <dt><code>${<var>parameter</var>:-<var>word</var>}</code></dt>
2539 <dd><p>If <var>parameter</var> is unset or null, the expansion of
2540 <var>word</var> is substituted. Otherwise, the value of
2541 <var>parameter</var> is substituted.
2542 </p>
2543 </dd>
2544 <dt><code>${<var>parameter</var>:=<var>word</var>}</code></dt>
2545 <dd><p>If <var>parameter</var>
2546 is unset or null, the expansion of <var>word</var>
2547 is assigned to <var>parameter</var>.
2548 The value of <var>parameter</var> is then substituted.
2549 Positional parameters and special parameters may not be assigned to
2550 in this way.
2551 </p>
2552 </dd>
2553 <dt><code>${<var>parameter</var>:?<var>word</var>}</code></dt>
2554 <dd><p>If <var>parameter</var>
2555 is null or unset, the expansion of <var>word</var> (or a message
2556 to that effect if <var>word</var>
2557 is not present) is written to the standard error and the shell, if it
2558 is not interactive, exits. Otherwise, the value of <var>parameter</var> is
2559 substituted.
2560 </p>
2561 </dd>
2562 <dt><code>${<var>parameter</var>:+<var>word</var>}</code></dt>
2563 <dd><p>If <var>parameter</var>
2564 is null or unset, nothing is substituted, otherwise the expansion of
2565 <var>word</var> is substituted.
2566 </p>
2567 </dd>
2568 <dt><code>${<var>parameter</var>:<var>offset</var>}</code></dt>
2569 <dt><code>${<var>parameter</var>:<var>offset</var>:<var>length</var>}</code></dt>
2570 <dd><p>This is referred to as Substring Expansion.
2571 It expands to up to <var>length</var> characters of the value of <var>parameter</var>
2572 starting at the character specified by <var>offset</var>.
2573 If <var>parameter</var> is &lsquo;<samp>@</samp>&rsquo;, an indexed array subscripted by
2574 &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;, or an associative array name, the results differ as
2575 described below.
2576 If <var>length</var> is omitted, it expands to the substring of the value of
2577 <var>parameter</var> starting at the character specified by <var>offset</var>
2578 and extending to the end of the value.
2579 <var>length</var> and <var>offset</var> are arithmetic expressions
2580 (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>).
2581 </p>
2582 <p>If <var>offset</var> evaluates to a number less than zero, the value
2583 is used as an offset in characters
2584 from the end of the value of <var>parameter</var>.
2585 If <var>length</var> evaluates to a number less than zero,
2586 it is interpreted as an offset in characters
2587 from the end of the value of <var>parameter</var> rather than
2588 a number of characters, and the expansion is the characters between
2589 <var>offset</var> and that result.
2590 Note that a negative offset must be separated from the colon by at least
2591 one space to avoid being confused with the &lsquo;<samp>:-</samp>&rsquo; expansion.
2592 </p>
2593 <p>Here are some examples illustrating substring expansion on parameters and
2594 subscripted arrays:
2595 </p>
2596 <pre class="verbatim">$ string=01234567890abcdefgh
2597 $ echo ${string:7}
2598 7890abcdefgh
2599 $ echo ${string:7:0}
2600
2601 $ echo ${string:7:2}
2602 78
2603 $ echo ${string:7:-2}
2604 7890abcdef
2605 $ echo ${string: -7}
2606 bcdefgh
2607 $ echo ${string: -7:0}
2608
2609 $ echo ${string: -7:2}
2610 bc
2611 $ echo ${string: -7:-2}
2612 bcdef
2613 $ set -- 01234567890abcdefgh
2614 $ echo ${1:7}
2615 7890abcdefgh
2616 $ echo ${1:7:0}
2617
2618 $ echo ${1:7:2}
2619 78
2620 $ echo ${1:7:-2}
2621 7890abcdef
2622 $ echo ${1: -7}
2623 bcdefgh
2624 $ echo ${1: -7:0}
2625
2626 $ echo ${1: -7:2}
2627 bc
2628 $ echo ${1: -7:-2}
2629 bcdef
2630 $ array[0]=01234567890abcdefgh
2631 $ echo ${array[0]:7}
2632 7890abcdefgh
2633 $ echo ${array[0]:7:0}
2634
2635 $ echo ${array[0]:7:2}
2636 78
2637 $ echo ${array[0]:7:-2}
2638 7890abcdef
2639 $ echo ${array[0]: -7}
2640 bcdefgh
2641 $ echo ${array[0]: -7:0}
2642
2643 $ echo ${array[0]: -7:2}
2644 bc
2645 $ echo ${array[0]: -7:-2}
2646 bcdef
2647 </pre>
2648 <p>If <var>parameter</var> is &lsquo;<samp>@</samp>&rsquo;, the result is <var>length</var> positional
2649 parameters beginning at <var>offset</var>.
2650 A negative <var>offset</var> is taken relative to one greater than the greatest
2651 positional parameter, so an offset of -1 evaluates to the last positional
2652 parameter.
2653 It is an expansion error if <var>length</var> evaluates to a number less than zero.
2654 </p>
2655 <p>The following examples illustrate substring expansion using positional
2656 parameters:
2657 </p>
2658 <pre class="verbatim">$ set -- 1 2 3 4 5 6 7 8 9 0 a b c d e f g h
2659 $ echo ${@:7}
2660 7 8 9 0 a b c d e f g h
2661 $ echo ${@:7:0}
2662
2663 $ echo ${@:7:2}
2664 7 8
2665 $ echo ${@:7:-2}
2666 bash: -2: substring expression &lt; 0
2667 $ echo ${@: -7:2}
2668 b c
2669 $ echo ${@:0}
2670 ./bash 1 2 3 4 5 6 7 8 9 0 a b c d e f g h
2671 $ echo ${@:0:2}
2672 ./bash 1
2673 $ echo ${@: -7:0}
2674
2675 </pre>
2676 <p>If <var>parameter</var> is an indexed array name subscripted
2677 by &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;, the result is the <var>length</var>
2678 members of the array beginning with <code>${<var>parameter</var>[<var>offset</var>]}</code>.
2679 A negative <var>offset</var> is taken relative to one greater than the maximum
2680 index of the specified array.
2681 It is an expansion error if <var>length</var> evaluates to a number less than zero.
2682 </p>
2683 <p>These examples show how you can use substring expansion with indexed
2684 arrays:
2685 </p>
2686 <pre class="verbatim">$ array=(0 1 2 3 4 5 6 7 8 9 0 a b c d e f g h)
2687 $ echo ${array[@]:7}
2688 7 8 9 0 a b c d e f g h
2689 $ echo ${array[@]:7:2}
2690 7 8
2691 $ echo ${array[@]: -7:2}
2692 b c
2693 $ echo ${array[@]: -7:-2}
2694 bash: -2: substring expression &lt; 0
2695 $ echo ${array[@]:0}
2696 0 1 2 3 4 5 6 7 8 9 0 a b c d e f g h
2697 $ echo ${array[@]:0:2}
2698 0 1
2699 $ echo ${array[@]: -7:0}
2700
2701 </pre>
2702 <p>Substring expansion applied to an associative array produces undefined
2703 results.
2704 </p>
2705 <p>Substring indexing is zero-based unless the positional parameters
2706 are used, in which case the indexing starts at 1 by default.
2707 If <var>offset</var> is 0, and the positional parameters are used, <code>$@</code> is
2708 prefixed to the list.
2709 </p>
2710 </dd>
2711 <dt><code>${!<var>prefix</var>*}</code></dt>
2712 <dt><code>${!<var>prefix</var>@}</code></dt>
2713 <dd><p>Expands to the names of variables whose names begin with <var>prefix</var>,
2714 separated by the first character of the <code>IFS</code> special variable.
2715 When &lsquo;<samp>@</samp>&rsquo; is used and the expansion appears within double quotes, each
2716 variable name expands to a separate word.
2717 </p>
2718 </dd>
2719 <dt><code>${!<var>name</var>[@]}</code></dt>
2720 <dt><code>${!<var>name</var>[*]}</code></dt>
2721 <dd><p>If <var>name</var> is an array variable, expands to the list of array indices
2722 (keys) assigned in <var>name</var>.
2723 If <var>name</var> is not an array, expands to 0 if <var>name</var> is set and null
2724 otherwise.
2725 When &lsquo;<samp>@</samp>&rsquo; is used and the expansion appears within double quotes, each
2726 key expands to a separate word.
2727 </p>
2728 </dd>
2729 <dt><code>${#<var>parameter</var>}</code></dt>
2730 <dd><p>The length in characters of the expanded value of <var>parameter</var> is
2731 substituted.
2732 If <var>parameter</var> is &lsquo;<samp>*</samp>&rsquo; or &lsquo;<samp>@</samp>&rsquo;, the value substituted
2733 is the number of positional parameters.
2734 If <var>parameter</var> is an array name subscripted by &lsquo;<samp>*</samp>&rsquo; or &lsquo;<samp>@</samp>&rsquo;,
2735 the value substituted is the number of elements in the array.
2736 If <var>parameter</var>
2737 is an indexed array name subscripted by a negative number, that number is
2738 interpreted as relative to one greater than the maximum index of
2739 <var>parameter</var>, so negative indices count back from the end of the
2740 array, and an index of -1 references the last element.
2741 </p>
2742 </dd>
2743 <dt><code>${<var>parameter</var>#<var>word</var>}</code></dt>
2744 <dt><code>${<var>parameter</var>##<var>word</var>}</code></dt>
2745 <dd><p>The <var>word</var>
2746 is expanded to produce a pattern and matched according to the rules
2747 described below (see <a href="#Pattern-Matching">Pattern Matching</a>). If the pattern matches
2748 the beginning of the expanded value of <var>parameter</var>,
2749 then the result of the expansion is the expanded value of <var>parameter</var>
2750 with the shortest matching pattern (the &lsquo;<samp>#</samp>&rsquo; case) or the
2751 longest matching pattern (the &lsquo;<samp>##</samp>&rsquo; case) deleted.
2752 If <var>parameter</var> is &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
2753 the pattern removal operation is applied to each positional
2754 parameter in turn, and the expansion is the resultant list.
2755 If <var>parameter</var> is an array variable subscripted with
2756 &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
2757 the pattern removal operation is applied to each member of the
2758 array in turn, and the expansion is the resultant list.
2759 </p>
2760 </dd>
2761 <dt><code>${<var>parameter</var>%<var>word</var>}</code></dt>
2762 <dt><code>${<var>parameter</var>%%<var>word</var>}</code></dt>
2763 <dd><p>The <var>word</var>
2764 is expanded to produce a pattern and matched according to the rules
2765 described below (see <a href="#Pattern-Matching">Pattern Matching</a>). If the pattern matches
2766 If the pattern matches a trailing portion of the expanded value of
2767 <var>parameter</var>, then the result of the expansion is the value of
2768 <var>parameter</var> with the shortest matching pattern (the &lsquo;<samp>%</samp>&rsquo; case)
2769 or the longest matching pattern (the &lsquo;<samp>%%</samp>&rsquo; case) deleted.
2770 If <var>parameter</var> is &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
2771 the pattern removal operation is applied to each positional
2772 parameter in turn, and the expansion is the resultant list.
2773 If <var>parameter</var>
2774 is an array variable subscripted with &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
2775 the pattern removal operation is applied to each member of the
2776 array in turn, and the expansion is the resultant list.
2777 </p>
2778 </dd>
2779 <dt><code>${<var>parameter</var>/<var>pattern</var>/<var>string</var>}</code></dt>
2780 <dd>
2781 <p>The <var>pattern</var> is expanded to produce a pattern just as in
2782 filename expansion.
2783 <var>Parameter</var> is expanded and the longest match of <var>pattern</var>
2784 against its value is replaced with <var>string</var>.
2785 The match is performed according to the rules described below
2786 (see <a href="#Pattern-Matching">Pattern Matching</a>).
2787 If <var>pattern</var> begins with &lsquo;<samp>/</samp>&rsquo;, all matches of <var>pattern</var> are
2788 replaced with <var>string</var>. Normally only the first match is replaced.
2789 If <var>pattern</var> begins with &lsquo;<samp>#</samp>&rsquo;, it must match at the beginning
2790 of the expanded value of <var>parameter</var>.
2791 If <var>pattern</var> begins with &lsquo;<samp>%</samp>&rsquo;, it must match at the end
2792 of the expanded value of <var>parameter</var>.
2793 If <var>string</var> is null, matches of <var>pattern</var> are deleted
2794 and the <code>/</code> following <var>pattern</var> may be omitted.
2795 If the <code>nocasematch</code> shell option
2796 (see the description of <code>shopt</code> in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>)
2797 is enabled, the match is performed without regard to the case
2798 of alphabetic characters.
2799 If <var>parameter</var> is &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
2800 the substitution operation is applied to each positional
2801 parameter in turn, and the expansion is the resultant list.
2802 If <var>parameter</var>
2803 is an array variable subscripted with &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
2804 the substitution operation is applied to each member of the
2805 array in turn, and the expansion is the resultant list.
2806 </p>
2807 </dd>
2808 <dt><code>${<var>parameter</var>^<var>pattern</var>}</code></dt>
2809 <dt><code>${<var>parameter</var>^^<var>pattern</var>}</code></dt>
2810 <dt><code>${<var>parameter</var>,<var>pattern</var>}</code></dt>
2811 <dt><code>${<var>parameter</var>,,<var>pattern</var>}</code></dt>
2812 <dd><p>This expansion modifies the case of alphabetic characters in <var>parameter</var>.
2813 The <var>pattern</var> is expanded to produce a pattern just as in
2814 filename expansion.
2815 Each character in the expanded value of <var>parameter</var> is tested against
2816 <var>pattern</var>, and, if it matches the pattern, its case is converted.
2817 The pattern should not attempt to match more than one character.
2818 The &lsquo;<samp>^</samp>&rsquo; operator converts lowercase letters matching <var>pattern</var>
2819 to uppercase; the &lsquo;<samp>,</samp>&rsquo; operator converts matching uppercase letters
2820 to lowercase.
2821 The &lsquo;<samp>^^</samp>&rsquo; and &lsquo;<samp>,,</samp>&rsquo; expansions convert each matched character in the
2822 expanded value; the &lsquo;<samp>^</samp>&rsquo; and &lsquo;<samp>,</samp>&rsquo; expansions match and convert only
2823 the first character in the expanded value.
2824 If <var>pattern</var> is omitted, it is treated like a &lsquo;<samp>?</samp>&rsquo;, which matches
2825 every character.
2826 If <var>parameter</var> is &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
2827 the case modification operation is applied to each positional
2828 parameter in turn, and the expansion is the resultant list.
2829 If <var>parameter</var>
2830 is an array variable subscripted with &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
2831 the case modification operation is applied to each member of the
2832 array in turn, and the expansion is the resultant list.
2833 </p>
2834 </dd>
2835 <dt><code>${<var>parameter</var>@<var>operator</var>}</code></dt>
2836 <dd><p>The expansion is either a transformation of the value of <var>parameter</var>
2837 or information about <var>parameter</var> itself, depending on the value of
2838 <var>operator</var>. Each <var>operator</var> is a single letter:
2839 </p>
2840 <dl compact="compact">
2841 <dt><code>Q</code></dt>
2842 <dd><p>The expansion is a string that is the value of <var>parameter</var> quoted in a
2843 format that can be reused as input.
2844 </p></dd>
2845 <dt><code>E</code></dt>
2846 <dd><p>The expansion is a string that is the value of <var>parameter</var> with backslash
2847 escape sequences expanded as with the <code>$'&hellip;'</code> quoting mechanism.
2848 </p></dd>
2849 <dt><code>P</code></dt>
2850 <dd><p>The expansion is a string that is the result of expanding the value of
2851 <var>parameter</var> as if it were a prompt string (see <a href="#Controlling-the-Prompt">Controlling the Prompt</a>).
2852 </p></dd>
2853 <dt><code>A</code></dt>
2854 <dd><p>The expansion is a string in the form of
2855 an assignment statement or <code>declare</code> command that, if
2856 evaluated, will recreate <var>parameter</var> with its attributes and value.
2857 </p></dd>
2858 <dt><code>a</code></dt>
2859 <dd><p>The expansion is a string consisting of flag values representing
2860 <var>parameter</var>&rsquo;s attributes.
2861 </p></dd>
2862 </dl>
2863
2864 <p>If <var>parameter</var> is &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
2865 the operation is applied to each positional
2866 parameter in turn, and the expansion is the resultant list.
2867 If <var>parameter</var>
2868 is an array variable subscripted with &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
2869 the operation is applied to each member of the
2870 array in turn, and the expansion is the resultant list.
2871 </p>
2872 <p>The result of the expansion is subject to word splitting and pathname
2873 expansion as described below.
2874 </p></dd>
2875 </dl>
2876
2877 <hr>
2878 <a name="Command-Substitution"></a>
2879 <div class="header">
2880 <p>
2881 Next: <a href="#Arithmetic-Expansion" accesskey="n" rel="next">Arithmetic Expansion</a>, Previous: <a href="#Shell-Parameter-Expansion" accesskey="p" rel="prev">Shell Parameter Expansion</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
2882 </div>
2883 <a name="Command-Substitution-1"></a>
2884 <h4 class="subsection">3.5.4 Command Substitution</h4>
2885 <a name="index-command-substitution"></a>
2886
2887 <p>Command substitution allows the output of a command to replace
2888 the command itself.
2889 Command substitution occurs when a command is enclosed as follows:
2890 </p><div class="example">
2891 <pre class="example">$(<var>command</var>)
2892 </pre></div>
2893 <p>or
2894 </p><div class="example">
2895 <pre class="example">`<var>command</var>`
2896 </pre></div>
2897
2898 <p>Bash performs the expansion by executing <var>command</var> in a subshell environment
2899 and replacing the command substitution with the standard output of the
2900 command, with any trailing newlines deleted.
2901 Embedded newlines are not deleted, but they may be removed during
2902 word splitting.
2903 The command substitution <code>$(cat <var>file</var>)</code> can be
2904 replaced by the equivalent but faster <code>$(&lt; <var>file</var>)</code>.
2905 </p>
2906 <p>When the old-style backquote form of substitution is used,
2907 backslash retains its literal meaning except when followed by
2908 &lsquo;<samp>$</samp>&rsquo;, &lsquo;<samp>`</samp>&rsquo;, or &lsquo;<samp>\</samp>&rsquo;.
2909 The first backquote not preceded by a backslash terminates the
2910 command substitution.
2911 When using the <code>$(<var>command</var>)</code> form, all characters between
2912 the parentheses make up the command; none are treated specially.
2913 </p>
2914 <p>Command substitutions may be nested. To nest when using the backquoted
2915 form, escape the inner backquotes with backslashes.
2916 </p>
2917 <p>If the substitution appears within double quotes, word splitting and
2918 filename expansion are not performed on the results.
2919 </p>
2920 <hr>
2921 <a name="Arithmetic-Expansion"></a>
2922 <div class="header">
2923 <p>
2924 Next: <a href="#Process-Substitution" accesskey="n" rel="next">Process Substitution</a>, Previous: <a href="#Command-Substitution" accesskey="p" rel="prev">Command Substitution</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
2925 </div>
2926 <a name="Arithmetic-Expansion-1"></a>
2927 <h4 class="subsection">3.5.5 Arithmetic Expansion</h4>
2928 <a name="index-expansion_002c-arithmetic"></a>
2929 <a name="index-arithmetic-expansion"></a>
2930
2931 <p>Arithmetic expansion allows the evaluation of an arithmetic expression
2932 and the substitution of the result. The format for arithmetic expansion is:
2933 </p>
2934 <div class="example">
2935 <pre class="example">$(( <var>expression</var> ))
2936 </pre></div>
2937
2938 <p>The expression is treated as if it were within double quotes, but
2939 a double quote inside the parentheses is not treated specially.
2940 All tokens in the expression undergo parameter and variable expansion,
2941 command substitution, and quote removal.
2942 The result is treated as the arithmetic expression to be evaluated.
2943 Arithmetic expansions may be nested.
2944 </p>
2945 <p>The evaluation is performed according to the rules listed below
2946 (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>).
2947 If the expression is invalid, Bash prints a message indicating
2948 failure to the standard error and no substitution occurs.
2949 </p>
2950 <hr>
2951 <a name="Process-Substitution"></a>
2952 <div class="header">
2953 <p>
2954 Next: <a href="#Word-Splitting" accesskey="n" rel="next">Word Splitting</a>, Previous: <a href="#Arithmetic-Expansion" accesskey="p" rel="prev">Arithmetic Expansion</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
2955 </div>
2956 <a name="Process-Substitution-1"></a>
2957 <h4 class="subsection">3.5.6 Process Substitution</h4>
2958 <a name="index-process-substitution"></a>
2959
2960 <p>Process substitution allows a process&rsquo;s input or output to be
2961 referred to using a filename.
2962 It takes the form of
2963 </p><div class="example">
2964 <pre class="example">&lt;(<var>list</var>)
2965 </pre></div>
2966 <p>or
2967 </p><div class="example">
2968 <pre class="example">&gt;(<var>list</var>)
2969 </pre></div>
2970 <p>The process <var>list</var> is run asynchronously, and its input or output
2971 appears as a filename.
2972 This filename is
2973 passed as an argument to the current command as the result of the
2974 expansion.
2975 If the <code>&gt;(<var>list</var>)</code> form is used, writing to
2976 the file will provide input for <var>list</var>. If the
2977 <code>&lt;(<var>list</var>)</code> form is used, the file passed as an
2978 argument should be read to obtain the output of <var>list</var>.
2979 Note that no space may appear between the <code>&lt;</code> or <code>&gt;</code>
2980 and the left parenthesis, otherwise the construct would be interpreted
2981 as a redirection.
2982 Process substitution is supported on systems that support named
2983 pipes (<small>FIFO</small>s) or the <samp>/dev/fd</samp> method of naming open files.
2984 </p>
2985 <p>When available, process substitution is performed simultaneously with
2986 parameter and variable expansion, command substitution, and arithmetic
2987 expansion.
2988 </p>
2989 <hr>
2990 <a name="Word-Splitting"></a>
2991 <div class="header">
2992 <p>
2993 Next: <a href="#Filename-Expansion" accesskey="n" rel="next">Filename Expansion</a>, Previous: <a href="#Process-Substitution" accesskey="p" rel="prev">Process Substitution</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
2994 </div>
2995 <a name="Word-Splitting-1"></a>
2996 <h4 class="subsection">3.5.7 Word Splitting</h4>
2997 <a name="index-word-splitting"></a>
2998
2999 <p>The shell scans the results of parameter expansion, command substitution,
3000 and arithmetic expansion that did not occur within double quotes for
3001 word splitting.
3002 </p>
3003 <p>The shell treats each character of <code>$IFS</code> as a delimiter, and splits
3004 the results of the other expansions into words using these characters
3005 as field terminators.
3006 If <code>IFS</code> is unset, or its value is exactly <code>&lt;space&gt;&lt;tab&gt;&lt;newline&gt;</code>,
3007 the default, then sequences of
3008 <code> &lt;space&gt;</code>, <code>&lt;tab&gt;</code>, and <code>&lt;newline&gt;</code>
3009 at the beginning and end of the results of the previous
3010 expansions are ignored, and any sequence of <code>IFS</code>
3011 characters not at the beginning or end serves to delimit words.
3012 If <code>IFS</code> has a value other than the default, then sequences of
3013 the whitespace characters <code>space</code>, <code>tab</code>, and <code>newline</code>
3014 are ignored at the beginning and end of the
3015 word, as long as the whitespace character is in the
3016 value of <code>IFS</code> (an <code>IFS</code> whitespace character).
3017 Any character in <code>IFS</code> that is not <code>IFS</code>
3018 whitespace, along with any adjacent <code>IFS</code>
3019 whitespace characters, delimits a field. A sequence of <code>IFS</code>
3020 whitespace characters is also treated as a delimiter.
3021 If the value of <code>IFS</code> is null, no word splitting occurs.
3022 </p>
3023 <p>Explicit null arguments (<code>&quot;&quot;</code> or <code>''</code>) are retained
3024 and passed to commands as empty strings.
3025 Unquoted implicit null arguments, resulting from the expansion of
3026 parameters that have no values, are removed.
3027 If a parameter with no value is expanded within double quotes, a
3028 null argument results and is retained
3029 and passed to a command as an empty string.
3030 When a quoted null argument appears as part of a word whose expansion is
3031 non-null, the null argument is removed.
3032 That is, the word
3033 <code>-d''</code> becomes <code>-d</code> after word splitting and
3034 null argument removal.
3035 </p>
3036 <p>Note that if no expansion occurs, no splitting
3037 is performed.
3038 </p>
3039 <hr>
3040 <a name="Filename-Expansion"></a>
3041 <div class="header">
3042 <p>
3043 Next: <a href="#Quote-Removal" accesskey="n" rel="next">Quote Removal</a>, Previous: <a href="#Word-Splitting" accesskey="p" rel="prev">Word Splitting</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
3044 </div>
3045 <a name="Filename-Expansion-1"></a>
3046 <h4 class="subsection">3.5.8 Filename Expansion</h4>
3047 <table class="menu" border="0" cellspacing="0">
3048 <tr><td align="left" valign="top">&bull; <a href="#Pattern-Matching" accesskey="1">Pattern Matching</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How the shell matches patterns.
3049 </td></tr>
3050 </table>
3051 <a name="index-expansion_002c-filename"></a>
3052 <a name="index-expansion_002c-pathname"></a>
3053 <a name="index-filename-expansion"></a>
3054 <a name="index-pathname-expansion"></a>
3055
3056 <p>After word splitting, unless the <samp>-f</samp> option has been set
3057 (see <a href="#The-Set-Builtin">The Set Builtin</a>), Bash scans each word for the characters
3058 &lsquo;<samp>*</samp>&rsquo;, &lsquo;<samp>?</samp>&rsquo;, and &lsquo;<samp>[</samp>&rsquo;.
3059 If one of these characters appears, then the word is
3060 regarded as a <var>pattern</var>,
3061 and replaced with an alphabetically sorted list of
3062 filenames matching the pattern (see <a href="#Pattern-Matching">Pattern Matching</a>).
3063 If no matching filenames are found,
3064 and the shell option <code>nullglob</code> is disabled, the word is left
3065 unchanged.
3066 If the <code>nullglob</code> option is set, and no matches are found, the word
3067 is removed.
3068 If the <code>failglob</code> shell option is set, and no matches are found,
3069 an error message is printed and the command is not executed.
3070 If the shell option <code>nocaseglob</code> is enabled, the match is performed
3071 without regard to the case of alphabetic characters.
3072 </p>
3073 <p>When a pattern is used for filename expansion, the character &lsquo;<samp>.</samp>&rsquo;
3074 at the start of a filename or immediately following a slash
3075 must be matched explicitly, unless the shell option <code>dotglob</code> is set.
3076 The filenames &lsquo;<samp>.</samp>&rsquo; and &lsquo;<samp>..</samp>&rsquo; must always be matched explicitly,
3077 even if <code>dotglob</code> is set.
3078 In other cases, the &lsquo;<samp>.</samp>&rsquo; character is not treated specially.
3079 </p>
3080 <p>When matching a filename, the slash character must always be
3081 matched explicitly by a slash in the pattern, but in other matching
3082 contexts it can be matched by a special pattern character as described
3083 below (see <a href="#Pattern-Matching">Pattern Matching</a>).
3084 </p>
3085 <p>See the description of <code>shopt</code> in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>,
3086 for a description of the <code>nocaseglob</code>, <code>nullglob</code>,
3087 <code>failglob</code>, and <code>dotglob</code> options.
3088 </p>
3089 <p>The <code>GLOBIGNORE</code>
3090 shell variable may be used to restrict the set of file names matching a
3091 pattern. If <code>GLOBIGNORE</code>
3092 is set, each matching file name that also matches one of the patterns in
3093 <code>GLOBIGNORE</code> is removed from the list of matches.
3094 If the <code>nocaseglob</code> option is set, the matching against the patterns in
3095 <code>GLOBIGNORE</code> is performed without regard to case.
3096 The filenames
3097 <samp>.</samp> and <samp>..</samp>
3098 are always ignored when <code>GLOBIGNORE</code>
3099 is set and not null.
3100 However, setting <code>GLOBIGNORE</code> to a non-null value has the effect of
3101 enabling the <code>dotglob</code>
3102 shell option, so all other filenames beginning with a
3103 &lsquo;<samp>.</samp>&rsquo; will match.
3104 To get the old behavior of ignoring filenames beginning with a
3105 &lsquo;<samp>.</samp>&rsquo;, make &lsquo;<samp>.*</samp>&rsquo; one of the patterns in <code>GLOBIGNORE</code>.
3106 The <code>dotglob</code> option is disabled when <code>GLOBIGNORE</code>
3107 is unset.
3108 </p>
3109 <hr>
3110 <a name="Pattern-Matching"></a>
3111 <div class="header">
3112 <p>
3113 Up: <a href="#Filename-Expansion" accesskey="u" rel="up">Filename Expansion</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
3114 </div>
3115 <a name="Pattern-Matching-1"></a>
3116 <h4 class="subsubsection">3.5.8.1 Pattern Matching</h4>
3117 <a name="index-pattern-matching"></a>
3118 <a name="index-matching_002c-pattern"></a>
3119
3120 <p>Any character that appears in a pattern, other than the special pattern
3121 characters described below, matches itself.
3122 The <small>NUL</small> character may not occur in a pattern.
3123 A backslash escapes the following character; the
3124 escaping backslash is discarded when matching.
3125 The special pattern characters must be quoted if they are to be matched
3126 literally.
3127 </p>
3128 <p>The special pattern characters have the following meanings:
3129 </p><dl compact="compact">
3130 <dt><code>*</code></dt>
3131 <dd><p>Matches any string, including the null string.
3132 When the <code>globstar</code> shell option is enabled, and &lsquo;<samp>*</samp>&rsquo; is used in
3133 a filename expansion context, two adjacent &lsquo;<samp>*</samp>&rsquo;s used as a single
3134 pattern will match all files and zero or more directories and
3135 subdirectories.
3136 If followed by a &lsquo;<samp>/</samp>&rsquo;, two adjacent &lsquo;<samp>*</samp>&rsquo;s will match only
3137 directories and subdirectories.
3138 </p></dd>
3139 <dt><code>?</code></dt>
3140 <dd><p>Matches any single character.
3141 </p></dd>
3142 <dt><code>[&hellip;]</code></dt>
3143 <dd><p>Matches any one of the enclosed characters. A pair of characters
3144 separated by a hyphen denotes a <var>range expression</var>;
3145 any character that falls between those two characters, inclusive,
3146 using the current locale&rsquo;s collating sequence and character set,
3147 is matched. If the first character following the
3148 &lsquo;<samp>[</samp>&rsquo; is a &lsquo;<samp>!</samp>&rsquo; or a &lsquo;<samp>^</samp>&rsquo;
3149 then any character not enclosed is matched. A &lsquo;<samp>-</samp>&rsquo;
3150 may be matched by including it as the first or last character
3151 in the set. A &lsquo;<samp>]</samp>&rsquo; may be matched by including it as the first
3152 character in the set.
3153 The sorting order of characters in range expressions is determined by
3154 the current locale and the values of the
3155 <code>LC_COLLATE</code> and <code>LC_ALL</code> shell variables, if set.
3156 </p>
3157 <p>For example, in the default C locale, &lsquo;<samp>[a-dx-z]</samp>&rsquo; is equivalent to
3158 &lsquo;<samp>[abcdxyz]</samp>&rsquo;. Many locales sort characters in dictionary order, and in
3159 these locales &lsquo;<samp>[a-dx-z]</samp>&rsquo; is typically not equivalent to &lsquo;<samp>[abcdxyz]</samp>&rsquo;;
3160 it might be equivalent to &lsquo;<samp>[aBbCcDdxXyYz]</samp>&rsquo;, for example. To obtain
3161 the traditional interpretation of ranges in bracket expressions, you can
3162 force the use of the C locale by setting the <code>LC_COLLATE</code> or
3163 <code>LC_ALL</code> environment variable to the value &lsquo;<samp>C</samp>&rsquo;, or enable the
3164 <code>globasciiranges</code> shell option.
3165 </p>
3166 <p>Within &lsquo;<samp>[</samp>&rsquo; and &lsquo;<samp>]</samp>&rsquo;, <var>character classes</var> can be specified
3167 using the syntax
3168 <code>[:</code><var>class</var><code>:]</code>, where <var>class</var> is one of the
3169 following classes defined in the <small>POSIX</small> standard:
3170 </p><div class="example">
3171 <pre class="example">alnum alpha ascii blank cntrl digit graph lower
3172 print punct space upper word xdigit
3173 </pre></div>
3174 <p>A character class matches any character belonging to that class.
3175 The <code>word</code> character class matches letters, digits, and the character
3176 &lsquo;<samp>_</samp>&rsquo;.
3177 </p>
3178 <p>Within &lsquo;<samp>[</samp>&rsquo; and &lsquo;<samp>]</samp>&rsquo;, an <var>equivalence class</var> can be
3179 specified using the syntax <code>[=</code><var>c</var><code>=]</code>, which
3180 matches all characters with the same collation weight (as defined
3181 by the current locale) as the character <var>c</var>.
3182 </p>
3183 <p>Within &lsquo;<samp>[</samp>&rsquo; and &lsquo;<samp>]</samp>&rsquo;, the syntax <code>[.</code><var>symbol</var><code>.]</code>
3184 matches the collating symbol <var>symbol</var>.
3185 </p></dd>
3186 </dl>
3187
3188 <p>If the <code>extglob</code> shell option is enabled using the <code>shopt</code>
3189 builtin, several extended pattern matching operators are recognized.
3190 In the following description, a <var>pattern-list</var> is a list of one
3191 or more patterns separated by a &lsquo;<samp>|</samp>&rsquo;.
3192 Composite patterns may be formed using one or more of the following
3193 sub-patterns:
3194 </p>
3195 <dl compact="compact">
3196 <dt><code>?(<var>pattern-list</var>)</code></dt>
3197 <dd><p>Matches zero or one occurrence of the given patterns.
3198 </p>
3199 </dd>
3200 <dt><code>*(<var>pattern-list</var>)</code></dt>
3201 <dd><p>Matches zero or more occurrences of the given patterns.
3202 </p>
3203 </dd>
3204 <dt><code>+(<var>pattern-list</var>)</code></dt>
3205 <dd><p>Matches one or more occurrences of the given patterns.
3206 </p>
3207 </dd>
3208 <dt><code>@(<var>pattern-list</var>)</code></dt>
3209 <dd><p>Matches one of the given patterns.
3210 </p>
3211 </dd>
3212 <dt><code>!(<var>pattern-list</var>)</code></dt>
3213 <dd><p>Matches anything except one of the given patterns.
3214 </p></dd>
3215 </dl>
3216
3217 <p>Complicated extended pattern matching against long strings is slow,
3218 especially when the patterns contain alternations and the strings
3219 contain multiple matches.
3220 Using separate matches against shorter strings, or using arrays of
3221 strings instead of a single long string, may be faster.
3222 </p>
3223 <hr>
3224 <a name="Quote-Removal"></a>
3225 <div class="header">
3226 <p>
3227 Previous: <a href="#Filename-Expansion" accesskey="p" rel="prev">Filename Expansion</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
3228 </div>
3229 <a name="Quote-Removal-1"></a>
3230 <h4 class="subsection">3.5.9 Quote Removal</h4>
3231
3232 <p>After the preceding expansions, all unquoted occurrences of the
3233 characters &lsquo;<samp>\</samp>&rsquo;, &lsquo;<samp>'</samp>&rsquo;, and &lsquo;<samp>&quot;</samp>&rsquo; that did not
3234 result from one of the above expansions are removed.
3235 </p>
3236 <hr>
3237 <a name="Redirections"></a>
3238 <div class="header">
3239 <p>
3240 Next: <a href="#Executing-Commands" accesskey="n" rel="next">Executing Commands</a>, Previous: <a href="#Shell-Expansions" accesskey="p" rel="prev">Shell Expansions</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
3241 </div>
3242 <a name="Redirections-1"></a>
3243 <h3 class="section">3.6 Redirections</h3>
3244 <a name="index-redirection"></a>
3245
3246 <p>Before a command is executed, its input and output
3247 may be <var>redirected</var>
3248 using a special notation interpreted by the shell.
3249 Redirection allows commands&rsquo; file handles to be
3250 duplicated, opened, closed,
3251 made to refer to different files,
3252 and can change the files the command reads from and writes to.
3253 Redirection may also be used to modify file handles in the
3254 current shell execution environment. The following redirection
3255 operators may precede or appear anywhere within a
3256 simple command or may follow a command.
3257 Redirections are processed in the order they appear, from
3258 left to right.
3259 </p>
3260 <p>Each redirection that may be preceded by a file descriptor number
3261 may instead be preceded by a word of the form {<var>varname</var>}.
3262 In this case, for each redirection operator except
3263 &gt;&amp;- and &lt;&amp;-, the shell will allocate a file descriptor greater
3264 than 10 and assign it to {<var>varname</var>}. If &gt;&amp;- or &lt;&amp;- is preceded
3265 by {<var>varname</var>}, the value of <var>varname</var> defines the file
3266 descriptor to close.
3267 If {<var>varname</var>} is supplied, the redirection persists beyond
3268 the scope of the command, allowing the shell programmer to manage
3269 the file descriptor himself.
3270 </p>
3271 <p>In the following descriptions, if the file descriptor number is
3272 omitted, and the first character of the redirection operator is
3273 &lsquo;<samp>&lt;</samp>&rsquo;, the redirection refers to the standard input (file
3274 descriptor 0). If the first character of the redirection operator
3275 is &lsquo;<samp>&gt;</samp>&rsquo;, the redirection refers to the standard output (file
3276 descriptor 1).
3277 </p>
3278 <p>The word following the redirection operator in the following
3279 descriptions, unless otherwise noted, is subjected to brace expansion,
3280 tilde expansion, parameter expansion, command substitution, arithmetic
3281 expansion, quote removal, filename expansion, and word splitting.
3282 If it expands to more than one word, Bash reports an error.
3283 </p>
3284 <p>Note that the order of redirections is significant. For example,
3285 the command
3286 </p><div class="example">
3287 <pre class="example">ls &gt; <var>dirlist</var> 2&gt;&amp;1
3288 </pre></div>
3289 <p>directs both standard output (file descriptor 1) and standard error
3290 (file descriptor 2) to the file <var>dirlist</var>, while the command
3291 </p><div class="example">
3292 <pre class="example">ls 2&gt;&amp;1 &gt; <var>dirlist</var>
3293 </pre></div>
3294 <p>directs only the standard output to file <var>dirlist</var>,
3295 because the standard error was made a copy of the standard output
3296 before the standard output was redirected to <var>dirlist</var>.
3297 </p>
3298 <p>Bash handles several filenames specially when they are used in
3299 redirections, as described in the following table.
3300 If the operating system on which Bash is running provides these
3301 special files, bash will use them; otherwise it will emulate them
3302 internally with the behavior described below.
3303 </p>
3304 <dl compact="compact">
3305 <dt><code>/dev/fd/<var>fd</var></code></dt>
3306 <dd><p>If <var>fd</var> is a valid integer, file descriptor <var>fd</var> is duplicated.
3307 </p>
3308 </dd>
3309 <dt><code>/dev/stdin</code></dt>
3310 <dd><p>File descriptor 0 is duplicated.
3311 </p>
3312 </dd>
3313 <dt><code>/dev/stdout</code></dt>
3314 <dd><p>File descriptor 1 is duplicated.
3315 </p>
3316 </dd>
3317 <dt><code>/dev/stderr</code></dt>
3318 <dd><p>File descriptor 2 is duplicated.
3319 </p>
3320 </dd>
3321 <dt><code>/dev/tcp/<var>host</var>/<var>port</var></code></dt>
3322 <dd><p>If <var>host</var> is a valid hostname or Internet address, and <var>port</var>
3323 is an integer port number or service name, Bash attempts to open
3324 the corresponding TCP socket.
3325 </p>
3326 </dd>
3327 <dt><code>/dev/udp/<var>host</var>/<var>port</var></code></dt>
3328 <dd><p>If <var>host</var> is a valid hostname or Internet address, and <var>port</var>
3329 is an integer port number or service name, Bash attempts to open
3330 the corresponding UDP socket.
3331 </p></dd>
3332 </dl>
3333
3334 <p>A failure to open or create a file causes the redirection to fail.
3335 </p>
3336 <p>Redirections using file descriptors greater than 9 should be used with
3337 care, as they may conflict with file descriptors the shell uses
3338 internally.
3339 </p>
3340 <a name="Redirecting-Input"></a>
3341 <h4 class="subsection">3.6.1 Redirecting Input</h4>
3342 <p>Redirection of input causes the file whose name results from
3343 the expansion of <var>word</var>
3344 to be opened for reading on file descriptor <code>n</code>,
3345 or the standard input (file descriptor 0) if <code>n</code>
3346 is not specified.
3347 </p>
3348 <p>The general format for redirecting input is:
3349 </p><div class="example">
3350 <pre class="example">[<var>n</var>]&lt;<var>word</var>
3351 </pre></div>
3352
3353 <a name="Redirecting-Output"></a>
3354 <h4 class="subsection">3.6.2 Redirecting Output</h4>
3355 <p>Redirection of output causes the file whose name results from
3356 the expansion of <var>word</var>
3357 to be opened for writing on file descriptor <var>n</var>,
3358 or the standard output (file descriptor 1) if <var>n</var>
3359 is not specified. If the file does not exist it is created;
3360 if it does exist it is truncated to zero size.
3361 </p>
3362 <p>The general format for redirecting output is:
3363 </p><div class="example">
3364 <pre class="example">[<var>n</var>]&gt;[|]<var>word</var>
3365 </pre></div>
3366
3367 <p>If the redirection operator is &lsquo;<samp>&gt;</samp>&rsquo;, and the <code>noclobber</code>
3368 option to the <code>set</code> builtin has been enabled, the redirection
3369 will fail if the file whose name results from the expansion of
3370 <var>word</var> exists and is a regular file.
3371 If the redirection operator is &lsquo;<samp>&gt;|</samp>&rsquo;, or the redirection operator is
3372 &lsquo;<samp>&gt;</samp>&rsquo; and the <code>noclobber</code> option is not enabled, the redirection
3373 is attempted even if the file named by <var>word</var> exists.
3374 </p>
3375 <a name="Appending-Redirected-Output"></a>
3376 <h4 class="subsection">3.6.3 Appending Redirected Output</h4>
3377 <p>Redirection of output in this fashion
3378 causes the file whose name results from
3379 the expansion of <var>word</var>
3380 to be opened for appending on file descriptor <var>n</var>,
3381 or the standard output (file descriptor 1) if <var>n</var>
3382 is not specified. If the file does not exist it is created.
3383 </p>
3384 <p>The general format for appending output is:
3385 </p><div class="example">
3386 <pre class="example">[<var>n</var>]&gt;&gt;<var>word</var>
3387 </pre></div>
3388
3389 <a name="Redirecting-Standard-Output-and-Standard-Error"></a>
3390 <h4 class="subsection">3.6.4 Redirecting Standard Output and Standard Error</h4>
3391 <p>This construct allows both the
3392 standard output (file descriptor 1) and
3393 the standard error output (file descriptor 2)
3394 to be redirected to the file whose name is the
3395 expansion of <var>word</var>.
3396 </p>
3397 <p>There are two formats for redirecting standard output and
3398 standard error:
3399 </p><div class="example">
3400 <pre class="example">&amp;&gt;<var>word</var>
3401 </pre></div>
3402 <p>and
3403 </p><div class="example">
3404 <pre class="example">&gt;&amp;<var>word</var>
3405 </pre></div>
3406 <p>Of the two forms, the first is preferred.
3407 This is semantically equivalent to
3408 </p><div class="example">
3409 <pre class="example">&gt;<var>word</var> 2&gt;&amp;1
3410 </pre></div>
3411 <p>When using the second form, <var>word</var> may not expand to a number or
3412 &lsquo;<samp>-</samp>&rsquo;. If it does, other redirection operators apply
3413 (see Duplicating File Descriptors below) for compatibility reasons.
3414 </p>
3415 <a name="Appending-Standard-Output-and-Standard-Error"></a>
3416 <h4 class="subsection">3.6.5 Appending Standard Output and Standard Error</h4>
3417 <p>This construct allows both the
3418 standard output (file descriptor 1) and
3419 the standard error output (file descriptor 2)
3420 to be appended to the file whose name is the
3421 expansion of <var>word</var>.
3422 </p>
3423 <p>The format for appending standard output and standard error is:
3424 </p><div class="example">
3425 <pre class="example">&amp;&gt;&gt;<var>word</var>
3426 </pre></div>
3427 <p>This is semantically equivalent to
3428 </p><div class="example">
3429 <pre class="example">&gt;&gt;<var>word</var> 2&gt;&amp;1
3430 </pre></div>
3431 <p>(see Duplicating File Descriptors below).
3432 </p>
3433 <a name="Here-Documents"></a>
3434 <h4 class="subsection">3.6.6 Here Documents</h4>
3435 <p>This type of redirection instructs the shell to read input from the
3436 current source until a line containing only <var>word</var>
3437 (with no trailing blanks) is seen. All of
3438 the lines read up to that point are then used as the standard
3439 input (or file descriptor <var>n</var> if <var>n</var> is specified) for a command.
3440 </p>
3441 <p>The format of here-documents is:
3442 </p><div class="example">
3443 <pre class="example">[<var>n</var>]&lt;&lt;[-]<var>word</var>
3444 <var>here-document</var>
3445 <var>delimiter</var>
3446 </pre></div>
3447
3448 <p>No parameter and variable expansion, command substitution,
3449 arithmetic expansion, or filename expansion is performed on
3450 <var>word</var>. If any part of <var>word</var> is quoted, the
3451 <var>delimiter</var> is the result of quote removal on <var>word</var>,
3452 and the lines in the here-document are not expanded.
3453 If <var>word</var> is unquoted,
3454 all lines of the here-document are subjected to
3455 parameter expansion, command substitution, and arithmetic expansion,
3456 the character sequence <code>\newline</code> is ignored, and &lsquo;<samp>\</samp>&rsquo;
3457 must be used to quote the characters
3458 &lsquo;<samp>\</samp>&rsquo;, &lsquo;<samp>$</samp>&rsquo;, and &lsquo;<samp>`</samp>&rsquo;.
3459 </p>
3460 <p>If the redirection operator is &lsquo;<samp>&lt;&lt;-</samp>&rsquo;,
3461 then all leading tab characters are stripped from input lines and the
3462 line containing <var>delimiter</var>.
3463 This allows here-documents within shell scripts to be indented in a
3464 natural fashion.
3465 </p>
3466 <a name="Here-Strings"></a>
3467 <h4 class="subsection">3.6.7 Here Strings</h4>
3468 <p>A variant of here documents, the format is:
3469 </p><div class="example">
3470 <pre class="example">[<var>n</var>]&lt;&lt;&lt; <var>word</var>
3471 </pre></div>
3472
3473 <p>The <var>word</var> undergoes
3474 tilde expansion, parameter and variable expansion,
3475 command substitution, arithmetic expansion, and quote removal.
3476 Pathname expansion and word splitting are not performed.
3477 The result is supplied as a single string,
3478 with a newline appended,
3479 to the command on its
3480 standard input (or file descriptor <var>n</var> if <var>n</var> is specified).
3481 </p>
3482 <a name="Duplicating-File-Descriptors"></a>
3483 <h4 class="subsection">3.6.8 Duplicating File Descriptors</h4>
3484 <p>The redirection operator
3485 </p><div class="example">
3486 <pre class="example">[<var>n</var>]&lt;&amp;<var>word</var>
3487 </pre></div>
3488 <p>is used to duplicate input file descriptors.
3489 If <var>word</var>
3490 expands to one or more digits, the file descriptor denoted by <var>n</var>
3491 is made to be a copy of that file descriptor.
3492 If the digits in <var>word</var> do not specify a file descriptor open for
3493 input, a redirection error occurs.
3494 If <var>word</var>
3495 evaluates to &lsquo;<samp>-</samp>&rsquo;, file descriptor <var>n</var> is closed.
3496 If <var>n</var> is not specified, the standard input (file descriptor 0) is used.
3497 </p>
3498 <p>The operator
3499 </p><div class="example">
3500 <pre class="example">[<var>n</var>]&gt;&amp;<var>word</var>
3501 </pre></div>
3502 <p>is used similarly to duplicate output file descriptors. If
3503 <var>n</var> is not specified, the standard output (file descriptor 1) is used.
3504 If the digits in <var>word</var> do not specify a file descriptor open for
3505 output, a redirection error occurs.
3506 If <var>word</var>
3507 evaluates to &lsquo;<samp>-</samp>&rsquo;, file descriptor <var>n</var> is closed.
3508 As a special case, if <var>n</var> is omitted, and <var>word</var> does not
3509 expand to one or more digits or &lsquo;<samp>-</samp>&rsquo;, the standard output and standard
3510 error are redirected as described previously.
3511 </p>
3512 <a name="Moving-File-Descriptors"></a>
3513 <h4 class="subsection">3.6.9 Moving File Descriptors</h4>
3514 <p>The redirection operator
3515 </p><div class="example">
3516 <pre class="example">[<var>n</var>]&lt;&amp;<var>digit</var>-
3517 </pre></div>
3518 <p>moves the file descriptor <var>digit</var> to file descriptor <var>n</var>,
3519 or the standard input (file descriptor 0) if <var>n</var> is not specified.
3520 <var>digit</var> is closed after being duplicated to <var>n</var>.
3521 </p>
3522 <p>Similarly, the redirection operator
3523 </p><div class="example">
3524 <pre class="example">[<var>n</var>]&gt;&amp;<var>digit</var>-
3525 </pre></div>
3526 <p>moves the file descriptor <var>digit</var> to file descriptor <var>n</var>,
3527 or the standard output (file descriptor 1) if <var>n</var> is not specified.
3528 </p>
3529 <a name="Opening-File-Descriptors-for-Reading-and-Writing"></a>
3530 <h4 class="subsection">3.6.10 Opening File Descriptors for Reading and Writing</h4>
3531 <p>The redirection operator
3532 </p><div class="example">
3533 <pre class="example">[<var>n</var>]&lt;&gt;<var>word</var>
3534 </pre></div>
3535 <p>causes the file whose name is the expansion of <var>word</var>
3536 to be opened for both reading and writing on file descriptor
3537 <var>n</var>, or on file descriptor 0 if <var>n</var>
3538 is not specified. If the file does not exist, it is created.
3539 </p>
3540 <hr>
3541 <a name="Executing-Commands"></a>
3542 <div class="header">
3543 <p>
3544 Next: <a href="#Shell-Scripts" accesskey="n" rel="next">Shell Scripts</a>, Previous: <a href="#Redirections" accesskey="p" rel="prev">Redirections</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
3545 </div>
3546 <a name="Executing-Commands-1"></a>
3547 <h3 class="section">3.7 Executing Commands</h3>
3548
3549 <table class="menu" border="0" cellspacing="0">
3550 <tr><td align="left" valign="top">&bull; <a href="#Simple-Command-Expansion" accesskey="1">Simple Command Expansion</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How Bash expands simple commands before
3551 executing them.
3552 </td></tr>
3553 <tr><td align="left" valign="top">&bull; <a href="#Command-Search-and-Execution" accesskey="2">Command Search and Execution</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How Bash finds commands and runs them.
3554 </td></tr>
3555 <tr><td align="left" valign="top">&bull; <a href="#Command-Execution-Environment" accesskey="3">Command Execution Environment</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The environment in which Bash
3556 executes commands that are not
3557 shell builtins.
3558 </td></tr>
3559 <tr><td align="left" valign="top">&bull; <a href="#Environment" accesskey="4">Environment</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The environment given to a command.
3560 </td></tr>
3561 <tr><td align="left" valign="top">&bull; <a href="#Exit-Status" accesskey="5">Exit Status</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The status returned by commands and how Bash
3562 interprets it.
3563 </td></tr>
3564 <tr><td align="left" valign="top">&bull; <a href="#Signals" accesskey="6">Signals</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What happens when Bash or a command it runs
3565 receives a signal.
3566 </td></tr>
3567 </table>
3568
3569 <hr>
3570 <a name="Simple-Command-Expansion"></a>
3571 <div class="header">
3572 <p>
3573 Next: <a href="#Command-Search-and-Execution" accesskey="n" rel="next">Command Search and Execution</a>, Up: <a href="#Executing-Commands" accesskey="u" rel="up">Executing Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
3574 </div>
3575 <a name="Simple-Command-Expansion-1"></a>
3576 <h4 class="subsection">3.7.1 Simple Command Expansion</h4>
3577 <a name="index-command-expansion"></a>
3578
3579 <p>When a simple command is executed, the shell performs the following
3580 expansions, assignments, and redirections, from left to right.
3581 </p>
3582 <ol>
3583 <li> The words that the parser has marked as variable assignments (those
3584 preceding the command name) and redirections are saved for later
3585 processing.
3586
3587 </li><li> The words that are not variable assignments or redirections are
3588 expanded (see <a href="#Shell-Expansions">Shell Expansions</a>).
3589 If any words remain after expansion, the first word
3590 is taken to be the name of the command and the remaining words are
3591 the arguments.
3592
3593 </li><li> Redirections are performed as described above (see <a href="#Redirections">Redirections</a>).
3594
3595 </li><li> The text after the &lsquo;<samp>=</samp>&rsquo; in each variable assignment undergoes tilde
3596 expansion, parameter expansion, command substitution, arithmetic expansion,
3597 and quote removal before being assigned to the variable.
3598 </li></ol>
3599
3600 <p>If no command name results, the variable assignments affect the current
3601 shell environment. Otherwise, the variables are added to the environment
3602 of the executed command and do not affect the current shell environment.
3603 If any of the assignments attempts to assign a value to a readonly variable,
3604 an error occurs, and the command exits with a non-zero status.
3605 </p>
3606 <p>If no command name results, redirections are performed, but do not
3607 affect the current shell environment. A redirection error causes the
3608 command to exit with a non-zero status.
3609 </p>
3610 <p>If there is a command name left after expansion, execution proceeds as
3611 described below. Otherwise, the command exits. If one of the expansions
3612 contained a command substitution, the exit status of the command is
3613 the exit status of the last command substitution performed. If there
3614 were no command substitutions, the command exits with a status of zero.
3615 </p>
3616 <hr>
3617 <a name="Command-Search-and-Execution"></a>
3618 <div class="header">
3619 <p>
3620 Next: <a href="#Command-Execution-Environment" accesskey="n" rel="next">Command Execution Environment</a>, Previous: <a href="#Simple-Command-Expansion" accesskey="p" rel="prev">Simple Command Expansion</a>, Up: <a href="#Executing-Commands" accesskey="u" rel="up">Executing Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
3621 </div>
3622 <a name="Command-Search-and-Execution-1"></a>
3623 <h4 class="subsection">3.7.2 Command Search and Execution</h4>
3624 <a name="index-command-execution"></a>
3625 <a name="index-command-search"></a>
3626
3627 <p>After a command has been split into words, if it results in a
3628 simple command and an optional list of arguments, the following
3629 actions are taken.
3630 </p>
3631 <ol>
3632 <li> If the command name contains no slashes, the shell attempts to
3633 locate it. If there exists a shell function by that name, that
3634 function is invoked as described in <a href="#Shell-Functions">Shell Functions</a>.
3635
3636 </li><li> If the name does not match a function, the shell searches for
3637 it in the list of shell builtins. If a match is found, that
3638 builtin is invoked.
3639
3640 </li><li> If the name is neither a shell function nor a builtin,
3641 and contains no slashes, Bash searches each element of
3642 <code>$PATH</code> for a directory containing an executable file
3643 by that name. Bash uses a hash table to remember the full
3644 pathnames of executable files to avoid multiple <code>PATH</code> searches
3645 (see the description of <code>hash</code> in <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
3646 A full search of the directories in <code>$PATH</code>
3647 is performed only if the command is not found in the hash table.
3648 If the search is unsuccessful, the shell searches for a defined shell
3649 function named <code>command_not_found_handle</code>.
3650 If that function exists, it is invoked in a separate execution environment
3651 with the original command and
3652 the original command&rsquo;s arguments as its arguments, and the function&rsquo;s
3653 exit status becomes the exit status of that subshell.
3654 If that function is not defined, the shell prints an error
3655 message and returns an exit status of 127.
3656
3657 </li><li> If the search is successful, or if the command name contains
3658 one or more slashes, the shell executes the named program in
3659 a separate execution environment.
3660 Argument 0 is set to the name given, and the remaining arguments
3661 to the command are set to the arguments supplied, if any.
3662
3663 </li><li> If this execution fails because the file is not in executable
3664 format, and the file is not a directory, it is assumed to be a
3665 <var>shell script</var> and the shell executes it as described in
3666 <a href="#Shell-Scripts">Shell Scripts</a>.
3667
3668 </li><li> If the command was not begun asynchronously, the shell waits for
3669 the command to complete and collects its exit status.
3670
3671 </li></ol>
3672
3673 <hr>
3674 <a name="Command-Execution-Environment"></a>
3675 <div class="header">
3676 <p>
3677 Next: <a href="#Environment" accesskey="n" rel="next">Environment</a>, Previous: <a href="#Command-Search-and-Execution" accesskey="p" rel="prev">Command Search and Execution</a>, Up: <a href="#Executing-Commands" accesskey="u" rel="up">Executing Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
3678 </div>
3679 <a name="Command-Execution-Environment-1"></a>
3680 <h4 class="subsection">3.7.3 Command Execution Environment</h4>
3681 <a name="index-execution-environment"></a>
3682
3683 <p>The shell has an <var>execution environment</var>, which consists of the
3684 following:
3685 </p>
3686 <ul>
3687 <li> open files inherited by the shell at invocation, as modified by
3688 redirections supplied to the <code>exec</code> builtin
3689
3690 </li><li> the current working directory as set by <code>cd</code>, <code>pushd</code>, or
3691 <code>popd</code>, or inherited by the shell at invocation
3692
3693 </li><li> the file creation mode mask as set by <code>umask</code> or inherited from
3694 the shell&rsquo;s parent
3695
3696 </li><li> current traps set by <code>trap</code>
3697
3698 </li><li> shell parameters that are set by variable assignment or with <code>set</code>
3699 or inherited from the shell&rsquo;s parent in the environment
3700
3701 </li><li> shell functions defined during execution or inherited from the shell&rsquo;s
3702 parent in the environment
3703
3704 </li><li> options enabled at invocation (either by default or with command-line
3705 arguments) or by <code>set</code>
3706
3707 </li><li> options enabled by <code>shopt</code> (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>)
3708
3709 </li><li> shell aliases defined with <code>alias</code> (see <a href="#Aliases">Aliases</a>)
3710
3711 </li><li> various process <small>ID</small>s, including those of background jobs
3712 (see <a href="#Lists">Lists</a>), the value of <code>$$</code>, and the value of
3713 <code>$PPID</code>
3714
3715 </li></ul>
3716
3717 <p>When a simple command other than a builtin or shell function
3718 is to be executed, it
3719 is invoked in a separate execution environment that consists of
3720 the following. Unless otherwise noted, the values are inherited
3721 from the shell.
3722 </p>
3723 <ul>
3724 <li> the shell&rsquo;s open files, plus any modifications and additions specified
3725 by redirections to the command
3726
3727 </li><li> the current working directory
3728
3729 </li><li> the file creation mode mask
3730
3731 </li><li> shell variables and functions marked for export, along with variables
3732 exported for the command, passed in the environment (see <a href="#Environment">Environment</a>)
3733
3734 </li><li> traps caught by the shell are reset to the values inherited from the
3735 shell&rsquo;s parent, and traps ignored by the shell are ignored
3736
3737 </li></ul>
3738
3739 <p>A command invoked in this separate environment cannot affect the
3740 shell&rsquo;s execution environment.
3741 </p>
3742 <p>Command substitution, commands grouped with parentheses,
3743 and asynchronous commands are invoked in a
3744 subshell environment that is a duplicate of the shell environment,
3745 except that traps caught by the shell are reset to the values
3746 that the shell inherited from its parent at invocation. Builtin
3747 commands that are invoked as part of a pipeline are also executed
3748 in a subshell environment. Changes made to the subshell environment
3749 cannot affect the shell&rsquo;s execution environment.
3750 </p>
3751 <p>Subshells spawned to execute command substitutions inherit the value of
3752 the <samp>-e</samp> option from the parent shell. When not in <small>POSIX</small> mode,
3753 Bash clears the <samp>-e</samp> option in such subshells.
3754 </p>
3755 <p>If a command is followed by a &lsquo;<samp>&amp;</samp>&rsquo; and job control is not active, the
3756 default standard input for the command is the empty file <samp>/dev/null</samp>.
3757 Otherwise, the invoked command inherits the file descriptors of the calling
3758 shell as modified by redirections.
3759 </p>
3760 <hr>
3761 <a name="Environment"></a>
3762 <div class="header">
3763 <p>
3764 Next: <a href="#Exit-Status" accesskey="n" rel="next">Exit Status</a>, Previous: <a href="#Command-Execution-Environment" accesskey="p" rel="prev">Command Execution Environment</a>, Up: <a href="#Executing-Commands" accesskey="u" rel="up">Executing Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
3765 </div>
3766 <a name="Environment-1"></a>
3767 <h4 class="subsection">3.7.4 Environment</h4>
3768 <a name="index-environment"></a>
3769
3770 <p>When a program is invoked it is given an array of strings
3771 called the <var>environment</var>.
3772 This is a list of name-value pairs, of the form <code>name=value</code>.
3773 </p>
3774 <p>Bash provides several ways to manipulate the environment.
3775 On invocation, the shell scans its own environment and
3776 creates a parameter for each name found, automatically marking
3777 it for <var>export</var>
3778 to child processes. Executed commands inherit the environment.
3779 The <code>export</code> and &lsquo;<samp>declare -x</samp>&rsquo;
3780 commands allow parameters and functions to be added to and
3781 deleted from the environment. If the value of a parameter
3782 in the environment is modified, the new value becomes part
3783 of the environment, replacing the old. The environment
3784 inherited by any executed command consists of the shell&rsquo;s
3785 initial environment, whose values may be modified in the shell,
3786 less any pairs removed by the <code>unset</code> and &lsquo;<samp>export -n</samp>&rsquo;
3787 commands, plus any additions via the <code>export</code> and
3788 &lsquo;<samp>declare -x</samp>&rsquo; commands.
3789 </p>
3790 <p>The environment for any simple command
3791 or function may be augmented temporarily by prefixing it with
3792 parameter assignments, as described in <a href="#Shell-Parameters">Shell Parameters</a>.
3793 These assignment statements affect only the environment seen
3794 by that command.
3795 </p>
3796 <p>If the <samp>-k</samp> option is set (see <a href="#The-Set-Builtin">The Set Builtin</a>), then all
3797 parameter assignments are placed in the environment for a command,
3798 not just those that precede the command name.
3799 </p>
3800 <p>When Bash invokes an external command, the variable &lsquo;<samp>$_</samp>&rsquo;
3801 is set to the full pathname of the command and passed to that
3802 command in its environment.
3803 </p>
3804 <hr>
3805 <a name="Exit-Status"></a>
3806 <div class="header">
3807 <p>
3808 Next: <a href="#Signals" accesskey="n" rel="next">Signals</a>, Previous: <a href="#Environment" accesskey="p" rel="prev">Environment</a>, Up: <a href="#Executing-Commands" accesskey="u" rel="up">Executing Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
3809 </div>
3810 <a name="Exit-Status-1"></a>
3811 <h4 class="subsection">3.7.5 Exit Status</h4>
3812 <a name="index-exit-status-1"></a>
3813
3814 <p>The exit status of an executed command is the value returned by the
3815 <var>waitpid</var> system call or equivalent function. Exit statuses
3816 fall between 0 and 255, though, as explained below, the shell may
3817 use values above 125 specially. Exit statuses from shell builtins and
3818 compound commands are also limited to this range. Under certain
3819 circumstances, the shell will use special values to indicate specific
3820 failure modes.
3821 </p>
3822 <p>For the shell&rsquo;s purposes, a command which exits with a
3823 zero exit status has succeeded.
3824 A non-zero exit status indicates failure.
3825 This seemingly counter-intuitive scheme is used so there
3826 is one well-defined way to indicate success and a variety of
3827 ways to indicate various failure modes.
3828 When a command terminates on a fatal signal whose number is <var>N</var>,
3829 Bash uses the value 128+<var>N</var> as the exit status.
3830 </p>
3831 <p>If a command is not found, the child process created to
3832 execute it returns a status of 127. If a command is found
3833 but is not executable, the return status is 126.
3834 </p>
3835 <p>If a command fails because of an error during expansion or redirection,
3836 the exit status is greater than zero.
3837 </p>
3838 <p>The exit status is used by the Bash conditional commands
3839 (see <a href="#Conditional-Constructs">Conditional Constructs</a>) and some of the list
3840 constructs (see <a href="#Lists">Lists</a>).
3841 </p>
3842 <p>All of the Bash builtins return an exit status of zero if they succeed
3843 and a non-zero status on failure, so they may be used by the
3844 conditional and list constructs.
3845 All builtins return an exit status of 2 to indicate incorrect usage,
3846 generally invalid options or missing arguments.
3847 </p>
3848 <hr>
3849 <a name="Signals"></a>
3850 <div class="header">
3851 <p>
3852 Previous: <a href="#Exit-Status" accesskey="p" rel="prev">Exit Status</a>, Up: <a href="#Executing-Commands" accesskey="u" rel="up">Executing Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
3853 </div>
3854 <a name="Signals-1"></a>
3855 <h4 class="subsection">3.7.6 Signals</h4>
3856 <a name="index-signal-handling"></a>
3857
3858 <p>When Bash is interactive, in the absence of any traps, it ignores
3859 <code>SIGTERM</code> (so that &lsquo;<samp>kill 0</samp>&rsquo; does not kill an interactive shell),
3860 and <code>SIGINT</code>
3861 is caught and handled (so that the <code>wait</code> builtin is interruptible).
3862 When Bash receives a <code>SIGINT</code>, it breaks out of any executing loops.
3863 In all cases, Bash ignores <code>SIGQUIT</code>.
3864 If job control is in effect (see <a href="#Job-Control">Job Control</a>), Bash
3865 ignores <code>SIGTTIN</code>, <code>SIGTTOU</code>, and <code>SIGTSTP</code>.
3866 </p>
3867 <p>Non-builtin commands started by Bash have signal handlers set to the
3868 values inherited by the shell from its parent.
3869 When job control is not in effect, asynchronous commands
3870 ignore <code>SIGINT</code> and <code>SIGQUIT</code> in addition to these inherited
3871 handlers.
3872 Commands run as a result of
3873 command substitution ignore the keyboard-generated job control signals
3874 <code>SIGTTIN</code>, <code>SIGTTOU</code>, and <code>SIGTSTP</code>.
3875 </p>
3876 <p>The shell exits by default upon receipt of a <code>SIGHUP</code>.
3877 Before exiting, an interactive shell resends the <code>SIGHUP</code> to
3878 all jobs, running or stopped.
3879 Stopped jobs are sent <code>SIGCONT</code> to ensure that they receive
3880 the <code>SIGHUP</code>.
3881 To prevent the shell from sending the <code>SIGHUP</code> signal to a
3882 particular job, it should be removed
3883 from the jobs table with the <code>disown</code>
3884 builtin (see <a href="#Job-Control-Builtins">Job Control Builtins</a>) or marked
3885 to not receive <code>SIGHUP</code> using <code>disown -h</code>.
3886 </p>
3887 <p>If the <code>huponexit</code> shell option has been set with <code>shopt</code>
3888 (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), Bash sends a <code>SIGHUP</code> to all jobs when
3889 an interactive login shell exits.
3890 </p>
3891 <p>If Bash is waiting for a command to complete and receives a signal
3892 for which a trap has been set, the trap will not be executed until
3893 the command completes.
3894 When Bash is waiting for an asynchronous
3895 command via the <code>wait</code> builtin, the reception of a signal for
3896 which a trap has been set will cause the <code>wait</code> builtin to return
3897 immediately with an exit status greater than 128, immediately after
3898 which the trap is executed.
3899 </p>
3900 <hr>
3901 <a name="Shell-Scripts"></a>
3902 <div class="header">
3903 <p>
3904 Previous: <a href="#Executing-Commands" accesskey="p" rel="prev">Executing Commands</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
3905 </div>
3906 <a name="Shell-Scripts-1"></a>
3907 <h3 class="section">3.8 Shell Scripts</h3>
3908 <a name="index-shell-script"></a>
3909
3910 <p>A shell script is a text file containing shell commands. When such
3911 a file is used as the first non-option argument when invoking Bash,
3912 and neither the <samp>-c</samp> nor <samp>-s</samp> option is supplied
3913 (see <a href="#Invoking-Bash">Invoking Bash</a>),
3914 Bash reads and executes commands from the file, then exits. This
3915 mode of operation creates a non-interactive shell. The shell first
3916 searches for the file in the current directory, and looks in the
3917 directories in <code>$PATH</code> if not found there.
3918 </p>
3919 <p>When Bash runs
3920 a shell script, it sets the special parameter <code>0</code> to the name
3921 of the file, rather than the name of the shell, and the positional
3922 parameters are set to the remaining arguments, if any are given.
3923 If no additional arguments are supplied, the positional parameters
3924 are unset.
3925 </p>
3926 <p>A shell script may be made executable by using the <code>chmod</code> command
3927 to turn on the execute bit. When Bash finds such a file while
3928 searching the <code>$PATH</code> for a command, it spawns a subshell to
3929 execute it. In other words, executing
3930 </p><div class="example">
3931 <pre class="example">filename <var>arguments</var>
3932 </pre></div>
3933 <p>is equivalent to executing
3934 </p><div class="example">
3935 <pre class="example">bash filename <var>arguments</var>
3936 </pre></div>
3937
3938 <p>if <code>filename</code> is an executable shell script.
3939 This subshell reinitializes itself, so that the effect is as if a
3940 new shell had been invoked to interpret the script, with the
3941 exception that the locations of commands remembered by the parent
3942 (see the description of <code>hash</code> in <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>)
3943 are retained by the child.
3944 </p>
3945 <p>Most versions of Unix make this a part of the operating system&rsquo;s command
3946 execution mechanism. If the first line of a script begins with
3947 the two characters &lsquo;<samp>#!</samp>&rsquo;, the remainder of the line specifies
3948 an interpreter for the program.
3949 Thus, you can specify Bash, <code>awk</code>, Perl, or some other
3950 interpreter and write the rest of the script file in that language.
3951 </p>
3952 <p>The arguments to the interpreter
3953 consist of a single optional argument following the interpreter
3954 name on the first line of the script file, followed by the name of
3955 the script file, followed by the rest of the arguments. Bash
3956 will perform this action on operating systems that do not handle it
3957 themselves. Note that some older versions of Unix limit the interpreter
3958 name and argument to a maximum of 32 characters.
3959 </p>
3960 <p>Bash scripts often begin with <code>#! /bin/bash</code> (assuming that
3961 Bash has been installed in <samp>/bin</samp>), since this ensures that
3962 Bash will be used to interpret the script, even if it is executed
3963 under another shell.
3964 </p>
3965 <hr>
3966 <a name="Shell-Builtin-Commands"></a>
3967 <div class="header">
3968 <p>
3969 Next: <a href="#Shell-Variables" accesskey="n" rel="next">Shell Variables</a>, Previous: <a href="#Basic-Shell-Features" accesskey="p" rel="prev">Basic Shell Features</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
3970 </div>
3971 <a name="Shell-Builtin-Commands-1"></a>
3972 <h2 class="chapter">4 Shell Builtin Commands</h2>
3973
3974 <table class="menu" border="0" cellspacing="0">
3975 <tr><td align="left" valign="top">&bull; <a href="#Bourne-Shell-Builtins" accesskey="1">Bourne Shell Builtins</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Builtin commands inherited from the Bourne
3976 Shell.
3977 </td></tr>
3978 <tr><td align="left" valign="top">&bull; <a href="#Bash-Builtins" accesskey="2">Bash Builtins</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Table of builtins specific to Bash.
3979 </td></tr>
3980 <tr><td align="left" valign="top">&bull; <a href="#Modifying-Shell-Behavior" accesskey="3">Modifying Shell Behavior</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Builtins to modify shell attributes and
3981 optional behavior.
3982 </td></tr>
3983 <tr><td align="left" valign="top">&bull; <a href="#Special-Builtins" accesskey="4">Special Builtins</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Builtin commands classified specially by
3984 POSIX.
3985 </td></tr>
3986 </table>
3987
3988 <p>Builtin commands are contained within the shell itself.
3989 When the name of a builtin command is used as the first word of
3990 a simple command (see <a href="#Simple-Commands">Simple Commands</a>), the shell executes
3991 the command directly, without invoking another program.
3992 Builtin commands are necessary to implement functionality impossible
3993 or inconvenient to obtain with separate utilities.
3994 </p>
3995 <p>This section briefly describes the builtins which Bash inherits from
3996 the Bourne Shell, as well as the builtin commands which are unique
3997 to or have been extended in Bash.
3998 </p>
3999 <p>Several builtin commands are described in other chapters: builtin
4000 commands which provide the Bash interface to the job control
4001 facilities (see <a href="#Job-Control-Builtins">Job Control Builtins</a>), the directory stack
4002 (see <a href="#Directory-Stack-Builtins">Directory Stack Builtins</a>), the command history
4003 (see <a href="#Bash-History-Builtins">Bash History Builtins</a>), and the programmable completion
4004 facilities (see <a href="#Programmable-Completion-Builtins">Programmable Completion Builtins</a>).
4005 </p>
4006 <p>Many of the builtins have been extended by <small>POSIX</small> or Bash.
4007 </p>
4008 <p>Unless otherwise noted, each builtin command documented as accepting
4009 options preceded by &lsquo;<samp>-</samp>&rsquo; accepts &lsquo;<samp>--</samp>&rsquo;
4010 to signify the end of the options.
4011 The <code>:</code>, <code>true</code>, <code>false</code>, and <code>test</code>/<code>[</code>
4012 builtins do not accept options and do not treat &lsquo;<samp>--</samp>&rsquo; specially.
4013 The <code>exit</code>, <code>logout</code>, <code>return</code>,
4014 <code>break</code>, <code>continue</code>, <code>let</code>,
4015 and <code>shift</code> builtins accept and process arguments beginning
4016 with &lsquo;<samp>-</samp>&rsquo; without requiring &lsquo;<samp>--</samp>&rsquo;.
4017 Other builtins that accept arguments but are not specified as accepting
4018 options interpret arguments beginning with &lsquo;<samp>-</samp>&rsquo; as invalid options and
4019 require &lsquo;<samp>--</samp>&rsquo; to prevent this interpretation.
4020 </p>
4021 <hr>
4022 <a name="Bourne-Shell-Builtins"></a>
4023 <div class="header">
4024 <p>
4025 Next: <a href="#Bash-Builtins" accesskey="n" rel="next">Bash Builtins</a>, Up: <a href="#Shell-Builtin-Commands" accesskey="u" rel="up">Shell Builtin Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
4026 </div>
4027 <a name="Bourne-Shell-Builtins-1"></a>
4028 <h3 class="section">4.1 Bourne Shell Builtins</h3>
4029
4030 <p>The following shell builtin commands are inherited from the Bourne Shell.
4031 These commands are implemented as specified by the <small>POSIX</small> standard.
4032 </p>
4033 <dl compact="compact">
4034 <dt><code>: <span class="roman">(a colon)</span></code></dt>
4035 <dd><a name="index-_003a"></a>
4036 <div class="example">
4037 <pre class="example">: [<var>arguments</var>]
4038 </pre></div>
4039
4040 <p>Do nothing beyond expanding <var>arguments</var> and performing redirections.
4041 The return status is zero.
4042 </p>
4043 </dd>
4044 <dt><code>. <span class="roman">(a period)</span></code></dt>
4045 <dd><a name="index-_002e"></a>
4046 <div class="example">
4047 <pre class="example">. <var>filename</var> [<var>arguments</var>]
4048 </pre></div>
4049
4050 <p>Read and execute commands from the <var>filename</var> argument in the
4051 current shell context. If <var>filename</var> does not contain a slash,
4052 the <code>PATH</code> variable is used to find <var>filename</var>.
4053 When Bash is not in <small>POSIX</small> mode, the current directory is searched
4054 if <var>filename</var> is not found in <code>$PATH</code>.
4055 If any <var>arguments</var> are supplied, they become the positional
4056 parameters when <var>filename</var> is executed. Otherwise the positional
4057 parameters are unchanged.
4058 If the <samp>-T</samp> option is enabled, <code>source</code> inherits any trap on
4059 <code>DEBUG</code>; if it is not, any <code>DEBUG</code> trap string is saved and
4060 restored around the call to <code>source</code>, and <code>source</code> unsets the
4061 <code>DEBUG</code> trap while it executes.
4062 If <samp>-T</samp> is not set, and the sourced file changes
4063 the <code>DEBUG</code> trap, the new value is retained when <code>source</code> completes.
4064 The return status is the exit status of the last command executed, or
4065 zero if no commands are executed. If <var>filename</var> is not found, or
4066 cannot be read, the return status is non-zero.
4067 This builtin is equivalent to <code>source</code>.
4068 </p>
4069 </dd>
4070 <dt><code>break</code></dt>
4071 <dd><a name="index-break"></a>
4072 <div class="example">
4073 <pre class="example">break [<var>n</var>]
4074 </pre></div>
4075
4076 <p>Exit from a <code>for</code>, <code>while</code>, <code>until</code>, or <code>select</code> loop.
4077 If <var>n</var> is supplied, the <var>n</var>th enclosing loop is exited.
4078 <var>n</var> must be greater than or equal to 1.
4079 The return status is zero unless <var>n</var> is not greater than or equal to 1.
4080 </p>
4081 </dd>
4082 <dt><code>cd</code></dt>
4083 <dd><a name="index-cd"></a>
4084 <div class="example">
4085 <pre class="example">cd [-L|[-P [-e]] [-@] [<var>directory</var>]
4086 </pre></div>
4087
4088 <p>Change the current working directory to <var>directory</var>.
4089 If <var>directory</var> is not supplied, the value of the <code>HOME</code>
4090 shell variable is used.
4091 Any additional arguments following <var>directory</var> are ignored.
4092 If the shell variable
4093 <code>CDPATH</code> exists, it is used as a search path:
4094 each directory name in <code>CDPATH</code> is searched for
4095 <var>directory</var>, with alternative directory names in <code>CDPATH</code>
4096 separated by a colon (&lsquo;<samp>:</samp>&rsquo;).
4097 If <var>directory</var> begins with a slash, <code>CDPATH</code> is not used.
4098 </p>
4099 <p>The <samp>-P</samp> option means to not follow symbolic links: symbolic links
4100 are resolved while <code>cd</code> is traversing <var>directory</var> and before
4101 processing an instance of &lsquo;<samp>..</samp>&rsquo; in <var>directory</var>.
4102 </p>
4103 <p>By default, or when the <samp>-L</samp> option is supplied, symbolic links
4104 in <var>directory</var> are resolved after <code>cd</code> processes an instance
4105 of &lsquo;<samp>..</samp>&rsquo; in <var>directory</var>.
4106 </p>
4107 <p>If &lsquo;<samp>..</samp>&rsquo; appears in <var>directory</var>, it is processed by removing the
4108 immediately preceding pathname component, back to a slash or the beginning
4109 of <var>directory</var>.
4110 </p>
4111 <p>If the <samp>-e</samp> option is supplied with <samp>-P</samp>
4112 and the current working directory cannot be successfully determined
4113 after a successful directory change, <code>cd</code> will return an unsuccessful
4114 status.
4115 </p>
4116 <p>On systems that support it, the <samp>-@</samp> option presents the extended
4117 attributes associated with a file as a directory.
4118 </p>
4119 <p>If <var>directory</var> is &lsquo;<samp>-</samp>&rsquo;, it is converted to <code>$OLDPWD</code>
4120 before the directory change is attempted.
4121 </p>
4122 <p>If a non-empty directory name from <code>CDPATH</code> is used, or if
4123 &lsquo;<samp>-</samp>&rsquo; is the first argument, and the directory change is
4124 successful, the absolute pathname of the new working directory is
4125 written to the standard output.
4126 </p>
4127 <p>The return status is zero if the directory is successfully changed,
4128 non-zero otherwise.
4129 </p>
4130 </dd>
4131 <dt><code>continue</code></dt>
4132 <dd><a name="index-continue"></a>
4133 <div class="example">
4134 <pre class="example">continue [<var>n</var>]
4135 </pre></div>
4136
4137 <p>Resume the next iteration of an enclosing <code>for</code>, <code>while</code>,
4138 <code>until</code>, or <code>select</code> loop.
4139 If <var>n</var> is supplied, the execution of the <var>n</var>th enclosing loop
4140 is resumed.
4141 <var>n</var> must be greater than or equal to 1.
4142 The return status is zero unless <var>n</var> is not greater than or equal to 1.
4143 </p>
4144 </dd>
4145 <dt><code>eval</code></dt>
4146 <dd><a name="index-eval"></a>
4147 <div class="example">
4148 <pre class="example">eval [<var>arguments</var>]
4149 </pre></div>
4150
4151 <p>The arguments are concatenated together into a single command, which is
4152 then read and executed, and its exit status returned as the exit status
4153 of <code>eval</code>.
4154 If there are no arguments or only empty arguments, the return status is
4155 zero.
4156 </p>
4157 </dd>
4158 <dt><code>exec</code></dt>
4159 <dd><a name="index-exec"></a>
4160 <div class="example">
4161 <pre class="example">exec [-cl] [-a <var>name</var>] [<var>command</var> [<var>arguments</var>]]
4162 </pre></div>
4163
4164 <p>If <var>command</var>
4165 is supplied, it replaces the shell without creating a new process.
4166 If the <samp>-l</samp> option is supplied, the shell places a dash at the
4167 beginning of the zeroth argument passed to <var>command</var>.
4168 This is what the <code>login</code> program does.
4169 The <samp>-c</samp> option causes <var>command</var> to be executed with an empty
4170 environment.
4171 If <samp>-a</samp> is supplied, the shell passes <var>name</var> as the zeroth
4172 argument to <var>command</var>.
4173 If <var>command</var>
4174 cannot be executed for some reason, a non-interactive shell exits,
4175 unless the <code>execfail</code> shell option
4176 is enabled. In that case, it returns failure.
4177 An interactive shell returns failure if the file cannot be executed.
4178 A subshell exits unconditionally if <code>exec</code> fails.
4179 If no <var>command</var> is specified, redirections may be used to affect
4180 the current shell environment. If there are no redirection errors, the
4181 return status is zero; otherwise the return status is non-zero.
4182 </p>
4183 </dd>
4184 <dt><code>exit</code></dt>
4185 <dd><a name="index-exit"></a>
4186 <div class="example">
4187 <pre class="example">exit [<var>n</var>]
4188 </pre></div>
4189
4190 <p>Exit the shell, returning a status of <var>n</var> to the shell&rsquo;s parent.
4191 If <var>n</var> is omitted, the exit status is that of the last command executed.
4192 Any trap on <code>EXIT</code> is executed before the shell terminates.
4193 </p>
4194 </dd>
4195 <dt><code>export</code></dt>
4196 <dd><a name="index-export"></a>
4197 <div class="example">
4198 <pre class="example">export [-fn] [-p] [<var>name</var>[=<var>value</var>]]
4199 </pre></div>
4200
4201 <p>Mark each <var>name</var> to be passed to child processes
4202 in the environment. If the <samp>-f</samp> option is supplied, the <var>name</var>s
4203 refer to shell functions; otherwise the names refer to shell variables.
4204 The <samp>-n</samp> option means to no longer mark each <var>name</var> for export.
4205 If no <var>names</var> are supplied, or if the <samp>-p</samp> option is given, a
4206 list of names of all exported variables is displayed.
4207 The <samp>-p</samp> option displays output in a form that may be reused as input.
4208 If a variable name is followed by =<var>value</var>, the value of
4209 the variable is set to <var>value</var>.
4210 </p>
4211 <p>The return status is zero unless an invalid option is supplied, one of
4212 the names is not a valid shell variable name, or <samp>-f</samp> is supplied
4213 with a name that is not a shell function.
4214 </p>
4215 </dd>
4216 <dt><code>getopts</code></dt>
4217 <dd><a name="index-getopts"></a>
4218 <div class="example">
4219 <pre class="example">getopts <var>optstring</var> <var>name</var> [<var>args</var>]
4220 </pre></div>
4221
4222 <p><code>getopts</code> is used by shell scripts to parse positional parameters.
4223 <var>optstring</var> contains the option characters to be recognized; if a
4224 character is followed by a colon, the option is expected to have an
4225 argument, which should be separated from it by whitespace.
4226 The colon (&lsquo;<samp>:</samp>&rsquo;) and question mark (&lsquo;<samp>?</samp>&rsquo;) may not be
4227 used as option characters.
4228 Each time it is invoked, <code>getopts</code>
4229 places the next option in the shell variable <var>name</var>, initializing
4230 <var>name</var> if it does not exist,
4231 and the index of the next argument to be processed into the
4232 variable <code>OPTIND</code>.
4233 <code>OPTIND</code> is initialized to 1 each time the shell or a shell script
4234 is invoked.
4235 When an option requires an argument,
4236 <code>getopts</code> places that argument into the variable <code>OPTARG</code>.
4237 The shell does not reset <code>OPTIND</code> automatically; it must be manually
4238 reset between multiple calls to <code>getopts</code> within the same shell
4239 invocation if a new set of parameters is to be used.
4240 </p>
4241 <p>When the end of options is encountered, <code>getopts</code> exits with a
4242 return value greater than zero.
4243 <code>OPTIND</code> is set to the index of the first non-option argument,
4244 and <var>name</var> is set to &lsquo;<samp>?</samp>&rsquo;.
4245 </p>
4246 <p><code>getopts</code>
4247 normally parses the positional parameters, but if more arguments are
4248 given in <var>args</var>, <code>getopts</code> parses those instead.
4249 </p>
4250 <p><code>getopts</code> can report errors in two ways. If the first character of
4251 <var>optstring</var> is a colon, <var>silent</var>
4252 error reporting is used. In normal operation, diagnostic messages
4253 are printed when invalid options or missing option arguments are
4254 encountered.
4255 If the variable <code>OPTERR</code>
4256 is set to 0, no error messages will be displayed, even if the first
4257 character of <code>optstring</code> is not a colon.
4258 </p>
4259 <p>If an invalid option is seen,
4260 <code>getopts</code> places &lsquo;<samp>?</samp>&rsquo; into <var>name</var> and, if not silent,
4261 prints an error message and unsets <code>OPTARG</code>.
4262 If <code>getopts</code> is silent, the option character found is placed in
4263 <code>OPTARG</code> and no diagnostic message is printed.
4264 </p>
4265 <p>If a required argument is not found, and <code>getopts</code>
4266 is not silent, a question mark (&lsquo;<samp>?</samp>&rsquo;) is placed in <var>name</var>,
4267 <code>OPTARG</code> is unset, and a diagnostic message is printed.
4268 If <code>getopts</code> is silent, then a colon (&lsquo;<samp>:</samp>&rsquo;) is placed in
4269 <var>name</var> and <code>OPTARG</code> is set to the option character found.
4270 </p>
4271 </dd>
4272 <dt><code>hash</code></dt>
4273 <dd><a name="index-hash"></a>
4274 <div class="example">
4275 <pre class="example">hash [-r] [-p <var>filename</var>] [-dt] [<var>name</var>]
4276 </pre></div>
4277
4278 <p>Each time <code>hash</code> is invoked, it remembers the full pathnames of the
4279 commands specified as <var>name</var> arguments,
4280 so they need not be searched for on subsequent invocations.
4281 The commands are found by searching through the directories listed in
4282 <code>$PATH</code>.
4283 Any previously-remembered pathname is discarded.
4284 The <samp>-p</samp> option inhibits the path search, and <var>filename</var> is
4285 used as the location of <var>name</var>.
4286 The <samp>-r</samp> option causes the shell to forget all remembered locations.
4287 The <samp>-d</samp> option causes the shell to forget the remembered location
4288 of each <var>name</var>.
4289 If the <samp>-t</samp> option is supplied, the full pathname to which each
4290 <var>name</var> corresponds is printed. If multiple <var>name</var> arguments are
4291 supplied with <samp>-t</samp>, the <var>name</var> is printed before the hashed
4292 full pathname.
4293 The <samp>-l</samp> option causes output to be displayed in a format
4294 that may be reused as input.
4295 If no arguments are given, or if only <samp>-l</samp> is supplied,
4296 information about remembered commands is printed.
4297 The return status is zero unless a <var>name</var> is not found or an invalid
4298 option is supplied.
4299 </p>
4300 </dd>
4301 <dt><code>pwd</code></dt>
4302 <dd><a name="index-pwd"></a>
4303 <div class="example">
4304 <pre class="example">pwd [-LP]
4305 </pre></div>
4306
4307 <p>Print the absolute pathname of the current working directory.
4308 If the <samp>-P</samp> option is supplied, the pathname printed will not
4309 contain symbolic links.
4310 If the <samp>-L</samp> option is supplied, the pathname printed may contain
4311 symbolic links.
4312 The return status is zero unless an error is encountered while
4313 determining the name of the current directory or an invalid option
4314 is supplied.
4315 </p>
4316 </dd>
4317 <dt><code>readonly</code></dt>
4318 <dd><a name="index-readonly"></a>
4319 <div class="example">
4320 <pre class="example">readonly [-aAf] [-p] [<var>name</var>[=<var>value</var>]] &hellip;
4321 </pre></div>
4322
4323 <p>Mark each <var>name</var> as readonly.
4324 The values of these names may not be changed by subsequent assignment.
4325 If the <samp>-f</samp> option is supplied, each <var>name</var> refers to a shell
4326 function.
4327 The <samp>-a</samp> option means each <var>name</var> refers to an indexed
4328 array variable; the <samp>-A</samp> option means each <var>name</var> refers
4329 to an associative array variable.
4330 If both options are supplied, <samp>-A</samp> takes precedence.
4331 If no <var>name</var> arguments are given, or if the <samp>-p</samp>
4332 option is supplied, a list of all readonly names is printed.
4333 The other options may be used to restrict the output to a subset of
4334 the set of readonly names.
4335 The <samp>-p</samp> option causes output to be displayed in a format that
4336 may be reused as input.
4337 If a variable name is followed by =<var>value</var>, the value of
4338 the variable is set to <var>value</var>.
4339 The return status is zero unless an invalid option is supplied, one of
4340 the <var>name</var> arguments is not a valid shell variable or function name,
4341 or the <samp>-f</samp> option is supplied with a name that is not a shell function.
4342 </p>
4343 </dd>
4344 <dt><code>return</code></dt>
4345 <dd><a name="index-return"></a>
4346 <div class="example">
4347 <pre class="example">return [<var>n</var>]
4348 </pre></div>
4349
4350 <p>Cause a shell function to stop executing and return the value <var>n</var>
4351 to its caller.
4352 If <var>n</var> is not supplied, the return value is the exit status of the
4353 last command executed in the function.
4354 If <code>return</code> is executed by a trap handler, the last command used to
4355 determine the status is the last command executed before the trap handler.
4356 If <code>return</code> is executed during a <code>DEBUG</code> trap, the last command
4357 used to determine the status is the last command executed by the trap
4358 handler before <code>return</code> was invoked.
4359 <code>return</code> may also be used to terminate execution of a script
4360 being executed with the <code>.</code> (<code>source</code>) builtin,
4361 returning either <var>n</var> or
4362 the exit status of the last command executed within the script as the exit
4363 status of the script.
4364 If <var>n</var> is supplied, the return value is its least significant
4365 8 bits.
4366 Any command associated with the <code>RETURN</code> trap is executed
4367 before execution resumes after the function or script.
4368 The return status is non-zero if <code>return</code> is supplied a non-numeric
4369 argument or is used outside a function
4370 and not during the execution of a script by <code>.</code> or <code>source</code>.
4371 </p>
4372 </dd>
4373 <dt><code>shift</code></dt>
4374 <dd><a name="index-shift"></a>
4375 <div class="example">
4376 <pre class="example">shift [<var>n</var>]
4377 </pre></div>
4378
4379 <p>Shift the positional parameters to the left by <var>n</var>.
4380 The positional parameters from <var>n</var>+1 &hellip; <code>$#</code> are
4381 renamed to <code>$1</code> &hellip; <code>$#</code>-<var>n</var>.
4382 Parameters represented by the numbers <code>$#</code> to <code>$#</code>-<var>n</var>+1
4383 are unset.
4384 <var>n</var> must be a non-negative number less than or equal to <code>$#</code>.
4385 If <var>n</var> is zero or greater than <code>$#</code>, the positional parameters
4386 are not changed.
4387 If <var>n</var> is not supplied, it is assumed to be 1.
4388 The return status is zero unless <var>n</var> is greater than <code>$#</code> or
4389 less than zero, non-zero otherwise.
4390 </p>
4391 </dd>
4392 <dt><code>test</code></dt>
4393 <dt><code>[</code></dt>
4394 <dd><a name="index-test"></a>
4395 <a name="index-_005b"></a>
4396 <div class="example">
4397 <pre class="example">test <var>expr</var>
4398 </pre></div>
4399
4400 <p>Evaluate a conditional expression <var>expr</var> and return a status of 0
4401 (true) or 1 (false).
4402 Each operator and operand must be a separate argument.
4403 Expressions are composed of the primaries described below in
4404 <a href="#Bash-Conditional-Expressions">Bash Conditional Expressions</a>.
4405 <code>test</code> does not accept any options, nor does it accept and ignore
4406 an argument of <samp>--</samp> as signifying the end of options.
4407 </p>
4408 <p>When the <code>[</code> form is used, the last argument to the command must
4409 be a <code>]</code>.
4410 </p>
4411 <p>Expressions may be combined using the following operators, listed in
4412 decreasing order of precedence.
4413 The evaluation depends on the number of arguments; see below.
4414 Operator precedence is used when there are five or more arguments.
4415 </p>
4416 <dl compact="compact">
4417 <dt><code>! <var>expr</var></code></dt>
4418 <dd><p>True if <var>expr</var> is false.
4419 </p>
4420 </dd>
4421 <dt><code>( <var>expr</var> )</code></dt>
4422 <dd><p>Returns the value of <var>expr</var>.
4423 This may be used to override the normal precedence of operators.
4424 </p>
4425 </dd>
4426 <dt><code><var>expr1</var> -a <var>expr2</var></code></dt>
4427 <dd><p>True if both <var>expr1</var> and <var>expr2</var> are true.
4428 </p>
4429 </dd>
4430 <dt><code><var>expr1</var> -o <var>expr2</var></code></dt>
4431 <dd><p>True if either <var>expr1</var> or <var>expr2</var> is true.
4432 </p></dd>
4433 </dl>
4434
4435 <p>The <code>test</code> and <code>[</code> builtins evaluate conditional
4436 expressions using a set of rules based on the number of arguments.
4437 </p>
4438 <dl compact="compact">
4439 <dt>0 arguments</dt>
4440 <dd><p>The expression is false.
4441 </p>
4442 </dd>
4443 <dt>1 argument</dt>
4444 <dd><p>The expression is true if, and only if, the argument is not null.
4445 </p>
4446 </dd>
4447 <dt>2 arguments</dt>
4448 <dd><p>If the first argument is &lsquo;<samp>!</samp>&rsquo;, the expression is true if and
4449 only if the second argument is null.
4450 If the first argument is one of the unary conditional operators
4451 (see <a href="#Bash-Conditional-Expressions">Bash Conditional Expressions</a>), the expression
4452 is true if the unary test is true.
4453 If the first argument is not a valid unary operator, the expression is
4454 false.
4455 </p>
4456 </dd>
4457 <dt>3 arguments</dt>
4458 <dd><p>The following conditions are applied in the order listed.
4459 </p>
4460 <ol>
4461 <li> If the second argument is one of the binary conditional
4462 operators (see <a href="#Bash-Conditional-Expressions">Bash Conditional Expressions</a>), the
4463 result of the expression is the result of the binary test using the
4464 first and third arguments as operands.
4465 The &lsquo;<samp>-a</samp>&rsquo; and &lsquo;<samp>-o</samp>&rsquo; operators are considered binary operators
4466 when there are three arguments.
4467 </li><li> If the first argument is &lsquo;<samp>!</samp>&rsquo;, the value is the negation of
4468 the two-argument test using the second and third arguments.
4469 </li><li> If the first argument is exactly &lsquo;<samp>(</samp>&rsquo; and the third argument is
4470 exactly &lsquo;<samp>)</samp>&rsquo;, the result is the one-argument test of the second
4471 argument.
4472 </li><li> Otherwise, the expression is false.
4473 </li></ol>
4474
4475 </dd>
4476 <dt>4 arguments</dt>
4477 <dd><p>If the first argument is &lsquo;<samp>!</samp>&rsquo;, the result is the negation of
4478 the three-argument expression composed of the remaining arguments.
4479 Otherwise, the expression is parsed and evaluated according to
4480 precedence using the rules listed above.
4481 </p>
4482 </dd>
4483 <dt>5 or more arguments</dt>
4484 <dd><p>The expression is parsed and evaluated according to precedence
4485 using the rules listed above.
4486 </p></dd>
4487 </dl>
4488
4489 <p>When used with <code>test</code> or &lsquo;<samp>[</samp>&rsquo;, the &lsquo;<samp>&lt;</samp>&rsquo; and &lsquo;<samp>&gt;</samp>&rsquo;
4490 operators sort lexicographically using ASCII ordering.
4491 </p>
4492 </dd>
4493 <dt><code>times</code></dt>
4494 <dd><a name="index-times"></a>
4495 <div class="example">
4496 <pre class="example">times
4497 </pre></div>
4498
4499 <p>Print out the user and system times used by the shell and its children.
4500 The return status is zero.
4501 </p>
4502 </dd>
4503 <dt><code>trap</code></dt>
4504 <dd><a name="index-trap"></a>
4505 <div class="example">
4506 <pre class="example">trap [-lp] [<var>arg</var>] [<var>sigspec</var> &hellip;]
4507 </pre></div>
4508
4509 <p>The commands in <var>arg</var> are to be read and executed when the
4510 shell receives signal <var>sigspec</var>. If <var>arg</var> is absent (and
4511 there is a single <var>sigspec</var>) or
4512 equal to &lsquo;<samp>-</samp>&rsquo;, each specified signal&rsquo;s disposition is reset
4513 to the value it had when the shell was started.
4514 If <var>arg</var> is the null string, then the signal specified by
4515 each <var>sigspec</var> is ignored by the shell and commands it invokes.
4516 If <var>arg</var> is not present and <samp>-p</samp> has been supplied,
4517 the shell displays the trap commands associated with each <var>sigspec</var>.
4518 If no arguments are supplied, or
4519 only <samp>-p</samp> is given, <code>trap</code> prints the list of commands
4520 associated with each signal number in a form that may be reused as
4521 shell input.
4522 The <samp>-l</samp> option causes the shell to print a list of signal names
4523 and their corresponding numbers.
4524 Each <var>sigspec</var> is either a signal name or a signal number.
4525 Signal names are case insensitive and the <code>SIG</code> prefix is optional.
4526 </p>
4527 <p>If a <var>sigspec</var>
4528 is <code>0</code> or <code>EXIT</code>, <var>arg</var> is executed when the shell exits.
4529 If a <var>sigspec</var> is <code>DEBUG</code>, the command <var>arg</var> is executed
4530 before every simple command, <code>for</code> command, <code>case</code> command,
4531 <code>select</code> command, every arithmetic <code>for</code> command, and before
4532 the first command executes in a shell function.
4533 Refer to the description of the <code>extdebug</code> option to the
4534 <code>shopt</code> builtin (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>) for details of its
4535 effect on the <code>DEBUG</code> trap.
4536 If a <var>sigspec</var> is <code>RETURN</code>, the command <var>arg</var> is executed
4537 each time a shell function or a script executed with the <code>.</code> or
4538 <code>source</code> builtins finishes executing.
4539 </p>
4540 <p>If a <var>sigspec</var> is <code>ERR</code>, the command <var>arg</var>
4541 is executed whenever
4542 a pipeline (which may consist of a single simple
4543 command), a list, or a compound command returns a
4544 non-zero exit status,
4545 subject to the following conditions.
4546 The <code>ERR</code> trap is not executed if the failed command is part of the
4547 command list immediately following an <code>until</code> or <code>while</code> keyword,
4548 part of the test following the <code>if</code> or <code>elif</code> reserved words,
4549 part of a command executed in a <code>&amp;&amp;</code> or <code>||</code> list
4550 except the command following the final <code>&amp;&amp;</code> or <code>||</code>,
4551 any command in a pipeline but the last,
4552 or if the command&rsquo;s return
4553 status is being inverted using <code>!</code>.
4554 These are the same conditions obeyed by the <code>errexit</code> (<samp>-e</samp>)
4555 option.
4556 </p>
4557 <p>Signals ignored upon entry to the shell cannot be trapped or reset.
4558 Trapped signals that are not being ignored are reset to their original
4559 values in a subshell or subshell environment when one is created.
4560 </p>
4561 <p>The return status is zero unless a <var>sigspec</var> does not specify a
4562 valid signal.
4563 </p>
4564 </dd>
4565 <dt><code>umask</code></dt>
4566 <dd><a name="index-umask"></a>
4567 <div class="example">
4568 <pre class="example">umask [-p] [-S] [<var>mode</var>]
4569 </pre></div>
4570
4571 <p>Set the shell process&rsquo;s file creation mask to <var>mode</var>. If
4572 <var>mode</var> begins with a digit, it is interpreted as an octal number;
4573 if not, it is interpreted as a symbolic mode mask similar
4574 to that accepted by the <code>chmod</code> command. If <var>mode</var> is
4575 omitted, the current value of the mask is printed. If the <samp>-S</samp>
4576 option is supplied without a <var>mode</var> argument, the mask is printed
4577 in a symbolic format.
4578 If the <samp>-p</samp> option is supplied, and <var>mode</var>
4579 is omitted, the output is in a form that may be reused as input.
4580 The return status is zero if the mode is successfully changed or if
4581 no <var>mode</var> argument is supplied, and non-zero otherwise.
4582 </p>
4583 <p>Note that when the mode is interpreted as an octal number, each number
4584 of the umask is subtracted from <code>7</code>. Thus, a umask of <code>022</code>
4585 results in permissions of <code>755</code>.
4586 </p>
4587 </dd>
4588 <dt><code>unset</code></dt>
4589 <dd><a name="index-unset"></a>
4590 <div class="example">
4591 <pre class="example">unset [-fnv] [<var>name</var>]
4592 </pre></div>
4593
4594 <p>Remove each variable or function <var>name</var>.
4595 If the <samp>-v</samp> option is given, each
4596 <var>name</var> refers to a shell variable and that variable is removed.
4597 If the <samp>-f</samp> option is given, the <var>name</var>s refer to shell
4598 functions, and the function definition is removed.
4599 If the <samp>-n</samp> option is supplied, and <var>name</var> is a variable with
4600 the <var>nameref</var> attribute, <var>name</var> will be unset rather than the
4601 variable it references.
4602 <samp>-n</samp> has no effect if the <samp>-f</samp> option is supplied.
4603 If no options are supplied, each <var>name</var> refers to a variable; if
4604 there is no variable by that name, any function with that name is
4605 unset.
4606 Readonly variables and functions may not be unset.
4607 The return status is zero unless a <var>name</var> is readonly.
4608 </p></dd>
4609 </dl>
4610
4611 <hr>
4612 <a name="Bash-Builtins"></a>
4613 <div class="header">
4614 <p>
4615 Next: <a href="#Modifying-Shell-Behavior" accesskey="n" rel="next">Modifying Shell Behavior</a>, Previous: <a href="#Bourne-Shell-Builtins" accesskey="p" rel="prev">Bourne Shell Builtins</a>, Up: <a href="#Shell-Builtin-Commands" accesskey="u" rel="up">Shell Builtin Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
4616 </div>
4617 <a name="Bash-Builtin-Commands"></a>
4618 <h3 class="section">4.2 Bash Builtin Commands</h3>
4619
4620 <p>This section describes builtin commands which are unique to
4621 or have been extended in Bash.
4622 Some of these commands are specified in the <small>POSIX</small> standard.
4623 </p>
4624 <dl compact="compact">
4625 <dt><code>alias</code></dt>
4626 <dd><a name="index-alias"></a>
4627 <div class="example">
4628 <pre class="example">alias [-p] [<var>name</var>[=<var>value</var>] &hellip;]
4629 </pre></div>
4630
4631 <p>Without arguments or with the <samp>-p</samp> option, <code>alias</code> prints
4632 the list of aliases on the standard output in a form that allows
4633 them to be reused as input.
4634 If arguments are supplied, an alias is defined for each <var>name</var>
4635 whose <var>value</var> is given. If no <var>value</var> is given, the name
4636 and value of the alias is printed.
4637 Aliases are described in <a href="#Aliases">Aliases</a>.
4638 </p>
4639 </dd>
4640 <dt><code>bind</code></dt>
4641 <dd><a name="index-bind"></a>
4642 <div class="example">
4643 <pre class="example">bind [-m <var>keymap</var>] [-lpsvPSVX]
4644 bind [-m <var>keymap</var>] [-q <var>function</var>] [-u <var>function</var>] [-r <var>keyseq</var>]
4645 bind [-m <var>keymap</var>] -f <var>filename</var>
4646 bind [-m <var>keymap</var>] -x <var>keyseq:shell-command</var>
4647 bind [-m <var>keymap</var>] <var>keyseq:function-name</var>
4648 bind [-m <var>keymap</var>] <var>keyseq:readline-command</var>
4649 </pre></div>
4650
4651 <p>Display current Readline (see <a href="#Command-Line-Editing">Command Line Editing</a>)
4652 key and function bindings,
4653 bind a key sequence to a Readline function or macro,
4654 or set a Readline variable.
4655 Each non-option argument is a command as it would appear in a
4656 Readline initialization file (see <a href="#Readline-Init-File">Readline Init File</a>),
4657 but each binding or command must be passed as a separate argument; e.g.,
4658 &lsquo;<samp>&quot;\C-x\C-r&quot;:re-read-init-file</samp>&rsquo;.
4659 </p>
4660 <p>Options, if supplied, have the following meanings:
4661 </p>
4662 <dl compact="compact">
4663 <dt><code>-m <var>keymap</var></code></dt>
4664 <dd><p>Use <var>keymap</var> as the keymap to be affected by
4665 the subsequent bindings. Acceptable <var>keymap</var>
4666 names are
4667 <code>emacs</code>,
4668 <code>emacs-standard</code>,
4669 <code>emacs-meta</code>,
4670 <code>emacs-ctlx</code>,
4671 <code>vi</code>,
4672 <code>vi-move</code>,
4673 <code>vi-command</code>, and
4674 <code>vi-insert</code>.
4675 <code>vi</code> is equivalent to <code>vi-command</code> (<code>vi-move</code> is also a
4676 synonym); <code>emacs</code> is equivalent to <code>emacs-standard</code>.
4677 </p>
4678 </dd>
4679 <dt><code>-l</code></dt>
4680 <dd><p>List the names of all Readline functions.
4681 </p>
4682 </dd>
4683 <dt><code>-p</code></dt>
4684 <dd><p>Display Readline function names and bindings in such a way that they
4685 can be used as input or in a Readline initialization file.
4686 </p>
4687 </dd>
4688 <dt><code>-P</code></dt>
4689 <dd><p>List current Readline function names and bindings.
4690 </p>
4691 </dd>
4692 <dt><code>-v</code></dt>
4693 <dd><p>Display Readline variable names and values in such a way that they
4694 can be used as input or in a Readline initialization file.
4695 </p>
4696 </dd>
4697 <dt><code>-V</code></dt>
4698 <dd><p>List current Readline variable names and values.
4699 </p>
4700 </dd>
4701 <dt><code>-s</code></dt>
4702 <dd><p>Display Readline key sequences bound to macros and the strings they output
4703 in such a way that they can be used as input or in a Readline
4704 initialization file.
4705 </p>
4706 </dd>
4707 <dt><code>-S</code></dt>
4708 <dd><p>Display Readline key sequences bound to macros and the strings they output.
4709 </p>
4710 </dd>
4711 <dt><code>-f <var>filename</var></code></dt>
4712 <dd><p>Read key bindings from <var>filename</var>.
4713 </p>
4714 </dd>
4715 <dt><code>-q <var>function</var></code></dt>
4716 <dd><p>Query about which keys invoke the named <var>function</var>.
4717 </p>
4718 </dd>
4719 <dt><code>-u <var>function</var></code></dt>
4720 <dd><p>Unbind all keys bound to the named <var>function</var>.
4721 </p>
4722 </dd>
4723 <dt><code>-r <var>keyseq</var></code></dt>
4724 <dd><p>Remove any current binding for <var>keyseq</var>.
4725 </p>
4726 </dd>
4727 <dt><code>-x <var>keyseq:shell-command</var></code></dt>
4728 <dd><p>Cause <var>shell-command</var> to be executed whenever <var>keyseq</var> is
4729 entered.
4730 When <var>shell-command</var> is executed, the shell sets the
4731 <code>READLINE_LINE</code> variable to the contents of the Readline line
4732 buffer and the <code>READLINE_POINT</code> variable to the current location
4733 of the insertion point.
4734 If the executed command changes the value of <code>READLINE_LINE</code> or
4735 <code>READLINE_POINT</code>, those new values will be reflected in the
4736 editing state.
4737 </p>
4738 </dd>
4739 <dt><code>-X</code></dt>
4740 <dd><p>List all key sequences bound to shell commands and the associated commands
4741 in a format that can be reused as input.
4742 </p></dd>
4743 </dl>
4744
4745 <p>The return status is zero unless an invalid option is supplied or an
4746 error occurs.
4747 </p>
4748 </dd>
4749 <dt><code>builtin</code></dt>
4750 <dd><a name="index-builtin"></a>
4751 <div class="example">
4752 <pre class="example">builtin [<var>shell-builtin</var> [<var>args</var>]]
4753 </pre></div>
4754
4755 <p>Run a shell builtin, passing it <var>args</var>, and return its exit status.
4756 This is useful when defining a shell function with the same
4757 name as a shell builtin, retaining the functionality of the builtin within
4758 the function.
4759 The return status is non-zero if <var>shell-builtin</var> is not a shell
4760 builtin command.
4761 </p>
4762 </dd>
4763 <dt><code>caller</code></dt>
4764 <dd><a name="index-caller"></a>
4765 <div class="example">
4766 <pre class="example">caller [<var>expr</var>]
4767 </pre></div>
4768
4769 <p>Returns the context of any active subroutine call (a shell function or
4770 a script executed with the <code>.</code> or <code>source</code> builtins).
4771 </p>
4772 <p>Without <var>expr</var>, <code>caller</code> displays the line number and source
4773 filename of the current subroutine call.
4774 If a non-negative integer is supplied as <var>expr</var>, <code>caller</code>
4775 displays the line number, subroutine name, and source file corresponding
4776 to that position in the current execution call stack. This extra
4777 information may be used, for example, to print a stack trace. The
4778 current frame is frame 0.
4779 </p>
4780 <p>The return value is 0 unless the shell is not executing a subroutine
4781 call or <var>expr</var> does not correspond to a valid position in the
4782 call stack.
4783 </p>
4784 </dd>
4785 <dt><code>command</code></dt>
4786 <dd><a name="index-command"></a>
4787 <div class="example">
4788 <pre class="example">command [-pVv] <var>command</var> [<var>arguments</var> &hellip;]
4789 </pre></div>
4790
4791 <p>Runs <var>command</var> with <var>arguments</var> ignoring any shell function
4792 named <var>command</var>.
4793 Only shell builtin commands or commands found by searching the
4794 <code>PATH</code> are executed.
4795 If there is a shell function named <code>ls</code>, running &lsquo;<samp>command ls</samp>&rsquo;
4796 within the function will execute the external command <code>ls</code>
4797 instead of calling the function recursively.
4798 The <samp>-p</samp> option means to use a default value for <code>PATH</code>
4799 that is guaranteed to find all of the standard utilities.
4800 The return status in this case is 127 if <var>command</var> cannot be
4801 found or an error occurred, and the exit status of <var>command</var>
4802 otherwise.
4803 </p>
4804 <p>If either the <samp>-V</samp> or <samp>-v</samp> option is supplied, a
4805 description of <var>command</var> is printed. The <samp>-v</samp> option
4806 causes a single word indicating the command or file name used to
4807 invoke <var>command</var> to be displayed; the <samp>-V</samp> option produces
4808 a more verbose description. In this case, the return status is
4809 zero if <var>command</var> is found, and non-zero if not.
4810 </p>
4811 </dd>
4812 <dt><code>declare</code></dt>
4813 <dd><a name="index-declare"></a>
4814 <div class="example">
4815 <pre class="example">declare [-aAfFgilnrtux] [-p] [<var>name</var>[=<var>value</var>] &hellip;]
4816 </pre></div>
4817
4818 <p>Declare variables and give them attributes. If no <var>name</var>s
4819 are given, then display the values of variables instead.
4820 </p>
4821 <p>The <samp>-p</samp> option will display the attributes and values of each
4822 <var>name</var>.
4823 When <samp>-p</samp> is used with <var>name</var> arguments, additional options,
4824 other than <samp>-f</samp> and <samp>-F</samp>, are ignored.
4825 </p>
4826 <p>When <samp>-p</samp> is supplied without <var>name</var> arguments, <code>declare</code>
4827 will display the attributes and values of all variables having the
4828 attributes specified by the additional options.
4829 If no other options are supplied with <samp>-p</samp>, <code>declare</code> will
4830 display the attributes and values of all shell variables. The <samp>-f</samp>
4831 option will restrict the display to shell functions.
4832 </p>
4833 <p>The <samp>-F</samp> option inhibits the display of function definitions;
4834 only the function name and attributes are printed.
4835 If the <code>extdebug</code> shell option is enabled using <code>shopt</code>
4836 (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), the source file name and line number where
4837 each <var>name</var> is defined are displayed as well.
4838 <samp>-F</samp> implies <samp>-f</samp>.
4839 </p>
4840 <p>The <samp>-g</samp> option forces variables to be created or modified at
4841 the global scope, even when <code>declare</code> is executed in a shell function.
4842 It is ignored in all other cases.
4843 </p>
4844 <p>The following options can be used to restrict output to variables with
4845 the specified attributes or to give variables attributes:
4846 </p>
4847 <dl compact="compact">
4848 <dt><code>-a</code></dt>
4849 <dd><p>Each <var>name</var> is an indexed array variable (see <a href="#Arrays">Arrays</a>).
4850 </p>
4851 </dd>
4852 <dt><code>-A</code></dt>
4853 <dd><p>Each <var>name</var> is an associative array variable (see <a href="#Arrays">Arrays</a>).
4854 </p>
4855 </dd>
4856 <dt><code>-f</code></dt>
4857 <dd><p>Use function names only.
4858 </p>
4859 </dd>
4860 <dt><code>-i</code></dt>
4861 <dd><p>The variable is to be treated as
4862 an integer; arithmetic evaluation (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>) is
4863 performed when the variable is assigned a value.
4864 </p>
4865 </dd>
4866 <dt><code>-l</code></dt>
4867 <dd><p>When the variable is assigned a value, all upper-case characters are
4868 converted to lower-case.
4869 The upper-case attribute is disabled.
4870 </p>
4871 </dd>
4872 <dt><code>-n</code></dt>
4873 <dd><p>Give each <var>name</var> the <var>nameref</var> attribute, making
4874 it a name reference to another variable.
4875 That other variable is defined by the value of <var>name</var>.
4876 All references, assignments, and attribute modifications
4877 to <var>name</var>, except for those using or changing the
4878 <samp>-n</samp> attribute itself, are performed on the variable referenced by
4879 <var>name</var>&rsquo;s value.
4880 The nameref attribute cannot be applied to array variables.
4881 </p>
4882 </dd>
4883 <dt><code>-r</code></dt>
4884 <dd><p>Make <var>name</var>s readonly. These names cannot then be assigned values
4885 by subsequent assignment statements or unset.
4886 </p>
4887 </dd>
4888 <dt><code>-t</code></dt>
4889 <dd><p>Give each <var>name</var> the <code>trace</code> attribute.
4890 Traced functions inherit the <code>DEBUG</code> and <code>RETURN</code> traps from
4891 the calling shell.
4892 The trace attribute has no special meaning for variables.
4893 </p>
4894 </dd>
4895 <dt><code>-u</code></dt>
4896 <dd><p>When the variable is assigned a value, all lower-case characters are
4897 converted to upper-case.
4898 The lower-case attribute is disabled.
4899 </p>
4900 </dd>
4901 <dt><code>-x</code></dt>
4902 <dd><p>Mark each <var>name</var> for export to subsequent commands via
4903 the environment.
4904 </p></dd>
4905 </dl>
4906
4907 <p>Using &lsquo;<samp>+</samp>&rsquo; instead of &lsquo;<samp>-</samp>&rsquo; turns off the attribute instead,
4908 with the exceptions that &lsquo;<samp>+a</samp>&rsquo; and &lsquo;<samp>+A</samp>&rsquo;
4909 may not be used to destroy array variables and &lsquo;<samp>+r</samp>&rsquo; will not
4910 remove the readonly attribute.
4911 When used in a function, <code>declare</code> makes each <var>name</var> local,
4912 as with the <code>local</code> command, unless the <samp>-g</samp> option is used.
4913 If a variable name is followed by =<var>value</var>, the value of the variable
4914 is set to <var>value</var>.
4915 </p>
4916 <p>When using <samp>-a</samp> or <samp>-A</samp> and the compound assignment syntax to
4917 create array variables, additional attributes do not take effect until
4918 subsequent assignments.
4919 </p>
4920 <p>The return status is zero unless an invalid option is encountered,
4921 an attempt is made to define a function using &lsquo;<samp>-f foo=bar</samp>&rsquo;,
4922 an attempt is made to assign a value to a readonly variable,
4923 an attempt is made to assign a value to an array variable without
4924 using the compound assignment syntax (see <a href="#Arrays">Arrays</a>),
4925 one of the <var>names</var> is not a valid shell variable name,
4926 an attempt is made to turn off readonly status for a readonly variable,
4927 an attempt is made to turn off array status for an array variable,
4928 or an attempt is made to display a non-existent function with <samp>-f</samp>.
4929 </p>
4930 </dd>
4931 <dt><code>echo</code></dt>
4932 <dd><a name="index-echo"></a>
4933 <div class="example">
4934 <pre class="example">echo [-neE] [<var>arg</var> &hellip;]
4935 </pre></div>
4936
4937 <p>Output the <var>arg</var>s, separated by spaces, terminated with a
4938 newline.
4939 The return status is 0 unless a write error occurs.
4940 If <samp>-n</samp> is specified, the trailing newline is suppressed.
4941 If the <samp>-e</samp> option is given, interpretation of the following
4942 backslash-escaped characters is enabled.
4943 The <samp>-E</samp> option disables the interpretation of these escape characters,
4944 even on systems where they are interpreted by default.
4945 The <code>xpg_echo</code> shell option may be used to
4946 dynamically determine whether or not <code>echo</code> expands these
4947 escape characters by default.
4948 <code>echo</code> does not interpret <samp>--</samp> to mean the end of options.
4949 </p>
4950 <p><code>echo</code> interprets the following escape sequences:
4951 </p><dl compact="compact">
4952 <dt><code>\a</code></dt>
4953 <dd><p>alert (bell)
4954 </p></dd>
4955 <dt><code>\b</code></dt>
4956 <dd><p>backspace
4957 </p></dd>
4958 <dt><code>\c</code></dt>
4959 <dd><p>suppress further output
4960 </p></dd>
4961 <dt><code>\e</code></dt>
4962 <dt><code>\E</code></dt>
4963 <dd><p>escape
4964 </p></dd>
4965 <dt><code>\f</code></dt>
4966 <dd><p>form feed
4967 </p></dd>
4968 <dt><code>\n</code></dt>
4969 <dd><p>new line
4970 </p></dd>
4971 <dt><code>\r</code></dt>
4972 <dd><p>carriage return
4973 </p></dd>
4974 <dt><code>\t</code></dt>
4975 <dd><p>horizontal tab
4976 </p></dd>
4977 <dt><code>\v</code></dt>
4978 <dd><p>vertical tab
4979 </p></dd>
4980 <dt><code>\\</code></dt>
4981 <dd><p>backslash
4982 </p></dd>
4983 <dt><code>\0<var>nnn</var></code></dt>
4984 <dd><p>the eight-bit character whose value is the octal value <var>nnn</var>
4985 (zero to three octal digits)
4986 </p></dd>
4987 <dt><code>\x<var>HH</var></code></dt>
4988 <dd><p>the eight-bit character whose value is the hexadecimal value <var>HH</var>
4989 (one or two hex digits)
4990 </p></dd>
4991 <dt><code>\u<var>HHHH</var></code></dt>
4992 <dd><p>the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
4993 <var>HHHH</var> (one to four hex digits)
4994 </p></dd>
4995 <dt><code>\U<var>HHHHHHHH</var></code></dt>
4996 <dd><p>the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
4997 <var>HHHHHHHH</var> (one to eight hex digits)
4998 </p></dd>
4999 </dl>
5000
5001 </dd>
5002 <dt><code>enable</code></dt>
5003 <dd><a name="index-enable"></a>
5004 <div class="example">
5005 <pre class="example">enable [-a] [-dnps] [-f <var>filename</var>] [<var>name</var> &hellip;]
5006 </pre></div>
5007
5008 <p>Enable and disable builtin shell commands.
5009 Disabling a builtin allows a disk command which has the same name
5010 as a shell builtin to be executed without specifying a full pathname,
5011 even though the shell normally searches for builtins before disk commands.
5012 If <samp>-n</samp> is used, the <var>name</var>s become disabled. Otherwise
5013 <var>name</var>s are enabled. For example, to use the <code>test</code> binary
5014 found via <code>$PATH</code> instead of the shell builtin version, type
5015 &lsquo;<samp>enable -n test</samp>&rsquo;.
5016 </p>
5017 <p>If the <samp>-p</samp> option is supplied, or no <var>name</var> arguments appear,
5018 a list of shell builtins is printed. With no other arguments, the list
5019 consists of all enabled shell builtins.
5020 The <samp>-a</samp> option means to list
5021 each builtin with an indication of whether or not it is enabled.
5022 </p>
5023 <p>The <samp>-f</samp> option means to load the new builtin command <var>name</var>
5024 from shared object <var>filename</var>, on systems that support dynamic loading.
5025 The <samp>-d</samp> option will delete a builtin loaded with <samp>-f</samp>.
5026 </p>
5027 <p>If there are no options, a list of the shell builtins is displayed.
5028 The <samp>-s</samp> option restricts <code>enable</code> to the <small>POSIX</small> special
5029 builtins. If <samp>-s</samp> is used with <samp>-f</samp>, the new builtin becomes
5030 a special builtin (see <a href="#Special-Builtins">Special Builtins</a>).
5031 </p>
5032 <p>The return status is zero unless a <var>name</var> is not a shell builtin
5033 or there is an error loading a new builtin from a shared object.
5034 </p>
5035 </dd>
5036 <dt><code>help</code></dt>
5037 <dd><a name="index-help"></a>
5038 <div class="example">
5039 <pre class="example">help [-dms] [<var>pattern</var>]
5040 </pre></div>
5041
5042 <p>Display helpful information about builtin commands.
5043 If <var>pattern</var> is specified, <code>help</code> gives detailed help
5044 on all commands matching <var>pattern</var>, otherwise a list of
5045 the builtins is printed.
5046 </p>
5047 <p>Options, if supplied, have the following meanings:
5048 </p>
5049 <dl compact="compact">
5050 <dt><code>-d</code></dt>
5051 <dd><p>Display a short description of each <var>pattern</var>
5052 </p></dd>
5053 <dt><code>-m</code></dt>
5054 <dd><p>Display the description of each <var>pattern</var> in a manpage-like format
5055 </p></dd>
5056 <dt><code>-s</code></dt>
5057 <dd><p>Display only a short usage synopsis for each <var>pattern</var>
5058 </p></dd>
5059 </dl>
5060
5061 <p>The return status is zero unless no command matches <var>pattern</var>.
5062 </p>
5063 </dd>
5064 <dt><code>let</code></dt>
5065 <dd><a name="index-let"></a>
5066 <div class="example">
5067 <pre class="example">let <var>expression</var> [<var>expression</var> &hellip;]
5068 </pre></div>
5069
5070 <p>The <code>let</code> builtin allows arithmetic to be performed on shell
5071 variables. Each <var>expression</var> is evaluated according to the
5072 rules given below in <a href="#Shell-Arithmetic">Shell Arithmetic</a>. If the
5073 last <var>expression</var> evaluates to 0, <code>let</code> returns 1;
5074 otherwise 0 is returned.
5075 </p>
5076 </dd>
5077 <dt><code>local</code></dt>
5078 <dd><a name="index-local"></a>
5079 <div class="example">
5080 <pre class="example">local [<var>option</var>] <var>name</var>[=<var>value</var>] &hellip;
5081 </pre></div>
5082
5083 <p>For each argument, a local variable named <var>name</var> is created,
5084 and assigned <var>value</var>.
5085 The <var>option</var> can be any of the options accepted by <code>declare</code>.
5086 <code>local</code> can only be used within a function; it makes the variable
5087 <var>name</var> have a visible scope restricted to that function and its
5088 children.
5089 If <var>name</var> is &lsquo;<samp>-</samp>&rsquo;, the set of shell options is made local to the
5090 function in which <code>local</code> is invoked: shell options changed using
5091 the <code>set</code> builtin inside the function are restored to their original
5092 values when the function returns.
5093 The return status is zero unless <code>local</code> is used outside
5094 a function, an invalid <var>name</var> is supplied, or <var>name</var> is a
5095 readonly variable.
5096 </p>
5097 </dd>
5098 <dt><code>logout</code></dt>
5099 <dd><a name="index-logout"></a>
5100 <div class="example">
5101 <pre class="example">logout [<var>n</var>]
5102 </pre></div>
5103
5104 <p>Exit a login shell, returning a status of <var>n</var> to the shell&rsquo;s
5105 parent.
5106 </p>
5107 </dd>
5108 <dt><code>mapfile</code></dt>
5109 <dd><a name="index-mapfile"></a>
5110 <div class="example">
5111 <pre class="example">mapfile [-d <var>delim</var>] [-n <var>count</var>] [-O <var>origin</var>] [-s <var>count</var>]
5112 [-t] [-u <var>fd</var>] [-C <var>callback</var>] [-c <var>quantum</var>] [<var>array</var>]
5113 </pre></div>
5114
5115 <p>Read lines from the standard input into the indexed array variable <var>array</var>,
5116 or from file descriptor <var>fd</var>
5117 if the <samp>-u</samp> option is supplied.
5118 The variable <code>MAPFILE</code> is the default <var>array</var>.
5119 Options, if supplied, have the following meanings:
5120 </p>
5121 <dl compact="compact">
5122 <dt><code>-d</code></dt>
5123 <dd><p>The first character of <var>delim</var> is used to terminate each input line,
5124 rather than newline.
5125 If <var>delim</var> is the empty string, <code>mapfile</code> will terminate a line
5126 when it reads a NUL character.
5127 </p></dd>
5128 <dt><code>-n</code></dt>
5129 <dd><p>Copy at most <var>count</var> lines. If <var>count</var> is 0, all lines are copied.
5130 </p></dd>
5131 <dt><code>-O</code></dt>
5132 <dd><p>Begin assigning to <var>array</var> at index <var>origin</var>.
5133 The default index is 0.
5134 </p></dd>
5135 <dt><code>-s</code></dt>
5136 <dd><p>Discard the first <var>count</var> lines read.
5137 </p></dd>
5138 <dt><code>-t</code></dt>
5139 <dd><p>Remove a trailing <var>delim</var> (default newline) from each line read.
5140 </p></dd>
5141 <dt><code>-u</code></dt>
5142 <dd><p>Read lines from file descriptor <var>fd</var> instead of the standard input.
5143 </p></dd>
5144 <dt><code>-C</code></dt>
5145 <dd><p>Evaluate <var>callback</var> each time <var>quantum</var> lines are read.
5146 The <samp>-c</samp> option specifies <var>quantum</var>.
5147 </p></dd>
5148 <dt><code>-c</code></dt>
5149 <dd><p>Specify the number of lines read between each call to <var>callback</var>.
5150 </p></dd>
5151 </dl>
5152
5153 <p>If <samp>-C</samp> is specified without <samp>-c</samp>,
5154 the default quantum is 5000.
5155 When <var>callback</var> is evaluated, it is supplied the index of the next
5156 array element to be assigned and the line to be assigned to that element
5157 as additional arguments.
5158 <var>callback</var> is evaluated after the line is read but before the
5159 array element is assigned.
5160 </p>
5161 <p>If not supplied with an explicit origin, <code>mapfile</code> will clear <var>array</var>
5162 before assigning to it.
5163 </p>
5164 <p><code>mapfile</code> returns successfully unless an invalid option or option
5165 argument is supplied, <var>array</var> is invalid or unassignable, or <var>array</var>
5166 is not an indexed array.
5167 </p>
5168 </dd>
5169 <dt><code>printf</code></dt>
5170 <dd><a name="index-printf"></a>
5171 <div class="example">
5172 <pre class="example">printf [-v <var>var</var>] <var>format</var> [<var>arguments</var>]
5173 </pre></div>
5174
5175 <p>Write the formatted <var>arguments</var> to the standard output under the
5176 control of the <var>format</var>.
5177 The <samp>-v</samp> option causes the output to be assigned to the variable
5178 <var>var</var> rather than being printed to the standard output.
5179 </p>
5180 <p>The <var>format</var> is a character string which contains three types of objects:
5181 plain characters, which are simply copied to standard output, character
5182 escape sequences, which are converted and copied to the standard output, and
5183 format specifications, each of which causes printing of the next successive
5184 <var>argument</var>.
5185 In addition to the standard <code>printf(1)</code> formats, <code>printf</code>
5186 interprets the following extensions:
5187 </p>
5188 <dl compact="compact">
5189 <dt><code>%b</code></dt>
5190 <dd><p>Causes <code>printf</code> to expand backslash escape sequences in the
5191 corresponding <var>argument</var> in the same way as <code>echo -e</code>
5192 (see <a href="#Bash-Builtins">Bash Builtins</a>).
5193 </p></dd>
5194 <dt><code>%q</code></dt>
5195 <dd><p>Causes <code>printf</code> to output the
5196 corresponding <var>argument</var> in a format that can be reused as shell input.
5197 </p></dd>
5198 <dt><code>%(<var>datefmt</var>)T</code></dt>
5199 <dd><p>Causes <code>printf</code> to output the date-time string resulting from using
5200 <var>datefmt</var> as a format string for <code>strftime</code>(3).
5201 The corresponding <var>argument</var> is an integer representing the number of
5202 seconds since the epoch.
5203 Two special argument values may be used: -1 represents the current
5204 time, and -2 represents the time the shell was invoked.
5205 If no argument is specified, conversion behaves as if -1 had been given.
5206 This is an exception to the usual <code>printf</code> behavior.
5207 </p></dd>
5208 </dl>
5209
5210 <p>Arguments to non-string format specifiers are treated as C language constants,
5211 except that a leading plus or minus sign is allowed, and if the leading
5212 character is a single or double quote, the value is the ASCII value of
5213 the following character.
5214 </p>
5215 <p>The <var>format</var> is reused as necessary to consume all of the <var>arguments</var>.
5216 If the <var>format</var> requires more <var>arguments</var> than are supplied, the
5217 extra format specifications behave as if a zero value or null string, as
5218 appropriate, had been supplied. The return value is zero on success,
5219 non-zero on failure.
5220 </p>
5221 </dd>
5222 <dt><code>read</code></dt>
5223 <dd><a name="index-read"></a>
5224 <div class="example">
5225 <pre class="example">read [-ers] [-a <var>aname</var>] [-d <var>delim</var>] [-i <var>text</var>] [-n <var>nchars</var>]
5226 [-N <var>nchars</var>] [-p <var>prompt</var>] [-t <var>timeout</var>] [-u <var>fd</var>] [<var>name</var> &hellip;]
5227 </pre></div>
5228
5229 <p>One line is read from the standard input, or from the file descriptor
5230 <var>fd</var> supplied as an argument to the <samp>-u</samp> option,
5231 split into words as described above in <a href="#Word-Splitting">Word Splitting</a>,
5232 and the first word
5233 is assigned to the first <var>name</var>, the second word to the second <var>name</var>,
5234 and so on.
5235 If there are more words than names,
5236 the remaining words and their intervening delimiters are assigned
5237 to the last <var>name</var>.
5238 If there are fewer words read from the input stream than names,
5239 the remaining names are assigned empty values.
5240 The characters in the value of the <code>IFS</code> variable
5241 are used to split the line into words using the same rules the shell
5242 uses for expansion (described above in <a href="#Word-Splitting">Word Splitting</a>).
5243 The backslash character &lsquo;<samp>\</samp>&rsquo; may be used to remove any special
5244 meaning for the next character read and for line continuation.
5245 If no names are supplied, the line read is assigned to the
5246 variable <code>REPLY</code>.
5247 The exit status is zero, unless end-of-file is encountered, <code>read</code>
5248 times out (in which case the status is greater than 128),
5249 a variable assignment error (such as assigning to a readonly variable) occurs,
5250 or an invalid file descriptor is supplied as the argument to <samp>-u</samp>.
5251 </p>
5252 <p>Options, if supplied, have the following meanings:
5253 </p>
5254 <dl compact="compact">
5255 <dt><code>-a <var>aname</var></code></dt>
5256 <dd><p>The words are assigned to sequential indices of the array variable
5257 <var>aname</var>, starting at 0.
5258 All elements are removed from <var>aname</var> before the assignment.
5259 Other <var>name</var> arguments are ignored.
5260 </p>
5261 </dd>
5262 <dt><code>-d <var>delim</var></code></dt>
5263 <dd><p>The first character of <var>delim</var> is used to terminate the input line,
5264 rather than newline.
5265 If <var>delim</var> is the empty string, <code>read</code> will terminate a line
5266 when it reads a NUL character.
5267 </p>
5268 </dd>
5269 <dt><code>-e</code></dt>
5270 <dd><p>Readline (see <a href="#Command-Line-Editing">Command Line Editing</a>) is used to obtain the line.
5271 Readline uses the current (or default, if line editing was not previously
5272 active) editing settings, but uses Readline&rsquo;s default filename completion.
5273 </p>
5274 </dd>
5275 <dt><code>-i <var>text</var></code></dt>
5276 <dd><p>If Readline is being used to read the line, <var>text</var> is placed into
5277 the editing buffer before editing begins.
5278 </p>
5279 </dd>
5280 <dt><code>-n <var>nchars</var></code></dt>
5281 <dd><p><code>read</code> returns after reading <var>nchars</var> characters rather than
5282 waiting for a complete line of input, but honors a delimiter if fewer
5283 than <var>nchars</var> characters are read before the delimiter.
5284 </p>
5285 </dd>
5286 <dt><code>-N <var>nchars</var></code></dt>
5287 <dd><p><code>read</code> returns after reading exactly <var>nchars</var> characters rather
5288 than waiting for a complete line of input, unless EOF is encountered or
5289 <code>read</code> times out.
5290 Delimiter characters encountered in the input are
5291 not treated specially and do not cause <code>read</code> to return until
5292 <var>nchars</var> characters are read.
5293 The result is not split on the characters in <code>IFS</code>; the intent is
5294 that the variable is assigned exactly the characters read
5295 (with the exception of backslash; see the <samp>-r</samp> option below).
5296 </p>
5297 </dd>
5298 <dt><code>-p <var>prompt</var></code></dt>
5299 <dd><p>Display <var>prompt</var>, without a trailing newline, before attempting
5300 to read any input.
5301 The prompt is displayed only if input is coming from a terminal.
5302 </p>
5303 </dd>
5304 <dt><code>-r</code></dt>
5305 <dd><p>If this option is given, backslash does not act as an escape character.
5306 The backslash is considered to be part of the line.
5307 In particular, a backslash-newline pair may not then be used as a line
5308 continuation.
5309 </p>
5310 </dd>
5311 <dt><code>-s</code></dt>
5312 <dd><p>Silent mode. If input is coming from a terminal, characters are
5313 not echoed.
5314 </p>
5315 </dd>
5316 <dt><code>-t <var>timeout</var></code></dt>
5317 <dd><p>Cause <code>read</code> to time out and return failure if a complete line of
5318 input (or a specified number of characters)
5319 is not read within <var>timeout</var> seconds.
5320 <var>timeout</var> may be a decimal number with a fractional portion following
5321 the decimal point.
5322 This option is only effective if <code>read</code> is reading input from a
5323 terminal, pipe, or other special file; it has no effect when reading
5324 from regular files.
5325 If <code>read</code> times out, <code>read</code> saves any partial input read into
5326 the specified variable <var>name</var>.
5327 If <var>timeout</var> is 0, <code>read</code> returns immediately, without trying to
5328 read and data. The exit status is 0 if input is available on
5329 the specified file descriptor, non-zero otherwise.
5330 The exit status is greater than 128 if the timeout is exceeded.
5331 </p>
5332 </dd>
5333 <dt><code>-u <var>fd</var></code></dt>
5334 <dd><p>Read input from file descriptor <var>fd</var>.
5335 </p></dd>
5336 </dl>
5337
5338 </dd>
5339 <dt><code>readarray</code></dt>
5340 <dd><a name="index-readarray"></a>
5341 <div class="example">
5342 <pre class="example">readarray [-d <var>delim</var>] [-n <var>count</var>] [-O <var>origin</var>] [-s <var>count</var>]
5343 [-t] [-u <var>fd</var>] [-C <var>callback</var>] [-c <var>quantum</var>] [<var>array</var>]
5344 </pre></div>
5345
5346 <p>Read lines from the standard input into the indexed array variable <var>array</var>,
5347 or from file descriptor <var>fd</var>
5348 if the <samp>-u</samp> option is supplied.
5349 </p>
5350 <p>A synonym for <code>mapfile</code>.
5351 </p>
5352 </dd>
5353 <dt><code>source</code></dt>
5354 <dd><a name="index-source"></a>
5355 <div class="example">
5356 <pre class="example">source <var>filename</var>
5357 </pre></div>
5358
5359 <p>A synonym for <code>.</code> (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
5360 </p>
5361 </dd>
5362 <dt><code>type</code></dt>
5363 <dd><a name="index-type"></a>
5364 <div class="example">
5365 <pre class="example">type [-afptP] [<var>name</var> &hellip;]
5366 </pre></div>
5367
5368 <p>For each <var>name</var>, indicate how it would be interpreted if used as a
5369 command name.
5370 </p>
5371 <p>If the <samp>-t</samp> option is used, <code>type</code> prints a single word
5372 which is one of &lsquo;<samp>alias</samp>&rsquo;, &lsquo;<samp>function</samp>&rsquo;, &lsquo;<samp>builtin</samp>&rsquo;,
5373 &lsquo;<samp>file</samp>&rsquo; or &lsquo;<samp>keyword</samp>&rsquo;,
5374 if <var>name</var> is an alias, shell function, shell builtin,
5375 disk file, or shell reserved word, respectively.
5376 If the <var>name</var> is not found, then nothing is printed, and
5377 <code>type</code> returns a failure status.
5378 </p>
5379 <p>If the <samp>-p</samp> option is used, <code>type</code> either returns the name
5380 of the disk file that would be executed, or nothing if <samp>-t</samp>
5381 would not return &lsquo;<samp>file</samp>&rsquo;.
5382 </p>
5383 <p>The <samp>-P</samp> option forces a path search for each <var>name</var>, even if
5384 <samp>-t</samp> would not return &lsquo;<samp>file</samp>&rsquo;.
5385 </p>
5386 <p>If a command is hashed, <samp>-p</samp> and <samp>-P</samp> print the hashed value,
5387 which is not necessarily the file that appears first in <code>$PATH</code>.
5388 </p>
5389 <p>If the <samp>-a</samp> option is used, <code>type</code> returns all of the places
5390 that contain an executable named <var>file</var>.
5391 This includes aliases and functions, if and only if the <samp>-p</samp> option
5392 is not also used.
5393 </p>
5394 <p>If the <samp>-f</samp> option is used, <code>type</code> does not attempt to find
5395 shell functions, as with the <code>command</code> builtin.
5396 </p>
5397 <p>The return status is zero if all of the <var>names</var> are found, non-zero
5398 if any are not found.
5399 </p>
5400 </dd>
5401 <dt><code>typeset</code></dt>
5402 <dd><a name="index-typeset"></a>
5403 <div class="example">
5404 <pre class="example">typeset [-afFgrxilnrtux] [-p] [<var>name</var>[=<var>value</var>] &hellip;]
5405 </pre></div>
5406
5407 <p>The <code>typeset</code> command is supplied for compatibility with the Korn
5408 shell.
5409 It is a synonym for the <code>declare</code> builtin command.
5410 </p>
5411 </dd>
5412 <dt><code>ulimit</code></dt>
5413 <dd><a name="index-ulimit"></a>
5414 <div class="example">
5415 <pre class="example">ulimit [-HSabcdefiklmnpqrstuvxPT] [<var>limit</var>]
5416 </pre></div>
5417
5418 <p><code>ulimit</code> provides control over the resources available to processes
5419 started by the shell, on systems that allow such control. If an
5420 option is given, it is interpreted as follows:
5421 </p>
5422 <dl compact="compact">
5423 <dt><code>-S</code></dt>
5424 <dd><p>Change and report the soft limit associated with a resource.
5425 </p>
5426 </dd>
5427 <dt><code>-H</code></dt>
5428 <dd><p>Change and report the hard limit associated with a resource.
5429 </p>
5430 </dd>
5431 <dt><code>-a</code></dt>
5432 <dd><p>All current limits are reported.
5433 </p>
5434 </dd>
5435 <dt><code>-b</code></dt>
5436 <dd><p>The maximum socket buffer size.
5437 </p>
5438 </dd>
5439 <dt><code>-c</code></dt>
5440 <dd><p>The maximum size of core files created.
5441 </p>
5442 </dd>
5443 <dt><code>-d</code></dt>
5444 <dd><p>The maximum size of a process&rsquo;s data segment.
5445 </p>
5446 </dd>
5447 <dt><code>-e</code></dt>
5448 <dd><p>The maximum scheduling priority (&quot;nice&quot;).
5449 </p>
5450 </dd>
5451 <dt><code>-f</code></dt>
5452 <dd><p>The maximum size of files written by the shell and its children.
5453 </p>
5454 </dd>
5455 <dt><code>-i</code></dt>
5456 <dd><p>The maximum number of pending signals.
5457 </p>
5458 </dd>
5459 <dt><code>-k</code></dt>
5460 <dd><p>The maximum number of kqueues that may be allocated.
5461 </p>
5462 </dd>
5463 <dt><code>-l</code></dt>
5464 <dd><p>The maximum size that may be locked into memory.
5465 </p>
5466 </dd>
5467 <dt><code>-m</code></dt>
5468 <dd><p>The maximum resident set size (many systems do not honor this limit).
5469 </p>
5470 </dd>
5471 <dt><code>-n</code></dt>
5472 <dd><p>The maximum number of open file descriptors (most systems do not
5473 allow this value to be set).
5474 </p>
5475 </dd>
5476 <dt><code>-p</code></dt>
5477 <dd><p>The pipe buffer size.
5478 </p>
5479 </dd>
5480 <dt><code>-q</code></dt>
5481 <dd><p>The maximum number of bytes in POSIX message queues.
5482 </p>
5483 </dd>
5484 <dt><code>-r</code></dt>
5485 <dd><p>The maximum real-time scheduling priority.
5486 </p>
5487 </dd>
5488 <dt><code>-s</code></dt>
5489 <dd><p>The maximum stack size.
5490 </p>
5491 </dd>
5492 <dt><code>-t</code></dt>
5493 <dd><p>The maximum amount of cpu time in seconds.
5494 </p>
5495 </dd>
5496 <dt><code>-u</code></dt>
5497 <dd><p>The maximum number of processes available to a single user.
5498 </p>
5499 </dd>
5500 <dt><code>-v</code></dt>
5501 <dd><p>The maximum amount of virtual memory available to the shell, and, on
5502 some systems, to its children.
5503 </p>
5504 </dd>
5505 <dt><code>-x</code></dt>
5506 <dd><p>The maximum number of file locks.
5507 </p>
5508 </dd>
5509 <dt><code>-P</code></dt>
5510 <dd><p>The maximum number of pseudoterminals.
5511 </p>
5512 </dd>
5513 <dt><code>-T</code></dt>
5514 <dd><p>The maximum number of threads.
5515 </p></dd>
5516 </dl>
5517
5518 <p>If <var>limit</var> is given, and the <samp>-a</samp> option is not used,
5519 <var>limit</var> is the new value of the specified resource.
5520 The special <var>limit</var> values <code>hard</code>, <code>soft</code>, and
5521 <code>unlimited</code> stand for the current hard limit, the current soft limit,
5522 and no limit, respectively.
5523 A hard limit cannot be increased by a non-root user once it is set;
5524 a soft limit may be increased up to the value of the hard limit.
5525 Otherwise, the current value of the soft limit for the specified resource
5526 is printed, unless the <samp>-H</samp> option is supplied.
5527 When setting new limits, if neither <samp>-H</samp> nor <samp>-S</samp> is supplied,
5528 both the hard and soft limits are set.
5529 If no option is given, then <samp>-f</samp> is assumed. Values are in 1024-byte
5530 increments, except for <samp>-t</samp>, which is in seconds; <samp>-p</samp>,
5531 which is in units of 512-byte blocks;
5532 <samp>-P</samp>,
5533 <samp>-T</samp>,
5534 <samp>-b</samp>,
5535 <samp>-k</samp>,
5536 <samp>-n</samp> and <samp>-u</samp>, which are unscaled values;
5537 and, when in <small>POSIX</small> Mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>),
5538 <samp>-c</samp> and <samp>-f</samp>, which are in 512-byte increments.
5539 </p>
5540 <p>The return status is zero unless an invalid option or argument is supplied,
5541 or an error occurs while setting a new limit.
5542 </p>
5543 </dd>
5544 <dt><code>unalias</code></dt>
5545 <dd><a name="index-unalias"></a>
5546 <div class="example">
5547 <pre class="example">unalias [-a] [<var>name</var> &hellip; ]
5548 </pre></div>
5549
5550 <p>Remove each <var>name</var> from the list of aliases. If <samp>-a</samp> is
5551 supplied, all aliases are removed.
5552 Aliases are described in <a href="#Aliases">Aliases</a>.
5553 </p></dd>
5554 </dl>
5555
5556 <hr>
5557 <a name="Modifying-Shell-Behavior"></a>
5558 <div class="header">
5559 <p>
5560 Next: <a href="#Special-Builtins" accesskey="n" rel="next">Special Builtins</a>, Previous: <a href="#Bash-Builtins" accesskey="p" rel="prev">Bash Builtins</a>, Up: <a href="#Shell-Builtin-Commands" accesskey="u" rel="up">Shell Builtin Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
5561 </div>
5562 <a name="Modifying-Shell-Behavior-1"></a>
5563 <h3 class="section">4.3 Modifying Shell Behavior</h3>
5564
5565 <table class="menu" border="0" cellspacing="0">
5566 <tr><td align="left" valign="top">&bull; <a href="#The-Set-Builtin" accesskey="1">The Set Builtin</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Change the values of shell attributes and
5567 positional parameters.
5568 </td></tr>
5569 <tr><td align="left" valign="top">&bull; <a href="#The-Shopt-Builtin" accesskey="2">The Shopt Builtin</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Modify shell optional behavior.
5570 </td></tr>
5571 </table>
5572
5573 <hr>
5574 <a name="The-Set-Builtin"></a>
5575 <div class="header">
5576 <p>
5577 Next: <a href="#The-Shopt-Builtin" accesskey="n" rel="next">The Shopt Builtin</a>, Up: <a href="#Modifying-Shell-Behavior" accesskey="u" rel="up">Modifying Shell Behavior</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
5578 </div>
5579 <a name="The-Set-Builtin-1"></a>
5580 <h4 class="subsection">4.3.1 The Set Builtin</h4>
5581
5582 <p>This builtin is so complicated that it deserves its own section. <code>set</code>
5583 allows you to change the values of shell options and set the positional
5584 parameters, or to display the names and values of shell variables.
5585 </p>
5586 <dl compact="compact">
5587 <dt><code>set</code></dt>
5588 <dd><a name="index-set"></a>
5589 <div class="example">
5590 <pre class="example">set [--abefhkmnptuvxBCEHPT] [-o <var>option-name</var>] [<var>argument</var> &hellip;]
5591 set [+abefhkmnptuvxBCEHPT] [+o <var>option-name</var>] [<var>argument</var> &hellip;]
5592 </pre></div>
5593
5594 <p>If no options or arguments are supplied, <code>set</code> displays the names
5595 and values of all shell variables and functions, sorted according to the
5596 current locale, in a format that may be reused as input
5597 for setting or resetting the currently-set variables.
5598 Read-only variables cannot be reset.
5599 In <small>POSIX</small> mode, only shell variables are listed.
5600 </p>
5601 <p>When options are supplied, they set or unset shell attributes.
5602 Options, if specified, have the following meanings:
5603 </p>
5604 <dl compact="compact">
5605 <dt><code>-a</code></dt>
5606 <dd><p>Each variable or function that is created or modified is given the
5607 export attribute and marked for export to the environment of
5608 subsequent commands.
5609 </p>
5610 </dd>
5611 <dt><code>-b</code></dt>
5612 <dd><p>Cause the status of terminated background jobs to be reported
5613 immediately, rather than before printing the next primary prompt.
5614 </p>
5615 </dd>
5616 <dt><code>-e</code></dt>
5617 <dd><p>Exit immediately if
5618 a pipeline (see <a href="#Pipelines">Pipelines</a>), which may consist of a single simple command
5619 (see <a href="#Simple-Commands">Simple Commands</a>),
5620 a list (see <a href="#Lists">Lists</a>),
5621 or a compound command (see <a href="#Compound-Commands">Compound Commands</a>)
5622 returns a non-zero status.
5623 The shell does not exit if the command that fails is part of the
5624 command list immediately following a <code>while</code> or <code>until</code> keyword,
5625 part of the test in an <code>if</code> statement,
5626 part of any command executed in a <code>&amp;&amp;</code> or <code>||</code> list except
5627 the command following the final <code>&amp;&amp;</code> or <code>||</code>,
5628 any command in a pipeline but the last,
5629 or if the command&rsquo;s return status is being inverted with <code>!</code>.
5630 If a compound command other than a subshell
5631 returns a non-zero status because a command failed
5632 while <samp>-e</samp> was being ignored, the shell does not exit.
5633 A trap on <code>ERR</code>, if set, is executed before the shell exits.
5634 </p>
5635 <p>This option applies to the shell environment and each subshell environment
5636 separately (see <a href="#Command-Execution-Environment">Command Execution Environment</a>), and may cause
5637 subshells to exit before executing all the commands in the subshell.
5638 </p>
5639 <p>If a compound command or shell function executes in a context where
5640 <samp>-e</samp> is being ignored,
5641 none of the commands executed within the compound command or function body
5642 will be affected by the <samp>-e</samp> setting, even if <samp>-e</samp> is set
5643 and a command returns a failure status.
5644 If a compound command or shell function sets <samp>-e</samp> while executing in
5645 a context where <samp>-e</samp> is ignored, that setting will not have any
5646 effect until the compound command or the command containing the function
5647 call completes.
5648 </p>
5649 </dd>
5650 <dt><code>-f</code></dt>
5651 <dd><p>Disable filename expansion (globbing).
5652 </p>
5653 </dd>
5654 <dt><code>-h</code></dt>
5655 <dd><p>Locate and remember (hash) commands as they are looked up for execution.
5656 This option is enabled by default.
5657 </p>
5658 </dd>
5659 <dt><code>-k</code></dt>
5660 <dd><p>All arguments in the form of assignment statements are placed
5661 in the environment for a command, not just those that precede
5662 the command name.
5663 </p>
5664 </dd>
5665 <dt><code>-m</code></dt>
5666 <dd><p>Job control is enabled (see <a href="#Job-Control">Job Control</a>).
5667 All processes run in a separate process group.
5668 When a background job completes, the shell prints a line
5669 containing its exit status.
5670 </p>
5671 </dd>
5672 <dt><code>-n</code></dt>
5673 <dd><p>Read commands but do not execute them.
5674 This may be used to check a script for syntax errors.
5675 This option is ignored by interactive shells.
5676 </p>
5677 </dd>
5678 <dt><code>-o <var>option-name</var></code></dt>
5679 <dd>
5680 <p>Set the option corresponding to <var>option-name</var>:
5681 </p>
5682 <dl compact="compact">
5683 <dt><code>allexport</code></dt>
5684 <dd><p>Same as <code>-a</code>.
5685 </p>
5686 </dd>
5687 <dt><code>braceexpand</code></dt>
5688 <dd><p>Same as <code>-B</code>.
5689 </p>
5690 </dd>
5691 <dt><code>emacs</code></dt>
5692 <dd><p>Use an <code>emacs</code>-style line editing interface (see <a href="#Command-Line-Editing">Command Line Editing</a>).
5693 This also affects the editing interface used for <code>read -e</code>.
5694 </p>
5695 </dd>
5696 <dt><code>errexit</code></dt>
5697 <dd><p>Same as <code>-e</code>.
5698 </p>
5699 </dd>
5700 <dt><code>errtrace</code></dt>
5701 <dd><p>Same as <code>-E</code>.
5702 </p>
5703 </dd>
5704 <dt><code>functrace</code></dt>
5705 <dd><p>Same as <code>-T</code>.
5706 </p>
5707 </dd>
5708 <dt><code>hashall</code></dt>
5709 <dd><p>Same as <code>-h</code>.
5710 </p>
5711 </dd>
5712 <dt><code>histexpand</code></dt>
5713 <dd><p>Same as <code>-H</code>.
5714 </p>
5715 </dd>
5716 <dt><code>history</code></dt>
5717 <dd><p>Enable command history, as described in <a href="#Bash-History-Facilities">Bash History Facilities</a>.
5718 This option is on by default in interactive shells.
5719 </p>
5720 </dd>
5721 <dt><code>ignoreeof</code></dt>
5722 <dd><p>An interactive shell will not exit upon reading EOF.
5723 </p>
5724 </dd>
5725 <dt><code>keyword</code></dt>
5726 <dd><p>Same as <code>-k</code>.
5727 </p>
5728 </dd>
5729 <dt><code>monitor</code></dt>
5730 <dd><p>Same as <code>-m</code>.
5731 </p>
5732 </dd>
5733 <dt><code>noclobber</code></dt>
5734 <dd><p>Same as <code>-C</code>.
5735 </p>
5736 </dd>
5737 <dt><code>noexec</code></dt>
5738 <dd><p>Same as <code>-n</code>.
5739 </p>
5740 </dd>
5741 <dt><code>noglob</code></dt>
5742 <dd><p>Same as <code>-f</code>.
5743 </p>
5744 </dd>
5745 <dt><code>nolog</code></dt>
5746 <dd><p>Currently ignored.
5747 </p>
5748 </dd>
5749 <dt><code>notify</code></dt>
5750 <dd><p>Same as <code>-b</code>.
5751 </p>
5752 </dd>
5753 <dt><code>nounset</code></dt>
5754 <dd><p>Same as <code>-u</code>.
5755 </p>
5756 </dd>
5757 <dt><code>onecmd</code></dt>
5758 <dd><p>Same as <code>-t</code>.
5759 </p>
5760 </dd>
5761 <dt><code>physical</code></dt>
5762 <dd><p>Same as <code>-P</code>.
5763 </p>
5764 </dd>
5765 <dt><code>pipefail</code></dt>
5766 <dd><p>If set, the return value of a pipeline is the value of the last
5767 (rightmost) command to exit with a non-zero status, or zero if all
5768 commands in the pipeline exit successfully.
5769 This option is disabled by default.
5770 </p>
5771 </dd>
5772 <dt><code>posix</code></dt>
5773 <dd><p>Change the behavior of Bash where the default operation differs
5774 from the <small>POSIX</small> standard to match the standard
5775 (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>).
5776 This is intended to make Bash behave as a strict superset of that
5777 standard.
5778 </p>
5779 </dd>
5780 <dt><code>privileged</code></dt>
5781 <dd><p>Same as <code>-p</code>.
5782 </p>
5783 </dd>
5784 <dt><code>verbose</code></dt>
5785 <dd><p>Same as <code>-v</code>.
5786 </p>
5787 </dd>
5788 <dt><code>vi</code></dt>
5789 <dd><p>Use a <code>vi</code>-style line editing interface.
5790 This also affects the editing interface used for <code>read -e</code>.
5791 </p>
5792 </dd>
5793 <dt><code>xtrace</code></dt>
5794 <dd><p>Same as <code>-x</code>.
5795 </p></dd>
5796 </dl>
5797
5798 </dd>
5799 <dt><code>-p</code></dt>
5800 <dd><p>Turn on privileged mode.
5801 In this mode, the <code>$BASH_ENV</code> and <code>$ENV</code> files are not
5802 processed, shell functions are not inherited from the environment,
5803 and the <code>SHELLOPTS</code>, <code>BASHOPTS</code>, <code>CDPATH</code> and <code>GLOBIGNORE</code>
5804 variables, if they appear in the environment, are ignored.
5805 If the shell is started with the effective user (group) id not equal to the
5806 real user (group) id, and the <samp>-p</samp> option is not supplied, these actions
5807 are taken and the effective user id is set to the real user id.
5808 If the <samp>-p</samp> option is supplied at startup, the effective user id is
5809 not reset.
5810 Turning this option off causes the effective user
5811 and group ids to be set to the real user and group ids.
5812 </p>
5813 </dd>
5814 <dt><code>-t</code></dt>
5815 <dd><p>Exit after reading and executing one command.
5816 </p>
5817 </dd>
5818 <dt><code>-u</code></dt>
5819 <dd><p>Treat unset variables and parameters other than the special parameters
5820 &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo; as an error when performing parameter expansion.
5821 An error message will be written to the standard error, and a non-interactive
5822 shell will exit.
5823 </p>
5824 </dd>
5825 <dt><code>-v</code></dt>
5826 <dd><p>Print shell input lines as they are read.
5827 </p>
5828 </dd>
5829 <dt><code>-x</code></dt>
5830 <dd><p>Print a trace of simple commands, <code>for</code> commands, <code>case</code>
5831 commands, <code>select</code> commands, and arithmetic <code>for</code> commands
5832 and their arguments or associated word lists after they are
5833 expanded and before they are executed. The value of the <code>PS4</code>
5834 variable is expanded and the resultant value is printed before
5835 the command and its expanded arguments.
5836 </p>
5837 </dd>
5838 <dt><code>-B</code></dt>
5839 <dd><p>The shell will perform brace expansion (see <a href="#Brace-Expansion">Brace Expansion</a>).
5840 This option is on by default.
5841 </p>
5842 </dd>
5843 <dt><code>-C</code></dt>
5844 <dd><p>Prevent output redirection using &lsquo;<samp>&gt;</samp>&rsquo;, &lsquo;<samp>&gt;&amp;</samp>&rsquo;, and &lsquo;<samp>&lt;&gt;</samp>&rsquo;
5845 from overwriting existing files.
5846 </p>
5847 </dd>
5848 <dt><code>-E</code></dt>
5849 <dd><p>If set, any trap on <code>ERR</code> is inherited by shell functions, command
5850 substitutions, and commands executed in a subshell environment.
5851 The <code>ERR</code> trap is normally not inherited in such cases.
5852 </p>
5853 </dd>
5854 <dt><code>-H</code></dt>
5855 <dd><p>Enable &lsquo;<samp>!</samp>&rsquo; style history substitution (see <a href="#History-Interaction">History Interaction</a>).
5856 This option is on by default for interactive shells.
5857 </p>
5858 </dd>
5859 <dt><code>-P</code></dt>
5860 <dd><p>If set, do not resolve symbolic links when performing commands such as
5861 <code>cd</code> which change the current directory. The physical directory
5862 is used instead. By default, Bash follows
5863 the logical chain of directories when performing commands
5864 which change the current directory.
5865 </p>
5866 <p>For example, if <samp>/usr/sys</samp> is a symbolic link to <samp>/usr/local/sys</samp>
5867 then:
5868 </p><div class="example">
5869 <pre class="example">$ cd /usr/sys; echo $PWD
5870 /usr/sys
5871 $ cd ..; pwd
5872 /usr
5873 </pre></div>
5874
5875 <p>If <code>set -P</code> is on, then:
5876 </p><div class="example">
5877 <pre class="example">$ cd /usr/sys; echo $PWD
5878 /usr/local/sys
5879 $ cd ..; pwd
5880 /usr/local
5881 </pre></div>
5882
5883 </dd>
5884 <dt><code>-T</code></dt>
5885 <dd><p>If set, any trap on <code>DEBUG</code> and <code>RETURN</code> are inherited by
5886 shell functions, command substitutions, and commands executed
5887 in a subshell environment.
5888 The <code>DEBUG</code> and <code>RETURN</code> traps are normally not inherited
5889 in such cases.
5890 </p>
5891 </dd>
5892 <dt><code>--</code></dt>
5893 <dd><p>If no arguments follow this option, then the positional parameters are
5894 unset. Otherwise, the positional parameters are set to the
5895 <var>arguments</var>, even if some of them begin with a &lsquo;<samp>-</samp>&rsquo;.
5896 </p>
5897 </dd>
5898 <dt><code>-</code></dt>
5899 <dd><p>Signal the end of options, cause all remaining <var>arguments</var>
5900 to be assigned to the positional parameters. The <samp>-x</samp>
5901 and <samp>-v</samp> options are turned off.
5902 If there are no arguments, the positional parameters remain unchanged.
5903 </p></dd>
5904 </dl>
5905
5906 <p>Using &lsquo;<samp>+</samp>&rsquo; rather than &lsquo;<samp>-</samp>&rsquo; causes these options to be
5907 turned off. The options can also be used upon invocation of the
5908 shell. The current set of options may be found in <code>$-</code>.
5909 </p>
5910 <p>The remaining N <var>arguments</var> are positional parameters and are
5911 assigned, in order, to <code>$1</code>, <code>$2</code>, &hellip; <code>$N</code>.
5912 The special parameter <code>#</code> is set to N.
5913 </p>
5914 <p>The return status is always zero unless an invalid option is supplied.
5915 </p></dd>
5916 </dl>
5917
5918 <hr>
5919 <a name="The-Shopt-Builtin"></a>
5920 <div class="header">
5921 <p>
5922 Previous: <a href="#The-Set-Builtin" accesskey="p" rel="prev">The Set Builtin</a>, Up: <a href="#Modifying-Shell-Behavior" accesskey="u" rel="up">Modifying Shell Behavior</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
5923 </div>
5924 <a name="The-Shopt-Builtin-1"></a>
5925 <h4 class="subsection">4.3.2 The Shopt Builtin</h4>
5926
5927 <p>This builtin allows you to change additional shell optional behavior.
5928 </p>
5929 <dl compact="compact">
5930 <dt><code>shopt</code></dt>
5931 <dd><a name="index-shopt"></a>
5932 <div class="example">
5933 <pre class="example">shopt [-pqsu] [-o] [<var>optname</var> &hellip;]
5934 </pre></div>
5935
5936 <p>Toggle the values of settings controlling optional shell behavior.
5937 The settings can be either those listed below, or, if the
5938 <samp>-o</samp> option is used, those available with the <samp>-o</samp>
5939 option to the <code>set</code> builtin command (see <a href="#The-Set-Builtin">The Set Builtin</a>).
5940 With no options, or with the <samp>-p</samp> option, a list of all settable
5941 options is displayed, with an indication of whether or not each is set;
5942 if <var>optnames</var> are supplied, the output is restricted to those options.
5943 The <samp>-p</samp> option causes output to be displayed in a form that
5944 may be reused as input.
5945 Other options have the following meanings:
5946 </p>
5947 <dl compact="compact">
5948 <dt><code>-s</code></dt>
5949 <dd><p>Enable (set) each <var>optname</var>.
5950 </p>
5951 </dd>
5952 <dt><code>-u</code></dt>
5953 <dd><p>Disable (unset) each <var>optname</var>.
5954 </p>
5955 </dd>
5956 <dt><code>-q</code></dt>
5957 <dd><p>Suppresses normal output; the return status
5958 indicates whether the <var>optname</var> is set or unset.
5959 If multiple <var>optname</var> arguments are given with <samp>-q</samp>,
5960 the return status is zero if all <var>optnames</var> are enabled;
5961 non-zero otherwise.
5962 </p>
5963 </dd>
5964 <dt><code>-o</code></dt>
5965 <dd><p>Restricts the values of
5966 <var>optname</var> to be those defined for the <samp>-o</samp> option to the
5967 <code>set</code> builtin (see <a href="#The-Set-Builtin">The Set Builtin</a>).
5968 </p></dd>
5969 </dl>
5970
5971 <p>If either <samp>-s</samp> or <samp>-u</samp>
5972 is used with no <var>optname</var> arguments, <code>shopt</code> shows only
5973 those options which are set or unset, respectively.
5974 </p>
5975 <p>Unless otherwise noted, the <code>shopt</code> options are disabled (off)
5976 by default.
5977 </p>
5978 <p>The return status when listing options is zero if all <var>optnames</var>
5979 are enabled, non-zero otherwise. When setting or unsetting options,
5980 the return status is zero unless an <var>optname</var> is not a valid shell
5981 option.
5982 </p>
5983 <p>The list of <code>shopt</code> options is:
5984 </p><dl compact="compact">
5985 <dt><code>assoc_expand_once</code></dt>
5986 <dd><p>If set, the shell suppresses multiple evaluation of associative array
5987 subscripts during arithmetic expression evaluation and while executing
5988 builtins that can perform variable assignments.
5989 </p>
5990 </dd>
5991 <dt><code>autocd</code></dt>
5992 <dd><p>If set, a command name that is the name of a directory is executed as if
5993 it were the argument to the <code>cd</code> command.
5994 This option is only used by interactive shells.
5995 </p>
5996 </dd>
5997 <dt><code>cdable_vars</code></dt>
5998 <dd><p>If this is set, an argument to the <code>cd</code> builtin command that
5999 is not a directory is assumed to be the name of a variable whose
6000 value is the directory to change to.
6001 </p>
6002 </dd>
6003 <dt><code>cdspell</code></dt>
6004 <dd><p>If set, minor errors in the spelling of a directory component in a
6005 <code>cd</code> command will be corrected.
6006 The errors checked for are transposed characters,
6007 a missing character, and a character too many.
6008 If a correction is found, the corrected path is printed,
6009 and the command proceeds.
6010 This option is only used by interactive shells.
6011 </p>
6012 </dd>
6013 <dt><code>checkhash</code></dt>
6014 <dd><p>If this is set, Bash checks that a command found in the hash
6015 table exists before trying to execute it. If a hashed command no
6016 longer exists, a normal path search is performed.
6017 </p>
6018 </dd>
6019 <dt><code>checkjobs</code></dt>
6020 <dd><p>If set, Bash lists the status of any stopped and running jobs before
6021 exiting an interactive shell. If any jobs are running, this causes
6022 the exit to be deferred until a second exit is attempted without an
6023 intervening command (see <a href="#Job-Control">Job Control</a>).
6024 The shell always postpones exiting if any jobs are stopped.
6025 </p>
6026 </dd>
6027 <dt><code>checkwinsize</code></dt>
6028 <dd><p>If set, Bash checks the window size after each external (non-builtin)
6029 command and, if necessary, updates the values of
6030 <code>LINES</code> and <code>COLUMNS</code>.
6031 This option is enabled by default.
6032 </p>
6033 </dd>
6034 <dt><code>cmdhist</code></dt>
6035 <dd><p>If set, Bash
6036 attempts to save all lines of a multiple-line
6037 command in the same history entry. This allows
6038 easy re-editing of multi-line commands.
6039 This option is enabled by default, but only has an effect if command
6040 history is enabled (see <a href="#Bash-History-Facilities">Bash History Facilities</a>).
6041 </p>
6042 </dd>
6043 <dt><code>compat31</code></dt>
6044 <dd><p>If set, Bash
6045 changes its behavior to that of version 3.1 with respect to quoted
6046 arguments to the conditional command&rsquo;s &lsquo;<samp>=~</samp>&rsquo; operator
6047 and with respect to locale-specific
6048 string comparison when using the <code>[[</code>
6049 conditional command&rsquo;s &lsquo;<samp>&lt;</samp>&rsquo; and &lsquo;<samp>&gt;</samp>&rsquo; operators.
6050 Bash versions prior to bash-4.1 use ASCII collation and strcmp(3);
6051 bash-4.1 and later use the current locale&rsquo;s collation sequence and strcoll(3).
6052 </p>
6053 </dd>
6054 <dt><code>compat32</code></dt>
6055 <dd><p>If set, Bash
6056 changes its behavior to that of version 3.2 with respect to locale-specific
6057 string comparison when using the <code>[[</code>
6058 conditional command&rsquo;s &lsquo;<samp>&lt;</samp>&rsquo; and &lsquo;<samp>&gt;</samp>&rsquo; operators (see previous item)
6059 and the effect of interrupting a command list.
6060 Bash versions 3.2 and earlier continue with the next command in the list
6061 after one terminates due to an interrupt.
6062 </p>
6063 </dd>
6064 <dt><code>compat40</code></dt>
6065 <dd><p>If set, Bash
6066 changes its behavior to that of version 4.0 with respect to locale-specific
6067 string comparison when using the <code>[[</code>
6068 conditional command&rsquo;s &lsquo;<samp>&lt;</samp>&rsquo; and &lsquo;<samp>&gt;</samp>&rsquo; operators (see description
6069 of <code>compat31</code>)
6070 and the effect of interrupting a command list.
6071 Bash versions 4.0 and later interrupt the list as if the shell received the
6072 interrupt; previous versions continue with the next command in the list.
6073 </p>
6074 </dd>
6075 <dt><code>compat41</code></dt>
6076 <dd><p>If set, Bash, when in <small>POSIX</small> mode, treats a single quote in a double-quoted
6077 parameter expansion as a special character. The single quotes must match
6078 (an even number) and the characters between the single quotes are considered
6079 quoted. This is the behavior of <small>POSIX</small> mode through version 4.1.
6080 The default Bash behavior remains as in previous versions.
6081 </p>
6082 </dd>
6083 <dt><code>compat42</code></dt>
6084 <dd><p>If set, Bash
6085 does not process the replacement string in the pattern substitution word
6086 expansion using quote removal.
6087 </p>
6088 </dd>
6089 <dt><code>compat43</code></dt>
6090 <dd><p>If set, Bash
6091 does not print a warning message if an attempt is made to use a quoted compound
6092 array assignment as an argument to <code>declare</code>,
6093 makes word expansion errors
6094 non-fatal errors that cause the current command to fail (the default behavior is
6095 to make them fatal errors that cause the shell to exit),
6096 and does not reset the
6097 loop state when a shell function is executed (this allows <code>break</code> or
6098 <code>continue</code> in a shell function to affect loops in the caller&rsquo;s context).
6099 </p>
6100 </dd>
6101 <dt><code>compat44</code></dt>
6102 <dd><p>If set, Bash
6103 saves the positional parameters to BASH_ARGV and BASH_ARGC before they are
6104 used, regardless of whether or not extended debugging mode is enabled.
6105 </p>
6106 </dd>
6107 <dt><code>complete_fullquote</code></dt>
6108 <dd><p>If set, Bash
6109 quotes all shell metacharacters in filenames and directory names when
6110 performing completion.
6111 If not set, Bash
6112 removes metacharacters such as the dollar sign from the set of
6113 characters that will be quoted in completed filenames
6114 when these metacharacters appear in shell variable references in words to be
6115 completed.
6116 This means that dollar signs in variable names that expand to directories
6117 will not be quoted;
6118 however, any dollar signs appearing in filenames will not be quoted, either.
6119 This is active only when bash is using backslashes to quote completed
6120 filenames.
6121 This variable is set by default, which is the default Bash behavior in
6122 versions through 4.2.
6123 </p>
6124 </dd>
6125 <dt><code>direxpand</code></dt>
6126 <dd><p>If set, Bash
6127 replaces directory names with the results of word expansion when performing
6128 filename completion. This changes the contents of the readline editing
6129 buffer.
6130 If not set, Bash attempts to preserve what the user typed.
6131 </p>
6132 </dd>
6133 <dt><code>dirspell</code></dt>
6134 <dd><p>If set, Bash
6135 attempts spelling correction on directory names during word completion
6136 if the directory name initially supplied does not exist.
6137 </p>
6138 </dd>
6139 <dt><code>dotglob</code></dt>
6140 <dd><p>If set, Bash includes filenames beginning with a &lsquo;.&rsquo; in
6141 the results of filename expansion.
6142 The filenames &lsquo;<samp>.</samp>&rsquo; and &lsquo;<samp>..</samp>&rsquo; must always be matched explicitly,
6143 even if <code>dotglob</code> is set.
6144 </p>
6145 </dd>
6146 <dt><code>execfail</code></dt>
6147 <dd><p>If this is set, a non-interactive shell will not exit if
6148 it cannot execute the file specified as an argument to the <code>exec</code>
6149 builtin command. An interactive shell does not exit if <code>exec</code>
6150 fails.
6151 </p>
6152 </dd>
6153 <dt><code>expand_aliases</code></dt>
6154 <dd><p>If set, aliases are expanded as described below under Aliases,
6155 <a href="#Aliases">Aliases</a>.
6156 This option is enabled by default for interactive shells.
6157 </p>
6158 </dd>
6159 <dt><code>extdebug</code></dt>
6160 <dd><p>If set at shell invocation, arrange to execute the debugger profile
6161 before the shell starts, identical to the <samp>--debugger</samp> option.
6162 If set after invocation, behavior intended for use by debuggers is enabled:
6163 </p>
6164 <ol>
6165 <li> The <samp>-F</samp> option to the <code>declare</code> builtin (see <a href="#Bash-Builtins">Bash Builtins</a>)
6166 displays the source file name and line number corresponding to each function
6167 name supplied as an argument.
6168
6169 </li><li> If the command run by the <code>DEBUG</code> trap returns a non-zero value, the
6170 next command is skipped and not executed.
6171
6172 </li><li> If the command run by the <code>DEBUG</code> trap returns a value of 2, and the
6173 shell is executing in a subroutine (a shell function or a shell script
6174 executed by the <code>.</code> or <code>source</code> builtins), the shell simulates
6175 a call to <code>return</code>.
6176
6177 </li><li> <code>BASH_ARGC</code> and <code>BASH_ARGV</code> are updated as described in their
6178 descriptions (see <a href="#Bash-Variables">Bash Variables</a>).
6179
6180 </li><li> Function tracing is enabled: command substitution, shell functions, and
6181 subshells invoked with <code>( <var>command</var> )</code> inherit the
6182 <code>DEBUG</code> and <code>RETURN</code> traps.
6183
6184 </li><li> Error tracing is enabled: command substitution, shell functions, and
6185 subshells invoked with <code>( <var>command</var> )</code> inherit the
6186 <code>ERR</code> trap.
6187 </li></ol>
6188
6189 </dd>
6190 <dt><code>extglob</code></dt>
6191 <dd><p>If set, the extended pattern matching features described above
6192 (see <a href="#Pattern-Matching">Pattern Matching</a>) are enabled.
6193 </p>
6194 </dd>
6195 <dt><code>extquote</code></dt>
6196 <dd><p>If set, <code>$'<var>string</var>'</code> and <code>$&quot;<var>string</var>&quot;</code> quoting is
6197 performed within <code>${<var>parameter</var>}</code> expansions
6198 enclosed in double quotes. This option is enabled by default.
6199 </p>
6200 </dd>
6201 <dt><code>failglob</code></dt>
6202 <dd><p>If set, patterns which fail to match filenames during filename expansion
6203 result in an expansion error.
6204 </p>
6205 </dd>
6206 <dt><code>force_fignore</code></dt>
6207 <dd><p>If set, the suffixes specified by the <code>FIGNORE</code> shell variable
6208 cause words to be ignored when performing word completion even if
6209 the ignored words are the only possible completions.
6210 See <a href="#Bash-Variables">Bash Variables</a>, for a description of <code>FIGNORE</code>.
6211 This option is enabled by default.
6212 </p>
6213 </dd>
6214 <dt><code>globasciiranges</code></dt>
6215 <dd><p>If set, range expressions used in pattern matching bracket expressions
6216 (see <a href="#Pattern-Matching">Pattern Matching</a>)
6217 behave as if in the traditional C locale when performing
6218 comparisons. That is, the current locale&rsquo;s collating sequence
6219 is not taken into account, so
6220 &lsquo;<samp>b</samp>&rsquo; will not collate between &lsquo;<samp>A</samp>&rsquo; and &lsquo;<samp>B</samp>&rsquo;,
6221 and upper-case and lower-case ASCII characters will collate together.
6222 </p>
6223 </dd>
6224 <dt><code>globstar</code></dt>
6225 <dd><p>If set, the pattern &lsquo;<samp>**</samp>&rsquo; used in a filename expansion context will
6226 match all files and zero or more directories and subdirectories.
6227 If the pattern is followed by a &lsquo;<samp>/</samp>&rsquo;, only directories and
6228 subdirectories match.
6229 </p>
6230 </dd>
6231 <dt><code>gnu_errfmt</code></dt>
6232 <dd><p>If set, shell error messages are written in the standard <small>GNU</small> error
6233 message format.
6234 </p>
6235 </dd>
6236 <dt><code>histappend</code></dt>
6237 <dd><p>If set, the history list is appended to the file named by the value
6238 of the <code>HISTFILE</code>
6239 variable when the shell exits, rather than overwriting the file.
6240 </p>
6241 </dd>
6242 <dt><code>histreedit</code></dt>
6243 <dd><p>If set, and Readline
6244 is being used, a user is given the opportunity to re-edit a
6245 failed history substitution.
6246 </p>
6247 </dd>
6248 <dt><code>histverify</code></dt>
6249 <dd><p>If set, and Readline
6250 is being used, the results of history substitution are not immediately
6251 passed to the shell parser. Instead, the resulting line is loaded into
6252 the Readline editing buffer, allowing further modification.
6253 </p>
6254 </dd>
6255 <dt><code>hostcomplete</code></dt>
6256 <dd><p>If set, and Readline is being used, Bash will attempt to perform
6257 hostname completion when a word containing a &lsquo;<samp>@</samp>&rsquo; is being
6258 completed (see <a href="#Commands-For-Completion">Commands For Completion</a>). This option is enabled
6259 by default.
6260 </p>
6261 </dd>
6262 <dt><code>huponexit</code></dt>
6263 <dd><p>If set, Bash will send <code>SIGHUP</code> to all jobs when an interactive
6264 login shell exits (see <a href="#Signals">Signals</a>).
6265 </p>
6266 </dd>
6267 <dt><code>inherit_errexit</code></dt>
6268 <dd><p>If set, command substitution inherits the value of the <code>errexit</code> option,
6269 instead of unsetting it in the subshell environment.
6270 This option is enabled when <small>POSIX</small> mode is enabled.
6271 </p>
6272 </dd>
6273 <dt><code>interactive_comments</code></dt>
6274 <dd><p>Allow a word beginning with &lsquo;<samp>#</samp>&rsquo;
6275 to cause that word and all remaining characters on that
6276 line to be ignored in an interactive shell.
6277 This option is enabled by default.
6278 </p>
6279 </dd>
6280 <dt><code>lastpipe</code></dt>
6281 <dd><p>If set, and job control is not active, the shell runs the last command of
6282 a pipeline not executed in the background in the current shell environment.
6283 </p>
6284 </dd>
6285 <dt><code>lithist</code></dt>
6286 <dd><p>If enabled, and the <code>cmdhist</code>
6287 option is enabled, multi-line commands are saved to the history with
6288 embedded newlines rather than using semicolon separators where possible.
6289 </p>
6290 </dd>
6291 <dt><code>localvar_inherit</code></dt>
6292 <dd><p>If set, local variables inherit the value and attributes of a variable of
6293 the same name that exists at a previous scope before any new value is
6294 assigned. The <var>nameref</var> attribute is not inherited.
6295 </p>
6296 </dd>
6297 <dt><code>localvar_unset</code></dt>
6298 <dd><p>If set, calling <code>unset</code> on local variables in previous function scopes
6299 marks them so subsequent lookups find them unset until that function
6300 returns. This is identical to the behavior of unsetting local variables
6301 at the current function scope.
6302 </p>
6303 </dd>
6304 <dt><code>login_shell</code></dt>
6305 <dd><p>The shell sets this option if it is started as a login shell
6306 (see <a href="#Invoking-Bash">Invoking Bash</a>).
6307 The value may not be changed.
6308 </p>
6309 </dd>
6310 <dt><code>mailwarn</code></dt>
6311 <dd><p>If set, and a file that Bash is checking for mail has been
6312 accessed since the last time it was checked, the message
6313 <code>&quot;The mail in <var>mailfile</var> has been read&quot;</code> is displayed.
6314 </p>
6315 </dd>
6316 <dt><code>no_empty_cmd_completion</code></dt>
6317 <dd><p>If set, and Readline is being used, Bash will not attempt to search
6318 the <code>PATH</code> for possible completions when completion is attempted
6319 on an empty line.
6320 </p>
6321 </dd>
6322 <dt><code>nocaseglob</code></dt>
6323 <dd><p>If set, Bash matches filenames in a case-insensitive fashion when
6324 performing filename expansion.
6325 </p>
6326 </dd>
6327 <dt><code>nocasematch</code></dt>
6328 <dd><p>If set, Bash matches patterns in a case-insensitive fashion when
6329 performing matching while executing <code>case</code> or <code>[[</code>
6330 conditional commands,
6331 when performing pattern substitution word expansions,
6332 or when filtering possible completions as part of programmable completion.
6333 </p>
6334 </dd>
6335 <dt><code>nullglob</code></dt>
6336 <dd><p>If set, Bash allows filename patterns which match no
6337 files to expand to a null string, rather than themselves.
6338 </p>
6339 </dd>
6340 <dt><code>progcomp</code></dt>
6341 <dd><p>If set, the programmable completion facilities
6342 (see <a href="#Programmable-Completion">Programmable Completion</a>) are enabled.
6343 This option is enabled by default.
6344 </p>
6345 </dd>
6346 <dt><code>progcomp_alias</code></dt>
6347 <dd><p>If set, and programmable completion is enabled, Bash treats a command
6348 name that doesn&rsquo;t have any completions as a possible alias and attempts
6349 alias expansion. If it has an alias, Bash attempts programmable
6350 completion using the command word resulting from the expanded alias.
6351 </p>
6352 </dd>
6353 <dt><code>promptvars</code></dt>
6354 <dd><p>If set, prompt strings undergo
6355 parameter expansion, command substitution, arithmetic
6356 expansion, and quote removal after being expanded
6357 as described below (see <a href="#Controlling-the-Prompt">Controlling the Prompt</a>).
6358 This option is enabled by default.
6359 </p>
6360 </dd>
6361 <dt><code>restricted_shell</code></dt>
6362 <dd><p>The shell sets this option if it is started in restricted mode
6363 (see <a href="#The-Restricted-Shell">The Restricted Shell</a>).
6364 The value may not be changed.
6365 This is not reset when the startup files are executed, allowing
6366 the startup files to discover whether or not a shell is restricted.
6367 </p>
6368 </dd>
6369 <dt><code>shift_verbose</code></dt>
6370 <dd><p>If this is set, the <code>shift</code>
6371 builtin prints an error message when the shift count exceeds the
6372 number of positional parameters.
6373 </p>
6374 </dd>
6375 <dt><code>sourcepath</code></dt>
6376 <dd><p>If set, the <code>source</code> builtin uses the value of <code>PATH</code>
6377 to find the directory containing the file supplied as an argument.
6378 This option is enabled by default.
6379 </p>
6380 </dd>
6381 <dt><code>xpg_echo</code></dt>
6382 <dd><p>If set, the <code>echo</code> builtin expands backslash-escape sequences
6383 by default.
6384 </p>
6385 </dd>
6386 </dl>
6387
6388 <p>The return status when listing options is zero if all <var>optnames</var>
6389 are enabled, non-zero otherwise.
6390 When setting or unsetting options, the return status is zero unless an
6391 <var>optname</var> is not a valid shell option.
6392 </p></dd>
6393 </dl>
6394
6395 <hr>
6396 <a name="Special-Builtins"></a>
6397 <div class="header">
6398 <p>
6399 Previous: <a href="#Modifying-Shell-Behavior" accesskey="p" rel="prev">Modifying Shell Behavior</a>, Up: <a href="#Shell-Builtin-Commands" accesskey="u" rel="up">Shell Builtin Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
6400 </div>
6401 <a name="Special-Builtins-1"></a>
6402 <h3 class="section">4.4 Special Builtins</h3>
6403 <a name="index-special-builtin-1"></a>
6404
6405 <p>For historical reasons, the <small>POSIX</small> standard has classified
6406 several builtin commands as <em>special</em>.
6407 When Bash is executing in <small>POSIX</small> mode, the special builtins
6408 differ from other builtin commands in three respects:
6409 </p>
6410 <ol>
6411 <li> Special builtins are found before shell functions during command lookup.
6412
6413 </li><li> If a special builtin returns an error status, a non-interactive shell exits.
6414
6415 </li><li> Assignment statements preceding the command stay in effect in the shell
6416 environment after the command completes.
6417 </li></ol>
6418
6419 <p>When Bash is not executing in <small>POSIX</small> mode, these builtins behave no
6420 differently than the rest of the Bash builtin commands.
6421 The Bash <small>POSIX</small> mode is described in <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>.
6422 </p>
6423 <p>These are the <small>POSIX</small> special builtins:
6424 </p><div class="example">
6425 <pre class="example">break : . continue eval exec exit export readonly return set<!-- /@w -->
6426 shift trap unset<!-- /@w -->
6427 </pre></div>
6428
6429 <hr>
6430 <a name="Shell-Variables"></a>
6431 <div class="header">
6432 <p>
6433 Next: <a href="#Bash-Features" accesskey="n" rel="next">Bash Features</a>, Previous: <a href="#Shell-Builtin-Commands" accesskey="p" rel="prev">Shell Builtin Commands</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
6434 </div>
6435 <a name="Shell-Variables-1"></a>
6436 <h2 class="chapter">5 Shell Variables</h2>
6437
6438 <table class="menu" border="0" cellspacing="0">
6439 <tr><td align="left" valign="top">&bull; <a href="#Bourne-Shell-Variables" accesskey="1">Bourne Shell Variables</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Variables which Bash uses in the same way
6440 as the Bourne Shell.
6441 </td></tr>
6442 <tr><td align="left" valign="top">&bull; <a href="#Bash-Variables" accesskey="2">Bash Variables</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">List of variables that exist in Bash.
6443 </td></tr>
6444 </table>
6445
6446 <p>This chapter describes the shell variables that Bash uses.
6447 Bash automatically assigns default values to a number of variables.
6448 </p>
6449 <hr>
6450 <a name="Bourne-Shell-Variables"></a>
6451 <div class="header">
6452 <p>
6453 Next: <a href="#Bash-Variables" accesskey="n" rel="next">Bash Variables</a>, Up: <a href="#Shell-Variables" accesskey="u" rel="up">Shell Variables</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
6454 </div>
6455 <a name="Bourne-Shell-Variables-1"></a>
6456 <h3 class="section">5.1 Bourne Shell Variables</h3>
6457
6458 <p>Bash uses certain shell variables in the same way as the Bourne shell.
6459 In some cases, Bash assigns a default value to the variable.
6460 </p>
6461 <dl compact="compact">
6462 <dt><code>CDPATH</code>
6463 <a name="index-CDPATH"></a>
6464 </dt>
6465 <dd><p>A colon-separated list of directories used as a search path for
6466 the <code>cd</code> builtin command.
6467 </p>
6468 </dd>
6469 <dt><code>HOME</code>
6470 <a name="index-HOME"></a>
6471 </dt>
6472 <dd><p>The current user&rsquo;s home directory; the default for the <code>cd</code> builtin
6473 command.
6474 The value of this variable is also used by tilde expansion
6475 (see <a href="#Tilde-Expansion">Tilde Expansion</a>).
6476 </p>
6477 </dd>
6478 <dt><code>IFS</code>
6479 <a name="index-IFS"></a>
6480 </dt>
6481 <dd><p>A list of characters that separate fields; used when the shell splits
6482 words as part of expansion.
6483 </p>
6484 </dd>
6485 <dt><code>MAIL</code>
6486 <a name="index-MAIL"></a>
6487 </dt>
6488 <dd><p>If this parameter is set to a filename or directory name
6489 and the <code>MAILPATH</code> variable
6490 is not set, Bash informs the user of the arrival of mail in
6491 the specified file or Maildir-format directory.
6492 </p>
6493 </dd>
6494 <dt><code>MAILPATH</code>
6495 <a name="index-MAILPATH"></a>
6496 </dt>
6497 <dd><p>A colon-separated list of filenames which the shell periodically checks
6498 for new mail.
6499 Each list entry can specify the message that is printed when new mail
6500 arrives in the mail file by separating the filename from the message with
6501 a &lsquo;<samp>?</samp>&rsquo;.
6502 When used in the text of the message, <code>$_</code> expands to the name of
6503 the current mail file.
6504 </p>
6505 </dd>
6506 <dt><code>OPTARG</code>
6507 <a name="index-OPTARG"></a>
6508 </dt>
6509 <dd><p>The value of the last option argument processed by the <code>getopts</code> builtin.
6510 </p>
6511 </dd>
6512 <dt><code>OPTIND</code>
6513 <a name="index-OPTIND"></a>
6514 </dt>
6515 <dd><p>The index of the last option argument processed by the <code>getopts</code> builtin.
6516 </p>
6517 </dd>
6518 <dt><code>PATH</code>
6519 <a name="index-PATH"></a>
6520 </dt>
6521 <dd><p>A colon-separated list of directories in which the shell looks for
6522 commands.
6523 A zero-length (null) directory name in the value of <code>PATH</code> indicates the
6524 current directory.
6525 A null directory name may appear as two adjacent colons, or as an initial
6526 or trailing colon.
6527 </p>
6528 </dd>
6529 <dt><code>PS1</code>
6530 <a name="index-PS1"></a>
6531 </dt>
6532 <dd><p>The primary prompt string. The default value is &lsquo;<samp>\s-\v\$ </samp>&rsquo;.
6533 See <a href="#Controlling-the-Prompt">Controlling the Prompt</a>, for the complete list of escape
6534 sequences that are expanded before <code>PS1</code> is displayed.
6535 </p>
6536 </dd>
6537 <dt><code>PS2</code>
6538 <a name="index-PS2"></a>
6539 </dt>
6540 <dd><p>The secondary prompt string. The default value is &lsquo;<samp>&gt; </samp>&rsquo;.
6541 <code>PS2</code> is expanded in the same way as <code>PS1</code> before being
6542 displayed.
6543 </p>
6544 </dd>
6545 </dl>
6546
6547 <hr>
6548 <a name="Bash-Variables"></a>
6549 <div class="header">
6550 <p>
6551 Previous: <a href="#Bourne-Shell-Variables" accesskey="p" rel="prev">Bourne Shell Variables</a>, Up: <a href="#Shell-Variables" accesskey="u" rel="up">Shell Variables</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
6552 </div>
6553 <a name="Bash-Variables-1"></a>
6554 <h3 class="section">5.2 Bash Variables</h3>
6555
6556 <p>These variables are set or used by Bash, but other shells
6557 do not normally treat them specially.
6558 </p>
6559 <p>A few variables used by Bash are described in different chapters:
6560 variables for controlling the job control facilities
6561 (see <a href="#Job-Control-Variables">Job Control Variables</a>).
6562 </p>
6563 <dl compact="compact">
6564 <dt><code>BASH</code>
6565 <a name="index-BASH"></a>
6566 </dt>
6567 <dd><p>The full pathname used to execute the current instance of Bash.
6568 </p>
6569 </dd>
6570 <dt><code>BASHOPTS</code>
6571 <a name="index-BASHOPTS"></a>
6572 </dt>
6573 <dd><p>A colon-separated list of enabled shell options. Each word in
6574 the list is a valid argument for the <samp>-s</samp> option to the
6575 <code>shopt</code> builtin command (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>).
6576 The options appearing in <code>BASHOPTS</code> are those reported
6577 as &lsquo;<samp>on</samp>&rsquo; by &lsquo;<samp>shopt</samp>&rsquo;.
6578 If this variable is in the environment when Bash
6579 starts up, each shell option in the list will be enabled before
6580 reading any startup files. This variable is readonly.
6581 </p>
6582 </dd>
6583 <dt><code>BASHPID</code>
6584 <a name="index-BASHPID"></a>
6585 </dt>
6586 <dd><p>Expands to the process ID of the current Bash process.
6587 This differs from <code>$$</code> under certain circumstances, such as subshells
6588 that do not require Bash to be re-initialized.
6589 Assignments to <code>BASHPID</code> have no effect.
6590 If <code>BASHPID</code>
6591 is unset, it loses its special properties, even if it is
6592 subsequently reset.
6593 </p>
6594 </dd>
6595 <dt><code>BASH_ALIASES</code>
6596 <a name="index-BASH_005fALIASES"></a>
6597 </dt>
6598 <dd><p>An associative array variable whose members correspond to the internal
6599 list of aliases as maintained by the <code>alias</code> builtin.
6600 (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
6601 Elements added to this array appear in the alias list; however,
6602 unsetting array elements currently does not cause aliases to be removed
6603 from the alias list.
6604 If <code>BASH_ALIASES</code>
6605 is unset, it loses its special properties, even if it is
6606 subsequently reset.
6607 </p>
6608 </dd>
6609 <dt><code>BASH_ARGC</code>
6610 <a name="index-BASH_005fARGC"></a>
6611 </dt>
6612 <dd><p>An array variable whose values are the number of parameters in each
6613 frame of the current bash execution call stack. The number of
6614 parameters to the current subroutine (shell function or script executed
6615 with <code>.</code> or <code>source</code>) is at the top of the stack. When a
6616 subroutine is executed, the number of parameters passed is pushed onto
6617 <code>BASH_ARGC</code>.
6618 The shell sets <code>BASH_ARGC</code> only when in extended debugging mode
6619 (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>
6620 for a description of the <code>extdebug</code> option to the <code>shopt</code>
6621 builtin).
6622 Setting <code>extdebug</code> after the shell has started to execute a script,
6623 or referencing this variable when <code>extdebug</code> is not set,
6624 may result in inconsistent values.
6625 </p>
6626 </dd>
6627 <dt><code>BASH_ARGV</code>
6628 <a name="index-BASH_005fARGV"></a>
6629 </dt>
6630 <dd><p>An array variable containing all of the parameters in the current bash
6631 execution call stack. The final parameter of the last subroutine call
6632 is at the top of the stack; the first parameter of the initial call is
6633 at the bottom. When a subroutine is executed, the parameters supplied
6634 are pushed onto <code>BASH_ARGV</code>.
6635 The shell sets <code>BASH_ARGV</code> only when in extended debugging mode
6636 (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>
6637 for a description of the <code>extdebug</code> option to the <code>shopt</code>
6638 builtin).
6639 Setting <code>extdebug</code> after the shell has started to execute a script,
6640 or referencing this variable when <code>extdebug</code> is not set,
6641 may result in inconsistent values.
6642 </p>
6643 </dd>
6644 <dt><code>BASH_ARGV0</code>
6645 <a name="index-BASH_005fARGV0"></a>
6646 </dt>
6647 <dd><p>When referenced, this variable expands to the name of the shell or shell
6648 script (identical to <code>$0</code>; See <a href="#Special-Parameters">Special Parameters</a>,
6649 for the description of special parameter 0).
6650 Assignment to <code>BASH_ARGV0</code>
6651 causes the value assigned to also be assigned to <code>$0</code>.
6652 If <code>BASH_ARGV0</code>
6653 is unset, it loses its special properties, even if it is
6654 subsequently reset.
6655 </p>
6656 </dd>
6657 <dt><code>BASH_CMDS</code>
6658 <a name="index-BASH_005fCMDS"></a>
6659 </dt>
6660 <dd><p>An associative array variable whose members correspond to the internal
6661 hash table of commands as maintained by the <code>hash</code> builtin
6662 (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
6663 Elements added to this array appear in the hash table; however,
6664 unsetting array elements currently does not cause command names to be removed
6665 from the hash table.
6666 If <code>BASH_CMDS</code>
6667 is unset, it loses its special properties, even if it is
6668 subsequently reset.
6669 </p>
6670 </dd>
6671 <dt><code>BASH_COMMAND</code>
6672 <a name="index-BASH_005fCOMMAND"></a>
6673 </dt>
6674 <dd><p>The command currently being executed or about to be executed, unless the
6675 shell is executing a command as the result of a trap,
6676 in which case it is the command executing at the time of the trap.
6677 </p>
6678 </dd>
6679 <dt><code>BASH_COMPAT</code>
6680 <a name="index-BASH_005fCOMPAT"></a>
6681 </dt>
6682 <dd><p>The value is used to set the shell&rsquo;s compatibility level.
6683 See <a href="#The-Shopt-Builtin">The Shopt Builtin</a>, for a description of the various compatibility
6684 levels and their effects.
6685 The value may be a decimal number (e.g., 4.2) or an integer (e.g., 42)
6686 corresponding to the desired compatibility level.
6687 If <code>BASH_COMPAT</code> is unset or set to the empty string, the compatibility
6688 level is set to the default for the current version.
6689 If <code>BASH_COMPAT</code> is set to a value that is not one of the valid
6690 compatibility levels, the shell prints an error message and sets the
6691 compatibility level to the default for the current version.
6692 The valid compatibility levels correspond to the compatibility options
6693 accepted by the <code>shopt</code> builtin described above (for example,
6694 <var>compat42</var> means that 4.2 and 42 are valid values).
6695 The current version is also a valid value.
6696 </p>
6697 </dd>
6698 <dt><code>BASH_ENV</code>
6699 <a name="index-BASH_005fENV"></a>
6700 </dt>
6701 <dd><p>If this variable is set when Bash is invoked to execute a shell
6702 script, its value is expanded and used as the name of a startup file
6703 to read before executing the script. See <a href="#Bash-Startup-Files">Bash Startup Files</a>.
6704 </p>
6705 </dd>
6706 <dt><code>BASH_EXECUTION_STRING</code>
6707 <a name="index-BASH_005fEXECUTION_005fSTRING"></a>
6708 </dt>
6709 <dd><p>The command argument to the <samp>-c</samp> invocation option.
6710 </p>
6711 </dd>
6712 <dt><code>BASH_LINENO</code>
6713 <a name="index-BASH_005fLINENO"></a>
6714 </dt>
6715 <dd><p>An array variable whose members are the line numbers in source files
6716 where each corresponding member of <var>FUNCNAME</var> was invoked.
6717 <code>${BASH_LINENO[$i]}</code> is the line number in the source file
6718 (<code>${BASH_SOURCE[$i+1]}</code>) where
6719 <code>${FUNCNAME[$i]}</code> was called (or <code>${BASH_LINENO[$i-1]}</code> if
6720 referenced within another shell function).
6721 Use <code>LINENO</code> to obtain the current line number.
6722 </p>
6723 </dd>
6724 <dt><code>BASH_LOADABLES_PATH</code>
6725 <a name="index-BASH_005fLOADABLES_005fPATH"></a>
6726 </dt>
6727 <dd><p>A colon-separated list of directories in which the shell looks for
6728 dynamically loadable builtins specified by the
6729 <code>enable</code> command.
6730 </p>
6731 </dd>
6732 <dt><code>BASH_REMATCH</code>
6733 <a name="index-BASH_005fREMATCH"></a>
6734 </dt>
6735 <dd><p>An array variable whose members are assigned by the &lsquo;<samp>=~</samp>&rsquo; binary
6736 operator to the <code>[[</code> conditional command
6737 (see <a href="#Conditional-Constructs">Conditional Constructs</a>).
6738 The element with index 0 is the portion of the string
6739 matching the entire regular expression.
6740 The element with index <var>n</var> is the portion of the
6741 string matching the <var>n</var>th parenthesized subexpression.
6742 This variable is read-only.
6743 </p>
6744 </dd>
6745 <dt><code>BASH_SOURCE</code>
6746 <a name="index-BASH_005fSOURCE"></a>
6747 </dt>
6748 <dd><p>An array variable whose members are the source filenames where the
6749 corresponding shell function names in the <code>FUNCNAME</code> array
6750 variable are defined.
6751 The shell function <code>${FUNCNAME[$i]}</code> is defined in the file
6752 <code>${BASH_SOURCE[$i]}</code> and called from <code>${BASH_SOURCE[$i+1]}</code>
6753 </p>
6754 </dd>
6755 <dt><code>BASH_SUBSHELL</code>
6756 <a name="index-BASH_005fSUBSHELL"></a>
6757 </dt>
6758 <dd><p>Incremented by one within each subshell or subshell environment when
6759 the shell begins executing in that environment.
6760 The initial value is 0.
6761 </p>
6762 </dd>
6763 <dt><code>BASH_VERSINFO</code>
6764 <a name="index-BASH_005fVERSINFO"></a>
6765 </dt>
6766 <dd><p>A readonly array variable (see <a href="#Arrays">Arrays</a>)
6767 whose members hold version information for this instance of Bash.
6768 The values assigned to the array members are as follows:
6769 </p>
6770 <dl compact="compact">
6771 <dt><code>BASH_VERSINFO[0]</code></dt>
6772 <dd><p>The major version number (the <var>release</var>).
6773 </p>
6774 </dd>
6775 <dt><code>BASH_VERSINFO[1]</code></dt>
6776 <dd><p>The minor version number (the <var>version</var>).
6777 </p>
6778 </dd>
6779 <dt><code>BASH_VERSINFO[2]</code></dt>
6780 <dd><p>The patch level.
6781 </p>
6782 </dd>
6783 <dt><code>BASH_VERSINFO[3]</code></dt>
6784 <dd><p>The build version.
6785 </p>
6786 </dd>
6787 <dt><code>BASH_VERSINFO[4]</code></dt>
6788 <dd><p>The release status (e.g., <var>beta1</var>).
6789 </p>
6790 </dd>
6791 <dt><code>BASH_VERSINFO[5]</code></dt>
6792 <dd><p>The value of <code>MACHTYPE</code>.
6793 </p></dd>
6794 </dl>
6795
6796 </dd>
6797 <dt><code>BASH_VERSION</code>
6798 <a name="index-BASH_005fVERSION"></a>
6799 </dt>
6800 <dd><p>The version number of the current instance of Bash.
6801 </p>
6802 </dd>
6803 <dt><code>BASH_XTRACEFD</code>
6804 <a name="index-BASH_005fXTRACEFD"></a>
6805 </dt>
6806 <dd><p>If set to an integer corresponding to a valid file descriptor, Bash
6807 will write the trace output generated when &lsquo;<samp>set -x</samp>&rsquo;
6808 is enabled to that file descriptor.
6809 This allows tracing output to be separated from diagnostic and error
6810 messages.
6811 The file descriptor is closed when <code>BASH_XTRACEFD</code> is unset or assigned
6812 a new value.
6813 Unsetting <code>BASH_XTRACEFD</code> or assigning it the empty string causes the
6814 trace output to be sent to the standard error.
6815 Note that setting <code>BASH_XTRACEFD</code> to 2 (the standard error file
6816 descriptor) and then unsetting it will result in the standard error
6817 being closed.
6818 </p>
6819 </dd>
6820 <dt><code>CHILD_MAX</code>
6821 <a name="index-CHILD_005fMAX"></a>
6822 </dt>
6823 <dd><p>Set the number of exited child status values for the shell to remember.
6824 Bash will not allow this value to be decreased below a <small>POSIX</small>-mandated
6825 minimum, and there is a maximum value (currently 8192) that this may
6826 not exceed.
6827 The minimum value is system-dependent.
6828 </p>
6829 </dd>
6830 <dt><code>COLUMNS</code>
6831 <a name="index-COLUMNS"></a>
6832 </dt>
6833 <dd><p>Used by the <code>select</code> command to determine the terminal width
6834 when printing selection lists.
6835 Automatically set if the <code>checkwinsize</code> option is enabled
6836 (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), or in an interactive shell upon receipt of a
6837 <code>SIGWINCH</code>.
6838 </p>
6839 </dd>
6840 <dt><code>COMP_CWORD</code>
6841 <a name="index-COMP_005fCWORD"></a>
6842 </dt>
6843 <dd><p>An index into <code>${COMP_WORDS}</code> of the word containing the current
6844 cursor position.
6845 This variable is available only in shell functions invoked by the
6846 programmable completion facilities (see <a href="#Programmable-Completion">Programmable Completion</a>).
6847 </p>
6848 </dd>
6849 <dt><code>COMP_LINE</code>
6850 <a name="index-COMP_005fLINE"></a>
6851 </dt>
6852 <dd><p>The current command line.
6853 This variable is available only in shell functions and external
6854 commands invoked by the
6855 programmable completion facilities (see <a href="#Programmable-Completion">Programmable Completion</a>).
6856 </p>
6857 </dd>
6858 <dt><code>COMP_POINT</code>
6859 <a name="index-COMP_005fPOINT"></a>
6860 </dt>
6861 <dd><p>The index of the current cursor position relative to the beginning of
6862 the current command.
6863 If the current cursor position is at the end of the current command,
6864 the value of this variable is equal to <code>${#COMP_LINE}</code>.
6865 This variable is available only in shell functions and external
6866 commands invoked by the
6867 programmable completion facilities (see <a href="#Programmable-Completion">Programmable Completion</a>).
6868 </p>
6869 </dd>
6870 <dt><code>COMP_TYPE</code>
6871 <a name="index-COMP_005fTYPE"></a>
6872 </dt>
6873 <dd><p>Set to an integer value corresponding to the type of completion attempted
6874 that caused a completion function to be called:
6875 <var>TAB</var>, for normal completion,
6876 &lsquo;<samp>?</samp>&rsquo;, for listing completions after successive tabs,
6877 &lsquo;<samp>!</samp>&rsquo;, for listing alternatives on partial word completion,
6878 &lsquo;<samp>@</samp>&rsquo;, to list completions if the word is not unmodified,
6879 or
6880 &lsquo;<samp>%</samp>&rsquo;, for menu completion.
6881 This variable is available only in shell functions and external
6882 commands invoked by the
6883 programmable completion facilities (see <a href="#Programmable-Completion">Programmable Completion</a>).
6884 </p>
6885 </dd>
6886 <dt><code>COMP_KEY</code>
6887 <a name="index-COMP_005fKEY"></a>
6888 </dt>
6889 <dd><p>The key (or final key of a key sequence) used to invoke the current
6890 completion function.
6891 </p>
6892 </dd>
6893 <dt><code>COMP_WORDBREAKS</code>
6894 <a name="index-COMP_005fWORDBREAKS"></a>
6895 </dt>
6896 <dd><p>The set of characters that the Readline library treats as word
6897 separators when performing word completion.
6898 If <code>COMP_WORDBREAKS</code> is unset, it loses its special properties,
6899 even if it is subsequently reset.
6900 </p>
6901 </dd>
6902 <dt><code>COMP_WORDS</code>
6903 <a name="index-COMP_005fWORDS"></a>
6904 </dt>
6905 <dd><p>An array variable consisting of the individual
6906 words in the current command line.
6907 The line is split into words as Readline would split it, using
6908 <code>COMP_WORDBREAKS</code> as described above.
6909 This variable is available only in shell functions invoked by the
6910 programmable completion facilities (see <a href="#Programmable-Completion">Programmable Completion</a>).
6911 </p>
6912 </dd>
6913 <dt><code>COMPREPLY</code>
6914 <a name="index-COMPREPLY"></a>
6915 </dt>
6916 <dd><p>An array variable from which Bash reads the possible completions
6917 generated by a shell function invoked by the programmable completion
6918 facility (see <a href="#Programmable-Completion">Programmable Completion</a>).
6919 Each array element contains one possible completion.
6920 </p>
6921 </dd>
6922 <dt><code>COPROC</code>
6923 <a name="index-COPROC"></a>
6924 </dt>
6925 <dd><p>An array variable created to hold the file descriptors
6926 for output from and input to an unnamed coprocess (see <a href="#Coprocesses">Coprocesses</a>).
6927 </p>
6928 </dd>
6929 <dt><code>DIRSTACK</code>
6930 <a name="index-DIRSTACK"></a>
6931 </dt>
6932 <dd><p>An array variable containing the current contents of the directory stack.
6933 Directories appear in the stack in the order they are displayed by the
6934 <code>dirs</code> builtin.
6935 Assigning to members of this array variable may be used to modify
6936 directories already in the stack, but the <code>pushd</code> and <code>popd</code>
6937 builtins must be used to add and remove directories.
6938 Assignment to this variable will not change the current directory.
6939 If <code>DIRSTACK</code> is unset, it loses its special properties, even if
6940 it is subsequently reset.
6941 </p>
6942 </dd>
6943 <dt><code>EMACS</code>
6944 <a name="index-EMACS"></a>
6945 </dt>
6946 <dd><p>If Bash finds this variable in the environment when the shell
6947 starts with value &lsquo;<samp>t</samp>&rsquo;, it assumes that the shell is running in an
6948 Emacs shell buffer and disables line editing.
6949 </p>
6950 </dd>
6951 <dt><code>ENV</code>
6952 <a name="index-ENV"></a>
6953 </dt>
6954 <dd><p>Similar to <code>BASH_ENV</code>; used when the shell is invoked in
6955 <small>POSIX</small> Mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>).
6956 </p>
6957 </dd>
6958 <dt><code>EPOCHREALTIME</code>
6959 <a name="index-EPOCHREALTIME"></a>
6960 </dt>
6961 <dd><p>Each time this parameter is referenced, it expands to the number of seconds
6962 since the Unix Epoch as a floating point value with micro-second granularity
6963 (see the documentation for the C library function <var>time</var> for the
6964 definition of Epoch).
6965 Assignments to <code>EPOCHREALTIME</code> are ignored.
6966 If <code>EPOCHREALTIME</code> is unset, it loses its special properties, even if
6967 it is subsequently reset.
6968 </p>
6969 </dd>
6970 <dt><code>EPOCHSECONDS</code>
6971 <a name="index-EPOCHSECONDS"></a>
6972 </dt>
6973 <dd><p>Each time this parameter is referenced, it expands to the number of seconds
6974 since the Unix Epoch (see the documentation for the C library function
6975 <var>time</var> for the definition of Epoch).
6976 Assignments to <code>EPOCHSECONDS</code> are ignored.
6977 If <code>EPOCHSECONDS</code> is unset, it loses its special properties, even if
6978 it is subsequently reset.
6979 </p>
6980 </dd>
6981 <dt><code>EUID</code>
6982 <a name="index-EUID"></a>
6983 </dt>
6984 <dd><p>The numeric effective user id of the current user. This variable
6985 is readonly.
6986 </p>
6987 </dd>
6988 <dt><code>EXECIGNORE</code>
6989 <a name="index-EXECIGNORE"></a>
6990 </dt>
6991 <dd><p>A colon-separated list of shell patterns (see <a href="#Pattern-Matching">Pattern Matching</a>)
6992 defining the list of filenames to be ignored by command search using
6993 <code>PATH</code>.
6994 Files whose full pathnames match one of these patterns are not considered
6995 executable files for the purposes of completion and command execution
6996 via <code>PATH</code> lookup.
6997 This does not affect the behavior of the <code>[</code>, <code>test</code>, and <code>[[</code>
6998 commands.
6999 Full pathnames in the command hash table are not subject to <code>EXECIGNORE</code>.
7000 Use this variable to ignore shared library files that have the executable
7001 bit set, but are not executable files.
7002 The pattern matching honors the setting of the <code>extglob</code> shell
7003 option.
7004 </p>
7005 </dd>
7006 <dt><code>FCEDIT</code>
7007 <a name="index-FCEDIT"></a>
7008 </dt>
7009 <dd><p>The editor used as a default by the <samp>-e</samp> option to the <code>fc</code>
7010 builtin command.
7011 </p>
7012 </dd>
7013 <dt><code>FIGNORE</code>
7014 <a name="index-FIGNORE"></a>
7015 </dt>
7016 <dd><p>A colon-separated list of suffixes to ignore when performing
7017 filename completion.
7018 A filename whose suffix matches one of the entries in
7019 <code>FIGNORE</code>
7020 is excluded from the list of matched filenames. A sample
7021 value is &lsquo;<samp>.o:~</samp>&rsquo;
7022 </p>
7023 </dd>
7024 <dt><code>FUNCNAME</code>
7025 <a name="index-FUNCNAME"></a>
7026 </dt>
7027 <dd><p>An array variable containing the names of all shell functions
7028 currently in the execution call stack.
7029 The element with index 0 is the name of any currently-executing
7030 shell function.
7031 The bottom-most element (the one with the highest index)
7032 is <code>&quot;main&quot;</code>.
7033 This variable exists only when a shell function is executing.
7034 Assignments to <code>FUNCNAME</code> have no effect.
7035 If <code>FUNCNAME</code> is unset, it loses its special properties, even if
7036 it is subsequently reset.
7037 </p>
7038 <p>This variable can be used with <code>BASH_LINENO</code> and <code>BASH_SOURCE</code>.
7039 Each element of <code>FUNCNAME</code> has corresponding elements in
7040 <code>BASH_LINENO</code> and <code>BASH_SOURCE</code> to describe the call stack.
7041 For instance, <code>${FUNCNAME[$i]}</code> was called from the file
7042 <code>${BASH_SOURCE[$i+1]}</code> at line number <code>${BASH_LINENO[$i]}</code>.
7043 The <code>caller</code> builtin displays the current call stack using this
7044 information.
7045 </p>
7046 </dd>
7047 <dt><code>FUNCNEST</code>
7048 <a name="index-FUNCNEST"></a>
7049 </dt>
7050 <dd><p>If set to a numeric value greater than 0, defines a maximum function
7051 nesting level. Function invocations that exceed this nesting level
7052 will cause the current command to abort.
7053 </p>
7054 </dd>
7055 <dt><code>GLOBIGNORE</code>
7056 <a name="index-GLOBIGNORE"></a>
7057 </dt>
7058 <dd><p>A colon-separated list of patterns defining the set of file names to
7059 be ignored by filename expansion.
7060 If a file name matched by a filename expansion pattern also matches one
7061 of the patterns in <code>GLOBIGNORE</code>, it is removed from the list
7062 of matches.
7063 The pattern matching honors the setting of the <code>extglob</code> shell
7064 option.
7065 </p>
7066 </dd>
7067 <dt><code>GROUPS</code>
7068 <a name="index-GROUPS"></a>
7069 </dt>
7070 <dd><p>An array variable containing the list of groups of which the current
7071 user is a member.
7072 Assignments to <code>GROUPS</code> have no effect.
7073 If <code>GROUPS</code> is unset, it loses its special properties, even if it is
7074 subsequently reset.
7075 </p>
7076 </dd>
7077 <dt><code>histchars</code>
7078 <a name="index-histchars"></a>
7079 </dt>
7080 <dd><p>Up to three characters which control history expansion, quick
7081 substitution, and tokenization (see <a href="#History-Interaction">History Interaction</a>).
7082 The first character is the
7083 <var>history expansion</var> character, that is, the character which signifies the
7084 start of a history expansion, normally &lsquo;<samp>!</samp>&rsquo;. The second character is the
7085 character which signifies &lsquo;quick substitution&rsquo; when seen as the first
7086 character on a line, normally &lsquo;<samp>^</samp>&rsquo;. The optional third character is the
7087 character which indicates that the remainder of the line is a comment when
7088 found as the first character of a word, usually &lsquo;<samp>#</samp>&rsquo;. The history
7089 comment character causes history substitution to be skipped for the
7090 remaining words on the line. It does not necessarily cause the shell
7091 parser to treat the rest of the line as a comment.
7092 </p>
7093 </dd>
7094 <dt><code>HISTCMD</code>
7095 <a name="index-HISTCMD"></a>
7096 </dt>
7097 <dd><p>The history number, or index in the history list, of the current
7098 command. If <code>HISTCMD</code> is unset, it loses its special properties,
7099 even if it is subsequently reset.
7100 </p>
7101 </dd>
7102 <dt><code>HISTCONTROL</code>
7103 <a name="index-HISTCONTROL"></a>
7104 </dt>
7105 <dd><p>A colon-separated list of values controlling how commands are saved on
7106 the history list.
7107 If the list of values includes &lsquo;<samp>ignorespace</samp>&rsquo;, lines which begin
7108 with a space character are not saved in the history list.
7109 A value of &lsquo;<samp>ignoredups</samp>&rsquo; causes lines which match the previous
7110 history entry to not be saved.
7111 A value of &lsquo;<samp>ignoreboth</samp>&rsquo; is shorthand for
7112 &lsquo;<samp>ignorespace</samp>&rsquo; and &lsquo;<samp>ignoredups</samp>&rsquo;.
7113 A value of &lsquo;<samp>erasedups</samp>&rsquo; causes all previous lines matching the
7114 current line to be removed from the history list before that line
7115 is saved.
7116 Any value not in the above list is ignored.
7117 If <code>HISTCONTROL</code> is unset, or does not include a valid value,
7118 all lines read by the shell parser are saved on the history list,
7119 subject to the value of <code>HISTIGNORE</code>.
7120 The second and subsequent lines of a multi-line compound command are
7121 not tested, and are added to the history regardless of the value of
7122 <code>HISTCONTROL</code>.
7123 </p>
7124 </dd>
7125 <dt><code>HISTFILE</code>
7126 <a name="index-HISTFILE"></a>
7127 </dt>
7128 <dd><p>The name of the file to which the command history is saved. The
7129 default value is <samp>~/.bash_history</samp>.
7130 </p>
7131 </dd>
7132 <dt><code>HISTFILESIZE</code>
7133 <a name="index-HISTFILESIZE"></a>
7134 </dt>
7135 <dd><p>The maximum number of lines contained in the history file.
7136 When this variable is assigned a value, the history file is truncated,
7137 if necessary, to contain no more than that number of lines
7138 by removing the oldest entries.
7139 The history file is also truncated to this size after
7140 writing it when a shell exits.
7141 If the value is 0, the history file is truncated to zero size.
7142 Non-numeric values and numeric values less than zero inhibit truncation.
7143 The shell sets the default value to the value of <code>HISTSIZE</code>
7144 after reading any startup files.
7145 </p>
7146 </dd>
7147 <dt><code>HISTIGNORE</code>
7148 <a name="index-HISTIGNORE"></a>
7149 </dt>
7150 <dd><p>A colon-separated list of patterns used to decide which command
7151 lines should be saved on the history list. Each pattern is
7152 anchored at the beginning of the line and must match the complete
7153 line (no implicit &lsquo;<samp>*</samp>&rsquo; is appended). Each pattern is tested
7154 against the line after the checks specified by <code>HISTCONTROL</code>
7155 are applied. In addition to the normal shell pattern matching
7156 characters, &lsquo;<samp>&amp;</samp>&rsquo; matches the previous history line. &lsquo;<samp>&amp;</samp>&rsquo;
7157 may be escaped using a backslash; the backslash is removed
7158 before attempting a match.
7159 The second and subsequent lines of a multi-line compound command are
7160 not tested, and are added to the history regardless of the value of
7161 <code>HISTIGNORE</code>.
7162 The pattern matching honors the setting of the <code>extglob</code> shell
7163 option.
7164 </p>
7165 <p><code>HISTIGNORE</code> subsumes the function of <code>HISTCONTROL</code>. A
7166 pattern of &lsquo;<samp>&amp;</samp>&rsquo; is identical to <code>ignoredups</code>, and a
7167 pattern of &lsquo;<samp>[ ]*</samp>&rsquo; is identical to <code>ignorespace</code>.
7168 Combining these two patterns, separating them with a colon,
7169 provides the functionality of <code>ignoreboth</code>.
7170 </p>
7171 </dd>
7172 <dt><code>HISTSIZE</code>
7173 <a name="index-HISTSIZE"></a>
7174 </dt>
7175 <dd><p>The maximum number of commands to remember on the history list.
7176 If the value is 0, commands are not saved in the history list.
7177 Numeric values less than zero result in every command being saved
7178 on the history list (there is no limit).
7179 The shell sets the default value to 500 after reading any startup files.
7180 </p>
7181 </dd>
7182 <dt><code>HISTTIMEFORMAT</code>
7183 <a name="index-HISTTIMEFORMAT"></a>
7184 </dt>
7185 <dd><p>If this variable is set and not null, its value is used as a format string
7186 for <var>strftime</var> to print the time stamp associated with each history
7187 entry displayed by the <code>history</code> builtin.
7188 If this variable is set, time stamps are written to the history file so
7189 they may be preserved across shell sessions.
7190 This uses the history comment character to distinguish timestamps from
7191 other history lines.
7192 </p>
7193 </dd>
7194 <dt><code>HOSTFILE</code>
7195 <a name="index-HOSTFILE"></a>
7196 </dt>
7197 <dd><p>Contains the name of a file in the same format as <samp>/etc/hosts</samp> that
7198 should be read when the shell needs to complete a hostname.
7199 The list of possible hostname completions may be changed while the shell
7200 is running;
7201 the next time hostname completion is attempted after the
7202 value is changed, Bash adds the contents of the new file to the
7203 existing list.
7204 If <code>HOSTFILE</code> is set, but has no value, or does not name a readable file,
7205 Bash attempts to read
7206 <samp>/etc/hosts</samp> to obtain the list of possible hostname completions.
7207 When <code>HOSTFILE</code> is unset, the hostname list is cleared.
7208 </p>
7209 </dd>
7210 <dt><code>HOSTNAME</code>
7211 <a name="index-HOSTNAME"></a>
7212 </dt>
7213 <dd><p>The name of the current host.
7214 </p>
7215 </dd>
7216 <dt><code>HOSTTYPE</code>
7217 <a name="index-HOSTTYPE"></a>
7218 </dt>
7219 <dd><p>A string describing the machine Bash is running on.
7220 </p>
7221 </dd>
7222 <dt><code>IGNOREEOF</code>
7223 <a name="index-IGNOREEOF"></a>
7224 </dt>
7225 <dd><p>Controls the action of the shell on receipt of an <code>EOF</code> character
7226 as the sole input. If set, the value denotes the number
7227 of consecutive <code>EOF</code> characters that can be read as the
7228 first character on an input line
7229 before the shell will exit. If the variable exists but does not
7230 have a numeric value, or has no value, then the default is 10.
7231 If the variable does not exist, then <code>EOF</code> signifies the end of
7232 input to the shell. This is only in effect for interactive shells.
7233 </p>
7234 </dd>
7235 <dt><code>INPUTRC</code>
7236 <a name="index-INPUTRC"></a>
7237 </dt>
7238 <dd><p>The name of the Readline initialization file, overriding the default
7239 of <samp>~/.inputrc</samp>.
7240 </p>
7241 </dd>
7242 <dt><code>INSIDE_EMACS</code>
7243 <a name="index-INSIDE_005fEMACS"></a>
7244 </dt>
7245 <dd><p>If Bash finds this variable in the environment when the shell
7246 starts, it assumes that the shell is running in an Emacs shell buffer
7247 and may disable line editing depending on the value of <code>TERM</code>.
7248 </p>
7249 </dd>
7250 <dt><code>LANG</code>
7251 <a name="index-LANG"></a>
7252 </dt>
7253 <dd><p>Used to determine the locale category for any category not specifically
7254 selected with a variable starting with <code>LC_</code>.
7255 </p>
7256 </dd>
7257 <dt><code>LC_ALL</code>
7258 <a name="index-LC_005fALL"></a>
7259 </dt>
7260 <dd><p>This variable overrides the value of <code>LANG</code> and any other
7261 <code>LC_</code> variable specifying a locale category.
7262 </p>
7263 </dd>
7264 <dt><code>LC_COLLATE</code>
7265 <a name="index-LC_005fCOLLATE"></a>
7266 </dt>
7267 <dd><p>This variable determines the collation order used when sorting the
7268 results of filename expansion, and
7269 determines the behavior of range expressions, equivalence classes,
7270 and collating sequences within filename expansion and pattern matching
7271 (see <a href="#Filename-Expansion">Filename Expansion</a>).
7272 </p>
7273 </dd>
7274 <dt><code>LC_CTYPE</code>
7275 <a name="index-LC_005fCTYPE"></a>
7276 </dt>
7277 <dd><p>This variable determines the interpretation of characters and the
7278 behavior of character classes within filename expansion and pattern
7279 matching (see <a href="#Filename-Expansion">Filename Expansion</a>).
7280 </p>
7281 </dd>
7282 <dt><code>LC_MESSAGES</code>
7283 <a name="index-LC_005fMESSAGES-1"></a>
7284 </dt>
7285 <dd><p>This variable determines the locale used to translate double-quoted
7286 strings preceded by a &lsquo;<samp>$</samp>&rsquo; (see <a href="#Locale-Translation">Locale Translation</a>).
7287 </p>
7288 </dd>
7289 <dt><code>LC_NUMERIC</code>
7290 <a name="index-LC_005fNUMERIC"></a>
7291 </dt>
7292 <dd><p>This variable determines the locale category used for number formatting.
7293 </p>
7294 </dd>
7295 <dt><code>LC_TIME</code>
7296 <a name="index-LC_005fTIME"></a>
7297 </dt>
7298 <dd><p>This variable determines the locale category used for data and time
7299 formatting.
7300 </p>
7301 </dd>
7302 <dt><code>LINENO</code>
7303 <a name="index-LINENO"></a>
7304 </dt>
7305 <dd><p>The line number in the script or shell function currently executing.
7306 </p>
7307 </dd>
7308 <dt><code>LINES</code>
7309 <a name="index-LINES"></a>
7310 </dt>
7311 <dd><p>Used by the <code>select</code> command to determine the column length
7312 for printing selection lists.
7313 Automatically set if the <code>checkwinsize</code> option is enabled
7314 (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), or in an interactive shell upon receipt of a
7315 <code>SIGWINCH</code>.
7316 </p>
7317 </dd>
7318 <dt><code>MACHTYPE</code>
7319 <a name="index-MACHTYPE"></a>
7320 </dt>
7321 <dd><p>A string that fully describes the system type on which Bash
7322 is executing, in the standard <small>GNU</small> <var>cpu-company-system</var> format.
7323 </p>
7324 </dd>
7325 <dt><code>MAILCHECK</code>
7326 <a name="index-MAILCHECK"></a>
7327 </dt>
7328 <dd><p>How often (in seconds) that the shell should check for mail in the
7329 files specified in the <code>MAILPATH</code> or <code>MAIL</code> variables.
7330 The default is 60 seconds. When it is time to check
7331 for mail, the shell does so before displaying the primary prompt.
7332 If this variable is unset, or set to a value that is not a number
7333 greater than or equal to zero, the shell disables mail checking.
7334 </p>
7335 </dd>
7336 <dt><code>MAPFILE</code>
7337 <a name="index-MAPFILE"></a>
7338 </dt>
7339 <dd><p>An array variable created to hold the text read by the
7340 <code>mapfile</code> builtin when no variable name is supplied.
7341 </p>
7342 </dd>
7343 <dt><code>OLDPWD</code>
7344 <a name="index-OLDPWD"></a>
7345 </dt>
7346 <dd><p>The previous working directory as set by the <code>cd</code> builtin.
7347 </p>
7348 </dd>
7349 <dt><code>OPTERR</code>
7350 <a name="index-OPTERR"></a>
7351 </dt>
7352 <dd><p>If set to the value 1, Bash displays error messages
7353 generated by the <code>getopts</code> builtin command.
7354 </p>
7355 </dd>
7356 <dt><code>OSTYPE</code>
7357 <a name="index-OSTYPE"></a>
7358 </dt>
7359 <dd><p>A string describing the operating system Bash is running on.
7360 </p>
7361 </dd>
7362 <dt><code>PIPESTATUS</code>
7363 <a name="index-PIPESTATUS"></a>
7364 </dt>
7365 <dd><p>An array variable (see <a href="#Arrays">Arrays</a>)
7366 containing a list of exit status values from the processes
7367 in the most-recently-executed foreground pipeline (which may
7368 contain only a single command).
7369 </p>
7370 </dd>
7371 <dt><code>POSIXLY_CORRECT</code>
7372 <a name="index-POSIXLY_005fCORRECT"></a>
7373 </dt>
7374 <dd><p>If this variable is in the environment when Bash starts, the shell
7375 enters <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>) before reading the
7376 startup files, as if the <samp>--posix</samp> invocation option had been supplied.
7377 If it is set while the shell is running, Bash enables <small>POSIX</small> mode,
7378 as if the command
7379 </p><div class="example">
7380 <pre class="example"><code>set -o posix</code>
7381 </pre></div>
7382 <p>had been executed.
7383 When the shell enters <small>POSIX</small> mode, it sets this variable if it was
7384 not already set.
7385 </p>
7386 </dd>
7387 <dt><code>PPID</code>
7388 <a name="index-PPID"></a>
7389 </dt>
7390 <dd><p>The process <small>ID</small> of the shell&rsquo;s parent process. This variable
7391 is readonly.
7392 </p>
7393 </dd>
7394 <dt><code>PROMPT_COMMAND</code>
7395 <a name="index-PROMPT_005fCOMMAND"></a>
7396 </dt>
7397 <dd><p>If set, the value is interpreted as a command to execute
7398 before the printing of each primary prompt (<code>$PS1</code>).
7399 </p>
7400 </dd>
7401 <dt><code>PROMPT_DIRTRIM</code>
7402 <a name="index-PROMPT_005fDIRTRIM"></a>
7403 </dt>
7404 <dd><p>If set to a number greater than zero, the value is used as the number of
7405 trailing directory components to retain when expanding the <code>\w</code> and
7406 <code>\W</code> prompt string escapes (see <a href="#Controlling-the-Prompt">Controlling the Prompt</a>).
7407 Characters removed are replaced with an ellipsis.
7408 </p>
7409 </dd>
7410 <dt><code>PS0</code>
7411 <a name="index-PS0"></a>
7412 </dt>
7413 <dd><p>The value of this parameter is expanded like <var>PS1</var>
7414 and displayed by interactive shells after reading a command
7415 and before the command is executed.
7416 </p>
7417 </dd>
7418 <dt><code>PS3</code>
7419 <a name="index-PS3"></a>
7420 </dt>
7421 <dd><p>The value of this variable is used as the prompt for the
7422 <code>select</code> command. If this variable is not set, the
7423 <code>select</code> command prompts with &lsquo;<samp>#? </samp>&rsquo;
7424 </p>
7425 </dd>
7426 <dt><code>PS4</code>
7427 <a name="index-PS4"></a>
7428 </dt>
7429 <dd><p>The value of this parameter is expanded like <var>PS1</var>
7430 and the expanded value is the prompt printed before the command line
7431 is echoed when the <samp>-x</samp> option is set (see <a href="#The-Set-Builtin">The Set Builtin</a>).
7432 The first character of the expanded value is replicated multiple times,
7433 as necessary, to indicate multiple levels of indirection.
7434 The default is &lsquo;<samp>+ </samp>&rsquo;.
7435 </p>
7436 </dd>
7437 <dt><code>PWD</code>
7438 <a name="index-PWD"></a>
7439 </dt>
7440 <dd><p>The current working directory as set by the <code>cd</code> builtin.
7441 </p>
7442 </dd>
7443 <dt><code>RANDOM</code>
7444 <a name="index-RANDOM"></a>
7445 </dt>
7446 <dd><p>Each time this parameter is referenced, a random integer
7447 between 0 and 32767 is generated. Assigning a value to this
7448 variable seeds the random number generator.
7449 </p>
7450 </dd>
7451 <dt><code>READLINE_LINE</code>
7452 <a name="index-READLINE_005fLINE"></a>
7453 </dt>
7454 <dd><p>The contents of the Readline line buffer, for use
7455 with &lsquo;<samp>bind -x</samp>&rsquo; (see <a href="#Bash-Builtins">Bash Builtins</a>).
7456 </p>
7457 </dd>
7458 <dt><code>READLINE_POINT</code>
7459 <a name="index-READLINE_005fPOINT"></a>
7460 </dt>
7461 <dd><p>The position of the insertion point in the Readline line buffer, for use
7462 with &lsquo;<samp>bind -x</samp>&rsquo; (see <a href="#Bash-Builtins">Bash Builtins</a>).
7463 </p>
7464 </dd>
7465 <dt><code>REPLY</code>
7466 <a name="index-REPLY"></a>
7467 </dt>
7468 <dd><p>The default variable for the <code>read</code> builtin.
7469 </p>
7470 </dd>
7471 <dt><code>SECONDS</code>
7472 <a name="index-SECONDS"></a>
7473 </dt>
7474 <dd><p>This variable expands to the number of seconds since the
7475 shell was started. Assignment to this variable resets
7476 the count to the value assigned, and the expanded value
7477 becomes the value assigned plus the number of seconds
7478 since the assignment.
7479 </p>
7480 </dd>
7481 <dt><code>SHELL</code>
7482 <a name="index-SHELL"></a>
7483 </dt>
7484 <dd><p>The full pathname to the shell is kept in this environment variable.
7485 If it is not set when the shell starts,
7486 Bash assigns to it the full pathname of the current user&rsquo;s login shell.
7487 </p>
7488 </dd>
7489 <dt><code>SHELLOPTS</code>
7490 <a name="index-SHELLOPTS"></a>
7491 </dt>
7492 <dd><p>A colon-separated list of enabled shell options. Each word in
7493 the list is a valid argument for the <samp>-o</samp> option to the
7494 <code>set</code> builtin command (see <a href="#The-Set-Builtin">The Set Builtin</a>).
7495 The options appearing in <code>SHELLOPTS</code> are those reported
7496 as &lsquo;<samp>on</samp>&rsquo; by &lsquo;<samp>set -o</samp>&rsquo;.
7497 If this variable is in the environment when Bash
7498 starts up, each shell option in the list will be enabled before
7499 reading any startup files. This variable is readonly.
7500 </p>
7501 </dd>
7502 <dt><code>SHLVL</code>
7503 <a name="index-SHLVL"></a>
7504 </dt>
7505 <dd><p>Incremented by one each time a new instance of Bash is started. This is
7506 intended to be a count of how deeply your Bash shells are nested.
7507 </p>
7508 </dd>
7509 <dt><code>TIMEFORMAT</code>
7510 <a name="index-TIMEFORMAT"></a>
7511 </dt>
7512 <dd><p>The value of this parameter is used as a format string specifying
7513 how the timing information for pipelines prefixed with the <code>time</code>
7514 reserved word should be displayed.
7515 The &lsquo;<samp>%</samp>&rsquo; character introduces an
7516 escape sequence that is expanded to a time value or other
7517 information.
7518 The escape sequences and their meanings are as
7519 follows; the braces denote optional portions.
7520 </p>
7521 <dl compact="compact">
7522 <dt><code>%%</code></dt>
7523 <dd><p>A literal &lsquo;<samp>%</samp>&rsquo;.
7524 </p>
7525 </dd>
7526 <dt><code>%[<var>p</var>][l]R</code></dt>
7527 <dd><p>The elapsed time in seconds.
7528 </p>
7529 </dd>
7530 <dt><code>%[<var>p</var>][l]U</code></dt>
7531 <dd><p>The number of CPU seconds spent in user mode.
7532 </p>
7533 </dd>
7534 <dt><code>%[<var>p</var>][l]S</code></dt>
7535 <dd><p>The number of CPU seconds spent in system mode.
7536 </p>
7537 </dd>
7538 <dt><code>%P</code></dt>
7539 <dd><p>The CPU percentage, computed as (%U + %S) / %R.
7540 </p></dd>
7541 </dl>
7542
7543 <p>The optional <var>p</var> is a digit specifying the precision, the number of
7544 fractional digits after a decimal point.
7545 A value of 0 causes no decimal point or fraction to be output.
7546 At most three places after the decimal point may be specified; values
7547 of <var>p</var> greater than 3 are changed to 3.
7548 If <var>p</var> is not specified, the value 3 is used.
7549 </p>
7550 <p>The optional <code>l</code> specifies a longer format, including minutes, of
7551 the form <var>MM</var>m<var>SS</var>.<var>FF</var>s.
7552 The value of <var>p</var> determines whether or not the fraction is included.
7553 </p>
7554 <p>If this variable is not set, Bash acts as if it had the value
7555 </p><div class="example">
7556 <pre class="example"><code>$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS'</code>
7557 </pre></div>
7558 <p>If the value is null, no timing information is displayed.
7559 A trailing newline is added when the format string is displayed.
7560 </p>
7561 </dd>
7562 <dt><code>TMOUT</code>
7563 <a name="index-TMOUT"></a>
7564 </dt>
7565 <dd><p>If set to a value greater than zero, <code>TMOUT</code> is treated as the
7566 default timeout for the <code>read</code> builtin (see <a href="#Bash-Builtins">Bash Builtins</a>).
7567 The <code>select</code> command (see <a href="#Conditional-Constructs">Conditional Constructs</a>) terminates
7568 if input does not arrive after <code>TMOUT</code> seconds when input is coming
7569 from a terminal.
7570 </p>
7571 <p>In an interactive shell, the value is interpreted as
7572 the number of seconds to wait for a line of input after issuing
7573 the primary prompt.
7574 Bash
7575 terminates after waiting for that number of seconds if a complete
7576 line of input does not arrive.
7577 </p>
7578 </dd>
7579 <dt><code>TMPDIR</code>
7580 <a name="index-TMPDIR"></a>
7581 </dt>
7582 <dd><p>If set, Bash uses its value as the name of a directory in which
7583 Bash creates temporary files for the shell&rsquo;s use.
7584 </p>
7585 </dd>
7586 <dt><code>UID</code>
7587 <a name="index-UID"></a>
7588 </dt>
7589 <dd><p>The numeric real user id of the current user. This variable is readonly.
7590 </p>
7591 </dd>
7592 </dl>
7593
7594 <hr>
7595 <a name="Bash-Features"></a>
7596 <div class="header">
7597 <p>
7598 Next: <a href="#Job-Control" accesskey="n" rel="next">Job Control</a>, Previous: <a href="#Shell-Variables" accesskey="p" rel="prev">Shell Variables</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
7599 </div>
7600 <a name="Bash-Features-2"></a>
7601 <h2 class="chapter">6 Bash Features</h2>
7602
7603 <p>This chapter describes features unique to Bash.
7604 </p>
7605 <table class="menu" border="0" cellspacing="0">
7606 <tr><td align="left" valign="top">&bull; <a href="#Invoking-Bash" accesskey="1">Invoking Bash</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Command line options that you can give
7607 to Bash.
7608 </td></tr>
7609 <tr><td align="left" valign="top">&bull; <a href="#Bash-Startup-Files" accesskey="2">Bash Startup Files</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">When and how Bash executes scripts.
7610 </td></tr>
7611 <tr><td align="left" valign="top">&bull; <a href="#Interactive-Shells" accesskey="3">Interactive Shells</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What an interactive shell is.
7612 </td></tr>
7613 <tr><td align="left" valign="top">&bull; <a href="#Bash-Conditional-Expressions" accesskey="4">Bash Conditional Expressions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Primitives used in composing expressions for
7614 the <code>test</code> builtin.
7615 </td></tr>
7616 <tr><td align="left" valign="top">&bull; <a href="#Shell-Arithmetic" accesskey="5">Shell Arithmetic</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Arithmetic on shell variables.
7617 </td></tr>
7618 <tr><td align="left" valign="top">&bull; <a href="#Aliases" accesskey="6">Aliases</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Substituting one command for another.
7619 </td></tr>
7620 <tr><td align="left" valign="top">&bull; <a href="#Arrays" accesskey="7">Arrays</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Array Variables.
7621 </td></tr>
7622 <tr><td align="left" valign="top">&bull; <a href="#The-Directory-Stack" accesskey="8">The Directory Stack</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">History of visited directories.
7623 </td></tr>
7624 <tr><td align="left" valign="top">&bull; <a href="#Controlling-the-Prompt" accesskey="9">Controlling the Prompt</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Customizing the various prompt strings.
7625 </td></tr>
7626 <tr><td align="left" valign="top">&bull; <a href="#The-Restricted-Shell">The Restricted Shell</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A more controlled mode of shell execution.
7627 </td></tr>
7628 <tr><td align="left" valign="top">&bull; <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Making Bash behave more closely to what
7629 the POSIX standard specifies.
7630 </td></tr>
7631 </table>
7632
7633 <hr>
7634 <a name="Invoking-Bash"></a>
7635 <div class="header">
7636 <p>
7637 Next: <a href="#Bash-Startup-Files" accesskey="n" rel="next">Bash Startup Files</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
7638 </div>
7639 <a name="Invoking-Bash-1"></a>
7640 <h3 class="section">6.1 Invoking Bash</h3>
7641
7642 <div class="example">
7643 <pre class="example">bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o <var>option</var>]
7644 [-O <var>shopt_option</var>] [<var>argument</var> &hellip;]
7645 bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o <var>option</var>]
7646 [-O <var>shopt_option</var>] -c <var>string</var> [<var>argument</var> &hellip;]
7647 bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o <var>option</var>]
7648 [-O <var>shopt_option</var>] [<var>argument</var> &hellip;]
7649 </pre></div>
7650
7651 <p>All of the single-character options used with the <code>set</code> builtin
7652 (see <a href="#The-Set-Builtin">The Set Builtin</a>) can be used as options when the shell is invoked.
7653 In addition, there are several multi-character
7654 options that you can use. These options must appear on the command
7655 line before the single-character options to be recognized.
7656 </p>
7657 <dl compact="compact">
7658 <dt><code>--debugger</code></dt>
7659 <dd><p>Arrange for the debugger profile to be executed before the shell
7660 starts. Turns on extended debugging mode (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>
7661 for a description of the <code>extdebug</code> option to the <code>shopt</code>
7662 builtin).
7663 </p>
7664 </dd>
7665 <dt><code>--dump-po-strings</code></dt>
7666 <dd><p>A list of all double-quoted strings preceded by &lsquo;<samp>$</samp>&rsquo;
7667 is printed on the standard output
7668 in the <small>GNU</small> <code>gettext</code> PO (portable object) file format.
7669 Equivalent to <samp>-D</samp> except for the output format.
7670 </p>
7671 </dd>
7672 <dt><code>--dump-strings</code></dt>
7673 <dd><p>Equivalent to <samp>-D</samp>.
7674 </p>
7675 </dd>
7676 <dt><code>--help</code></dt>
7677 <dd><p>Display a usage message on standard output and exit successfully.
7678 </p>
7679 </dd>
7680 <dt><code>--init-file <var>filename</var></code></dt>
7681 <dt><code>--rcfile <var>filename</var></code></dt>
7682 <dd><p>Execute commands from <var>filename</var> (instead of <samp>~/.bashrc</samp>)
7683 in an interactive shell.
7684 </p>
7685 </dd>
7686 <dt><code>--login</code></dt>
7687 <dd><p>Equivalent to <samp>-l</samp>.
7688 </p>
7689 </dd>
7690 <dt><code>--noediting</code></dt>
7691 <dd><p>Do not use the <small>GNU</small> Readline library (see <a href="#Command-Line-Editing">Command Line Editing</a>)
7692 to read command lines when the shell is interactive.
7693 </p>
7694 </dd>
7695 <dt><code>--noprofile</code></dt>
7696 <dd><p>Don&rsquo;t load the system-wide startup file <samp>/etc/profile</samp>
7697 or any of the personal initialization files
7698 <samp>~/.bash_profile</samp>, <samp>~/.bash_login</samp>, or <samp>~/.profile</samp>
7699 when Bash is invoked as a login shell.
7700 </p>
7701 </dd>
7702 <dt><code>--norc</code></dt>
7703 <dd><p>Don&rsquo;t read the <samp>~/.bashrc</samp> initialization file in an
7704 interactive shell. This is on by default if the shell is
7705 invoked as <code>sh</code>.
7706 </p>
7707 </dd>
7708 <dt><code>--posix</code></dt>
7709 <dd><p>Change the behavior of Bash where the default operation differs
7710 from the <small>POSIX</small> standard to match the standard. This
7711 is intended to make Bash behave as a strict superset of that
7712 standard. See <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>, for a description of the Bash
7713 <small>POSIX</small> mode.
7714 </p>
7715 </dd>
7716 <dt><code>--restricted</code></dt>
7717 <dd><p>Make the shell a restricted shell (see <a href="#The-Restricted-Shell">The Restricted Shell</a>).
7718 </p>
7719 </dd>
7720 <dt><code>--verbose</code></dt>
7721 <dd><p>Equivalent to <samp>-v</samp>. Print shell input lines as they&rsquo;re read.
7722 </p>
7723 </dd>
7724 <dt><code>--version</code></dt>
7725 <dd><p>Show version information for this instance of
7726 Bash on the standard output and exit successfully.
7727 </p></dd>
7728 </dl>
7729
7730 <p>There are several single-character options that may be supplied at
7731 invocation which are not available with the <code>set</code> builtin.
7732 </p>
7733 <dl compact="compact">
7734 <dt><code>-c</code></dt>
7735 <dd><p>Read and execute commands from the first non-option argument
7736 <var>command_string</var>, then exit.
7737 If there are arguments after the <var>command_string</var>,
7738 the first argument is assigned to <code>$0</code>
7739 and any remaining arguments are assigned to the positional parameters.
7740 The assignment to <code>$0</code> sets the name of the shell, which is used
7741 in warning and error messages.
7742 </p>
7743 </dd>
7744 <dt><code>-i</code></dt>
7745 <dd><p>Force the shell to run interactively. Interactive shells are
7746 described in <a href="#Interactive-Shells">Interactive Shells</a>.
7747 </p>
7748 </dd>
7749 <dt><code>-l</code></dt>
7750 <dd><p>Make this shell act as if it had been directly invoked by login.
7751 When the shell is interactive, this is equivalent to starting a
7752 login shell with &lsquo;<samp>exec -l bash</samp>&rsquo;.
7753 When the shell is not interactive, the login shell startup files will
7754 be executed.
7755 &lsquo;<samp>exec bash -l</samp>&rsquo; or &lsquo;<samp>exec bash --login</samp>&rsquo;
7756 will replace the current shell with a Bash login shell.
7757 See <a href="#Bash-Startup-Files">Bash Startup Files</a>, for a description of the special behavior
7758 of a login shell.
7759 </p>
7760 </dd>
7761 <dt><code>-r</code></dt>
7762 <dd><p>Make the shell a restricted shell (see <a href="#The-Restricted-Shell">The Restricted Shell</a>).
7763 </p>
7764 </dd>
7765 <dt><code>-s</code></dt>
7766 <dd><p>If this option is present, or if no arguments remain after option
7767 processing, then commands are read from the standard input.
7768 This option allows the positional parameters to be set
7769 when invoking an interactive shell or when reading input
7770 through a pipe.
7771 </p>
7772 </dd>
7773 <dt><code>-D</code></dt>
7774 <dd><p>A list of all double-quoted strings preceded by &lsquo;<samp>$</samp>&rsquo;
7775 is printed on the standard output.
7776 These are the strings that
7777 are subject to language translation when the current locale
7778 is not <code>C</code> or <code>POSIX</code> (see <a href="#Locale-Translation">Locale Translation</a>).
7779 This implies the <samp>-n</samp> option; no commands will be executed.
7780 </p>
7781 </dd>
7782 <dt><code>[-+]O [<var>shopt_option</var>]</code></dt>
7783 <dd><p><var>shopt_option</var> is one of the shell options accepted by the
7784 <code>shopt</code> builtin (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>).
7785 If <var>shopt_option</var> is present, <samp>-O</samp> sets the value of that option;
7786 <samp>+O</samp> unsets it.
7787 If <var>shopt_option</var> is not supplied, the names and values of the shell
7788 options accepted by <code>shopt</code> are printed on the standard output.
7789 If the invocation option is <samp>+O</samp>, the output is displayed in a format
7790 that may be reused as input.
7791 </p>
7792 </dd>
7793 <dt><code>--</code></dt>
7794 <dd><p>A <code>--</code> signals the end of options and disables further option
7795 processing.
7796 Any arguments after the <code>--</code> are treated as filenames and arguments.
7797 </p></dd>
7798 </dl>
7799
7800 <a name="index-login-shell"></a>
7801 <p>A <em>login</em> shell is one whose first character of argument zero is
7802 &lsquo;<samp>-</samp>&rsquo;, or one invoked with the <samp>--login</samp> option.
7803 </p>
7804 <a name="index-interactive-shell"></a>
7805 <p>An <em>interactive</em> shell is one started without non-option arguments,
7806 unless <samp>-s</samp> is specified,
7807 without specifying the <samp>-c</samp> option, and whose input and output are both
7808 connected to terminals (as determined by <code>isatty(3)</code>), or one
7809 started with the <samp>-i</samp> option. See <a href="#Interactive-Shells">Interactive Shells</a>, for more
7810 information.
7811 </p>
7812 <p>If arguments remain after option processing, and neither the
7813 <samp>-c</samp> nor the <samp>-s</samp>
7814 option has been supplied, the first argument is assumed to
7815 be the name of a file containing shell commands (see <a href="#Shell-Scripts">Shell Scripts</a>).
7816 When Bash is invoked in this fashion, <code>$0</code>
7817 is set to the name of the file, and the positional parameters
7818 are set to the remaining arguments.
7819 Bash reads and executes commands from this file, then exits.
7820 Bash&rsquo;s exit status is the exit status of the last command executed
7821 in the script. If no commands are executed, the exit status is 0.
7822 </p>
7823 <hr>
7824 <a name="Bash-Startup-Files"></a>
7825 <div class="header">
7826 <p>
7827 Next: <a href="#Interactive-Shells" accesskey="n" rel="next">Interactive Shells</a>, Previous: <a href="#Invoking-Bash" accesskey="p" rel="prev">Invoking Bash</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
7828 </div>
7829 <a name="Bash-Startup-Files-1"></a>
7830 <h3 class="section">6.2 Bash Startup Files</h3>
7831 <a name="index-startup-files"></a>
7832
7833 <p>This section describes how Bash executes its startup files.
7834 If any of the files exist but cannot be read, Bash reports an error.
7835 Tildes are expanded in filenames as described above under
7836 Tilde Expansion (see <a href="#Tilde-Expansion">Tilde Expansion</a>).
7837 </p>
7838 <p>Interactive shells are described in <a href="#Interactive-Shells">Interactive Shells</a>.
7839 </p>
7840 <a name="Invoked-as-an-interactive-login-shell_002c-or-with-_002d_002dlogin"></a>
7841 <h4 class="subsubheading">Invoked as an interactive login shell, or with <samp>--login</samp></h4>
7842
7843 <p>When Bash is invoked as an interactive login shell, or as a
7844 non-interactive shell with the <samp>--login</samp> option, it first reads and
7845 executes commands from the file <samp>/etc/profile</samp>, if that file exists.
7846 After reading that file, it looks for <samp>~/.bash_profile</samp>,
7847 <samp>~/.bash_login</samp>, and <samp>~/.profile</samp>, in that order, and reads
7848 and executes commands from the first one that exists and is readable.
7849 The <samp>--noprofile</samp> option may be used when the shell is started to
7850 inhibit this behavior.
7851 </p>
7852 <p>When an interactive login shell exits,
7853 or a non-interactive login shell executes the <code>exit</code> builtin command,
7854 Bash reads and executes commands from
7855 the file <samp>~/.bash_logout</samp>, if it exists.
7856 </p>
7857 <a name="Invoked-as-an-interactive-non_002dlogin-shell"></a>
7858 <h4 class="subsubheading">Invoked as an interactive non-login shell</h4>
7859
7860 <p>When an interactive shell that is not a login shell is started, Bash
7861 reads and executes commands from <samp>~/.bashrc</samp>, if that file exists.
7862 This may be inhibited by using the <samp>--norc</samp> option.
7863 The <samp>--rcfile <var>file</var></samp> option will force Bash to read and
7864 execute commands from <var>file</var> instead of <samp>~/.bashrc</samp>.
7865 </p>
7866 <p>So, typically, your <samp>~/.bash_profile</samp> contains the line
7867 </p><div class="example">
7868 <pre class="example"><code>if [ -f ~/.bashrc ]; then . ~/.bashrc; fi</code>
7869 </pre></div>
7870 <p>after (or before) any login-specific initializations.
7871 </p>
7872 <a name="Invoked-non_002dinteractively"></a>
7873 <h4 class="subsubheading">Invoked non-interactively</h4>
7874
7875 <p>When Bash is started non-interactively, to run a shell script,
7876 for example, it looks for the variable <code>BASH_ENV</code> in the environment,
7877 expands its value if it appears there, and uses the expanded value as
7878 the name of a file to read and execute. Bash behaves as if the
7879 following command were executed:
7880 </p><div class="example">
7881 <pre class="example"><code>if [ -n &quot;$BASH_ENV&quot; ]; then . &quot;$BASH_ENV&quot;; fi</code>
7882 </pre></div>
7883 <p>but the value of the <code>PATH</code> variable is not used to search for the
7884 filename.
7885 </p>
7886 <p>As noted above, if a non-interactive shell is invoked with the
7887 <samp>--login</samp> option, Bash attempts to read and execute commands from the
7888 login shell startup files.
7889 </p>
7890 <a name="Invoked-with-name-sh"></a>
7891 <h4 class="subsubheading">Invoked with name <code>sh</code></h4>
7892
7893 <p>If Bash is invoked with the name <code>sh</code>, it tries to mimic the
7894 startup behavior of historical versions of <code>sh</code> as closely as
7895 possible, while conforming to the <small>POSIX</small> standard as well.
7896 </p>
7897 <p>When invoked as an interactive login shell, or as a non-interactive
7898 shell with the <samp>--login</samp> option, it first attempts to read
7899 and execute commands from <samp>/etc/profile</samp> and <samp>~/.profile</samp>, in
7900 that order.
7901 The <samp>--noprofile</samp> option may be used to inhibit this behavior.
7902 When invoked as an interactive shell with the name <code>sh</code>, Bash
7903 looks for the variable <code>ENV</code>, expands its value if it is defined,
7904 and uses the expanded value as the name of a file to read and execute.
7905 Since a shell invoked as <code>sh</code> does not attempt to read and execute
7906 commands from any other startup files, the <samp>--rcfile</samp> option has
7907 no effect.
7908 A non-interactive shell invoked with the name <code>sh</code> does not attempt
7909 to read any other startup files.
7910 </p>
7911 <p>When invoked as <code>sh</code>, Bash enters <small>POSIX</small> mode after
7912 the startup files are read.
7913 </p>
7914 <a name="Invoked-in-POSIX-mode"></a>
7915 <h4 class="subsubheading">Invoked in <small>POSIX</small> mode</h4>
7916
7917 <p>When Bash is started in <small>POSIX</small> mode, as with the
7918 <samp>--posix</samp> command line option, it follows the <small>POSIX</small> standard
7919 for startup files.
7920 In this mode, interactive shells expand the <code>ENV</code> variable
7921 and commands are read and executed from the file whose name is the
7922 expanded value.
7923 No other startup files are read.
7924 </p>
7925 <a name="Invoked-by-remote-shell-daemon"></a>
7926 <h4 class="subsubheading">Invoked by remote shell daemon</h4>
7927
7928 <p>Bash attempts to determine when it is being run with its standard input
7929 connected to a network connection, as when executed by the remote shell
7930 daemon, usually <code>rshd</code>, or the secure shell daemon <code>sshd</code>.
7931 If Bash determines it is being run in
7932 this fashion, it reads and executes commands from <samp>~/.bashrc</samp>, if that
7933 file exists and is readable.
7934 It will not do this if invoked as <code>sh</code>.
7935 The <samp>--norc</samp> option may be used to inhibit this behavior, and the
7936 <samp>--rcfile</samp> option may be used to force another file to be read, but
7937 neither <code>rshd</code> nor <code>sshd</code> generally invoke the shell with those
7938 options or allow them to be specified.
7939 </p>
7940 <a name="Invoked-with-unequal-effective-and-real-UID_002fGIDs"></a>
7941 <h4 class="subsubheading">Invoked with unequal effective and real <small>UID/GID</small>s</h4>
7942
7943 <p>If Bash is started with the effective user (group) id not equal to the
7944 real user (group) id, and the <samp>-p</samp> option is not supplied, no startup
7945 files are read, shell functions are not inherited from the environment,
7946 the <code>SHELLOPTS</code>, <code>BASHOPTS</code>, <code>CDPATH</code>, and <code>GLOBIGNORE</code>
7947 variables, if they appear in the environment, are ignored, and the effective
7948 user id is set to the real user id.
7949 If the <samp>-p</samp> option is supplied at invocation, the startup behavior is
7950 the same, but the effective user id is not reset.
7951 </p>
7952 <hr>
7953 <a name="Interactive-Shells"></a>
7954 <div class="header">
7955 <p>
7956 Next: <a href="#Bash-Conditional-Expressions" accesskey="n" rel="next">Bash Conditional Expressions</a>, Previous: <a href="#Bash-Startup-Files" accesskey="p" rel="prev">Bash Startup Files</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
7957 </div>
7958 <a name="Interactive-Shells-1"></a>
7959 <h3 class="section">6.3 Interactive Shells</h3>
7960 <a name="index-interactive-shell-1"></a>
7961 <a name="index-shell_002c-interactive"></a>
7962
7963 <table class="menu" border="0" cellspacing="0">
7964 <tr><td align="left" valign="top">&bull; <a href="#What-is-an-Interactive-Shell_003f" accesskey="1">What is an Interactive Shell?</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What determines whether a shell is Interactive.
7965 </td></tr>
7966 <tr><td align="left" valign="top">&bull; <a href="#Is-this-Shell-Interactive_003f" accesskey="2">Is this Shell Interactive?</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to tell if a shell is interactive.
7967 </td></tr>
7968 <tr><td align="left" valign="top">&bull; <a href="#Interactive-Shell-Behavior" accesskey="3">Interactive Shell Behavior</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What changes in a interactive shell?
7969 </td></tr>
7970 </table>
7971
7972 <hr>
7973 <a name="What-is-an-Interactive-Shell_003f"></a>
7974 <div class="header">
7975 <p>
7976 Next: <a href="#Is-this-Shell-Interactive_003f" accesskey="n" rel="next">Is this Shell Interactive?</a>, Up: <a href="#Interactive-Shells" accesskey="u" rel="up">Interactive Shells</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
7977 </div>
7978 <a name="What-is-an-Interactive-Shell_003f-1"></a>
7979 <h4 class="subsection">6.3.1 What is an Interactive Shell?</h4>
7980
7981 <p>An interactive shell
7982 is one started without non-option arguments, unless <samp>-s</samp> is
7983 specified, without specifying the <samp>-c</samp> option, and
7984 whose input and error output are both
7985 connected to terminals (as determined by <code>isatty(3)</code>),
7986 or one started with the <samp>-i</samp> option.
7987 </p>
7988 <p>An interactive shell generally reads from and writes to a user&rsquo;s
7989 terminal.
7990 </p>
7991 <p>The <samp>-s</samp> invocation option may be used to set the positional parameters
7992 when an interactive shell is started.
7993 </p>
7994 <hr>
7995 <a name="Is-this-Shell-Interactive_003f"></a>
7996 <div class="header">
7997 <p>
7998 Next: <a href="#Interactive-Shell-Behavior" accesskey="n" rel="next">Interactive Shell Behavior</a>, Previous: <a href="#What-is-an-Interactive-Shell_003f" accesskey="p" rel="prev">What is an Interactive Shell?</a>, Up: <a href="#Interactive-Shells" accesskey="u" rel="up">Interactive Shells</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
7999 </div>
8000 <a name="Is-this-Shell-Interactive_003f-1"></a>
8001 <h4 class="subsection">6.3.2 Is this Shell Interactive?</h4>
8002
8003 <p>To determine within a startup script whether or not Bash is
8004 running interactively,
8005 test the value of the &lsquo;<samp>-</samp>&rsquo; special parameter.
8006 It contains <code>i</code> when the shell is interactive. For example:
8007 </p>
8008 <div class="example">
8009 <pre class="example">case &quot;$-&quot; in
8010 *i*) echo This shell is interactive ;;
8011 *) echo This shell is not interactive ;;
8012 esac
8013 </pre></div>
8014
8015 <p>Alternatively, startup scripts may examine the variable
8016 <code>PS1</code>; it is unset in non-interactive shells, and set in
8017 interactive shells. Thus:
8018 </p>
8019 <div class="example">
8020 <pre class="example">if [ -z &quot;$PS1&quot; ]; then
8021 echo This shell is not interactive
8022 else
8023 echo This shell is interactive
8024 fi
8025 </pre></div>
8026
8027 <hr>
8028 <a name="Interactive-Shell-Behavior"></a>
8029 <div class="header">
8030 <p>
8031 Previous: <a href="#Is-this-Shell-Interactive_003f" accesskey="p" rel="prev">Is this Shell Interactive?</a>, Up: <a href="#Interactive-Shells" accesskey="u" rel="up">Interactive Shells</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
8032 </div>
8033 <a name="Interactive-Shell-Behavior-1"></a>
8034 <h4 class="subsection">6.3.3 Interactive Shell Behavior</h4>
8035
8036 <p>When the shell is running interactively, it changes its behavior in
8037 several ways.
8038 </p>
8039 <ol>
8040 <li> Startup files are read and executed as described in <a href="#Bash-Startup-Files">Bash Startup Files</a>.
8041
8042 </li><li> Job Control (see <a href="#Job-Control">Job Control</a>) is enabled by default. When job
8043 control is in effect, Bash ignores the keyboard-generated job control
8044 signals <code>SIGTTIN</code>, <code>SIGTTOU</code>, and <code>SIGTSTP</code>.
8045
8046 </li><li> Bash expands and displays <code>PS1</code> before reading the first line
8047 of a command, and expands and displays <code>PS2</code> before reading the
8048 second and subsequent lines of a multi-line command.
8049 Bash expands and displays <code>PS0</code> after it reads a command but before
8050 executing it.
8051 See <a href="#Controlling-the-Prompt">Controlling the Prompt</a>, for a complete list of prompt
8052 string escape sequences.
8053
8054 </li><li> Bash executes the value of the <code>PROMPT_COMMAND</code> variable as a command
8055 before printing the primary prompt, <code>$PS1</code>
8056 (see <a href="#Bash-Variables">Bash Variables</a>).
8057
8058 </li><li> Readline (see <a href="#Command-Line-Editing">Command Line Editing</a>) is used to read commands from
8059 the user&rsquo;s terminal.
8060
8061 </li><li> Bash inspects the value of the <code>ignoreeof</code> option to <code>set -o</code>
8062 instead of exiting immediately when it receives an <code>EOF</code> on its
8063 standard input when reading a command (see <a href="#The-Set-Builtin">The Set Builtin</a>).
8064
8065 </li><li> Command history (see <a href="#Bash-History-Facilities">Bash History Facilities</a>)
8066 and history expansion (see <a href="#History-Interaction">History Interaction</a>)
8067 are enabled by default.
8068 Bash will save the command history to the file named by <code>$HISTFILE</code>
8069 when a shell with history enabled exits.
8070
8071 </li><li> Alias expansion (see <a href="#Aliases">Aliases</a>) is performed by default.
8072
8073 </li><li> In the absence of any traps, Bash ignores <code>SIGTERM</code>
8074 (see <a href="#Signals">Signals</a>).
8075
8076 </li><li> In the absence of any traps, <code>SIGINT</code> is caught and handled
8077 (see <a href="#Signals">Signals</a>).
8078 <code>SIGINT</code> will interrupt some shell builtins.
8079
8080 </li><li> An interactive login shell sends a <code>SIGHUP</code> to all jobs on exit
8081 if the <code>huponexit</code> shell option has been enabled (see <a href="#Signals">Signals</a>).
8082
8083 </li><li> The <samp>-n</samp> invocation option is ignored, and &lsquo;<samp>set -n</samp>&rsquo; has
8084 no effect (see <a href="#The-Set-Builtin">The Set Builtin</a>).
8085
8086 </li><li> Bash will check for mail periodically, depending on the values of the
8087 <code>MAIL</code>, <code>MAILPATH</code>, and <code>MAILCHECK</code> shell variables
8088 (see <a href="#Bash-Variables">Bash Variables</a>).
8089
8090 </li><li> Expansion errors due to references to unbound shell variables after
8091 &lsquo;<samp>set -u</samp>&rsquo; has been enabled will not cause the shell to exit
8092 (see <a href="#The-Set-Builtin">The Set Builtin</a>).
8093
8094 </li><li> The shell will not exit on expansion errors caused by <var>var</var> being unset
8095 or null in <code>${<var>var</var>:?<var>word</var>}</code> expansions
8096 (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
8097
8098 </li><li> Redirection errors encountered by shell builtins will not cause the
8099 shell to exit.
8100
8101 </li><li> When running in <small>POSIX</small> mode, a special builtin returning an error
8102 status will not cause the shell to exit (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>).
8103
8104 </li><li> A failed <code>exec</code> will not cause the shell to exit
8105 (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
8106
8107 </li><li> Parser syntax errors will not cause the shell to exit.
8108
8109 </li><li> Simple spelling correction for directory arguments to the <code>cd</code>
8110 builtin is enabled by default (see the description of the <code>cdspell</code>
8111 option to the <code>shopt</code> builtin in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>).
8112
8113 </li><li> The shell will check the value of the <code>TMOUT</code> variable and exit
8114 if a command is not read within the specified number of seconds after
8115 printing <code>$PS1</code> (see <a href="#Bash-Variables">Bash Variables</a>).
8116
8117 </li></ol>
8118
8119 <hr>
8120 <a name="Bash-Conditional-Expressions"></a>
8121 <div class="header">
8122 <p>
8123 Next: <a href="#Shell-Arithmetic" accesskey="n" rel="next">Shell Arithmetic</a>, Previous: <a href="#Interactive-Shells" accesskey="p" rel="prev">Interactive Shells</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
8124 </div>
8125 <a name="Bash-Conditional-Expressions-1"></a>
8126 <h3 class="section">6.4 Bash Conditional Expressions</h3>
8127 <a name="index-expressions_002c-conditional"></a>
8128
8129 <p>Conditional expressions are used by the <code>[[</code> compound command
8130 and the <code>test</code> and <code>[</code> builtin commands. The <code>test</code>
8131 and <code>[</code> commands determine their behavior based on the number
8132 of arguments; see the descriptions of those commands for any other
8133 command-specific actions.
8134 </p>
8135 <p>Expressions may be unary or binary,
8136 and are formed from the following primaries.
8137 Unary expressions are often used to examine the status of a file.
8138 There are string operators and numeric comparison operators as well.
8139 Bash handles several filenames specially when they are used in
8140 expressions.
8141 If the operating system on which Bash is running provides these
8142 special files, Bash will use them; otherwise it will emulate them
8143 internally with this behavior:
8144 If the <var>file</var> argument to one of the primaries is of the form
8145 <samp>/dev/fd/<var>N</var></samp>, then file descriptor <var>N</var> is checked.
8146 If the <var>file</var> argument to one of the primaries is one of
8147 <samp>/dev/stdin</samp>, <samp>/dev/stdout</samp>, or <samp>/dev/stderr</samp>, file
8148 descriptor 0, 1, or 2, respectively, is checked.
8149 </p>
8150 <p>When used with <code>[[</code>, the &lsquo;<samp>&lt;</samp>&rsquo; and &lsquo;<samp>&gt;</samp>&rsquo; operators sort
8151 lexicographically using the current locale.
8152 The <code>test</code> command uses ASCII ordering.
8153 </p>
8154 <p>Unless otherwise specified, primaries that operate on files follow symbolic
8155 links and operate on the target of the link, rather than the link itself.
8156 </p>
8157 <dl compact="compact">
8158 <dt><code>-a <var>file</var></code></dt>
8159 <dd><p>True if <var>file</var> exists.
8160 </p>
8161 </dd>
8162 <dt><code>-b <var>file</var></code></dt>
8163 <dd><p>True if <var>file</var> exists and is a block special file.
8164 </p>
8165 </dd>
8166 <dt><code>-c <var>file</var></code></dt>
8167 <dd><p>True if <var>file</var> exists and is a character special file.
8168 </p>
8169 </dd>
8170 <dt><code>-d <var>file</var></code></dt>
8171 <dd><p>True if <var>file</var> exists and is a directory.
8172 </p>
8173 </dd>
8174 <dt><code>-e <var>file</var></code></dt>
8175 <dd><p>True if <var>file</var> exists.
8176 </p>
8177 </dd>
8178 <dt><code>-f <var>file</var></code></dt>
8179 <dd><p>True if <var>file</var> exists and is a regular file.
8180 </p>
8181 </dd>
8182 <dt><code>-g <var>file</var></code></dt>
8183 <dd><p>True if <var>file</var> exists and its set-group-id bit is set.
8184 </p>
8185 </dd>
8186 <dt><code>-h <var>file</var></code></dt>
8187 <dd><p>True if <var>file</var> exists and is a symbolic link.
8188 </p>
8189 </dd>
8190 <dt><code>-k <var>file</var></code></dt>
8191 <dd><p>True if <var>file</var> exists and its &quot;sticky&quot; bit is set.
8192 </p>
8193 </dd>
8194 <dt><code>-p <var>file</var></code></dt>
8195 <dd><p>True if <var>file</var> exists and is a named pipe (FIFO).
8196 </p>
8197 </dd>
8198 <dt><code>-r <var>file</var></code></dt>
8199 <dd><p>True if <var>file</var> exists and is readable.
8200 </p>
8201 </dd>
8202 <dt><code>-s <var>file</var></code></dt>
8203 <dd><p>True if <var>file</var> exists and has a size greater than zero.
8204 </p>
8205 </dd>
8206 <dt><code>-t <var>fd</var></code></dt>
8207 <dd><p>True if file descriptor <var>fd</var> is open and refers to a terminal.
8208 </p>
8209 </dd>
8210 <dt><code>-u <var>file</var></code></dt>
8211 <dd><p>True if <var>file</var> exists and its set-user-id bit is set.
8212 </p>
8213 </dd>
8214 <dt><code>-w <var>file</var></code></dt>
8215 <dd><p>True if <var>file</var> exists and is writable.
8216 </p>
8217 </dd>
8218 <dt><code>-x <var>file</var></code></dt>
8219 <dd><p>True if <var>file</var> exists and is executable.
8220 </p>
8221 </dd>
8222 <dt><code>-G <var>file</var></code></dt>
8223 <dd><p>True if <var>file</var> exists and is owned by the effective group id.
8224 </p>
8225 </dd>
8226 <dt><code>-L <var>file</var></code></dt>
8227 <dd><p>True if <var>file</var> exists and is a symbolic link.
8228 </p>
8229 </dd>
8230 <dt><code>-N <var>file</var></code></dt>
8231 <dd><p>True if <var>file</var> exists and has been modified since it was last read.
8232 </p>
8233 </dd>
8234 <dt><code>-O <var>file</var></code></dt>
8235 <dd><p>True if <var>file</var> exists and is owned by the effective user id.
8236 </p>
8237 </dd>
8238 <dt><code>-S <var>file</var></code></dt>
8239 <dd><p>True if <var>file</var> exists and is a socket.
8240 </p>
8241 </dd>
8242 <dt><code><var>file1</var> -ef <var>file2</var></code></dt>
8243 <dd><p>True if <var>file1</var> and <var>file2</var> refer to the same device and
8244 inode numbers.
8245 </p>
8246 </dd>
8247 <dt><code><var>file1</var> -nt <var>file2</var></code></dt>
8248 <dd><p>True if <var>file1</var> is newer (according to modification date)
8249 than <var>file2</var>, or if <var>file1</var> exists and <var>file2</var> does not.
8250 </p>
8251 </dd>
8252 <dt><code><var>file1</var> -ot <var>file2</var></code></dt>
8253 <dd><p>True if <var>file1</var> is older than <var>file2</var>,
8254 or if <var>file2</var> exists and <var>file1</var> does not.
8255 </p>
8256 </dd>
8257 <dt><code>-o <var>optname</var></code></dt>
8258 <dd><p>True if the shell option <var>optname</var> is enabled.
8259 The list of options appears in the description of the <samp>-o</samp>
8260 option to the <code>set</code> builtin (see <a href="#The-Set-Builtin">The Set Builtin</a>).
8261 </p>
8262 </dd>
8263 <dt><code>-v <var>varname</var></code></dt>
8264 <dd><p>True if the shell variable <var>varname</var> is set (has been assigned a value).
8265 </p>
8266 </dd>
8267 <dt><code>-R <var>varname</var></code></dt>
8268 <dd><p>True if the shell variable <var>varname</var> is set and is a name reference.
8269 </p>
8270 </dd>
8271 <dt><code>-z <var>string</var></code></dt>
8272 <dd><p>True if the length of <var>string</var> is zero.
8273 </p>
8274 </dd>
8275 <dt><code>-n <var>string</var></code></dt>
8276 <dt><code><var>string</var></code></dt>
8277 <dd><p>True if the length of <var>string</var> is non-zero.
8278 </p>
8279 </dd>
8280 <dt><code><var>string1</var> == <var>string2</var></code></dt>
8281 <dt><code><var>string1</var> = <var>string2</var></code></dt>
8282 <dd><p>True if the strings are equal.
8283 When used with the <code>[[</code> command, this performs pattern matching as
8284 described above (see <a href="#Conditional-Constructs">Conditional Constructs</a>).
8285 </p>
8286 <p>&lsquo;<samp>=</samp>&rsquo; should be used with the <code>test</code> command for <small>POSIX</small> conformance.
8287 </p>
8288 </dd>
8289 <dt><code><var>string1</var> != <var>string2</var></code></dt>
8290 <dd><p>True if the strings are not equal.
8291 </p>
8292 </dd>
8293 <dt><code><var>string1</var> &lt; <var>string2</var></code></dt>
8294 <dd><p>True if <var>string1</var> sorts before <var>string2</var> lexicographically.
8295 </p>
8296 </dd>
8297 <dt><code><var>string1</var> &gt; <var>string2</var></code></dt>
8298 <dd><p>True if <var>string1</var> sorts after <var>string2</var> lexicographically.
8299 </p>
8300 </dd>
8301 <dt><code><var>arg1</var> OP <var>arg2</var></code></dt>
8302 <dd><p><code>OP</code> is one of
8303 &lsquo;<samp>-eq</samp>&rsquo;, &lsquo;<samp>-ne</samp>&rsquo;, &lsquo;<samp>-lt</samp>&rsquo;, &lsquo;<samp>-le</samp>&rsquo;, &lsquo;<samp>-gt</samp>&rsquo;, or &lsquo;<samp>-ge</samp>&rsquo;.
8304 These arithmetic binary operators return true if <var>arg1</var>
8305 is equal to, not equal to, less than, less than or equal to,
8306 greater than, or greater than or equal to <var>arg2</var>,
8307 respectively. <var>Arg1</var> and <var>arg2</var>
8308 may be positive or negative integers.
8309 When used with the <code>[[</code> command, <var>Arg1</var> and <var>Arg2</var>
8310 are evaluated as arithmetic expressions (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>).
8311 </p></dd>
8312 </dl>
8313
8314 <hr>
8315 <a name="Shell-Arithmetic"></a>
8316 <div class="header">
8317 <p>
8318 Next: <a href="#Aliases" accesskey="n" rel="next">Aliases</a>, Previous: <a href="#Bash-Conditional-Expressions" accesskey="p" rel="prev">Bash Conditional Expressions</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
8319 </div>
8320 <a name="Shell-Arithmetic-1"></a>
8321 <h3 class="section">6.5 Shell Arithmetic</h3>
8322 <a name="index-arithmetic_002c-shell"></a>
8323 <a name="index-shell-arithmetic"></a>
8324 <a name="index-expressions_002c-arithmetic"></a>
8325 <a name="index-evaluation_002c-arithmetic"></a>
8326 <a name="index-arithmetic-evaluation"></a>
8327
8328 <p>The shell allows arithmetic expressions to be evaluated, as one of
8329 the shell expansions or by using the <code>((</code> compound command, the
8330 <code>let</code> builtin, or the <samp>-i</samp> option to the <code>declare</code> builtin.
8331 </p>
8332 <p>Evaluation is done in fixed-width integers with no check for overflow,
8333 though division by 0 is trapped and flagged as an error.
8334 The operators and their precedence, associativity, and values
8335 are the same as in the C language.
8336 The following list of operators is grouped into levels of
8337 equal-precedence operators.
8338 The levels are listed in order of decreasing precedence.
8339 </p>
8340 <dl compact="compact">
8341 <dt><code><var>id</var>++ <var>id</var>--</code></dt>
8342 <dd><p>variable post-increment and post-decrement
8343 </p>
8344 </dd>
8345 <dt><code>++<var>id</var> --<var>id</var></code></dt>
8346 <dd><p>variable pre-increment and pre-decrement
8347 </p>
8348 </dd>
8349 <dt><code>- +</code></dt>
8350 <dd><p>unary minus and plus
8351 </p>
8352 </dd>
8353 <dt><code>! ~</code></dt>
8354 <dd><p>logical and bitwise negation
8355 </p>
8356 </dd>
8357 <dt><code>**</code></dt>
8358 <dd><p>exponentiation
8359 </p>
8360 </dd>
8361 <dt><code>* / %</code></dt>
8362 <dd><p>multiplication, division, remainder
8363 </p>
8364 </dd>
8365 <dt><code>+ -</code></dt>
8366 <dd><p>addition, subtraction
8367 </p>
8368 </dd>
8369 <dt><code>&lt;&lt; &gt;&gt;</code></dt>
8370 <dd><p>left and right bitwise shifts
8371 </p>
8372 </dd>
8373 <dt><code>&lt;= &gt;= &lt; &gt;</code></dt>
8374 <dd><p>comparison
8375 </p>
8376 </dd>
8377 <dt><code>== !=</code></dt>
8378 <dd><p>equality and inequality
8379 </p>
8380 </dd>
8381 <dt><code>&amp;</code></dt>
8382 <dd><p>bitwise AND
8383 </p>
8384 </dd>
8385 <dt><code>^</code></dt>
8386 <dd><p>bitwise exclusive OR
8387 </p>
8388 </dd>
8389 <dt><code>|</code></dt>
8390 <dd><p>bitwise OR
8391 </p>
8392 </dd>
8393 <dt><code>&amp;&amp;</code></dt>
8394 <dd><p>logical AND
8395 </p>
8396 </dd>
8397 <dt><code>||</code></dt>
8398 <dd><p>logical OR
8399 </p>
8400 </dd>
8401 <dt><code>expr ? expr : expr</code></dt>
8402 <dd><p>conditional operator
8403 </p>
8404 </dd>
8405 <dt><code>= *= /= %= += -= &lt;&lt;= &gt;&gt;= &amp;= ^= |=</code></dt>
8406 <dd><p>assignment
8407 </p>
8408 </dd>
8409 <dt><code>expr1 , expr2</code></dt>
8410 <dd><p>comma
8411 </p></dd>
8412 </dl>
8413
8414 <p>Shell variables are allowed as operands; parameter expansion is
8415 performed before the expression is evaluated.
8416 Within an expression, shell variables may also be referenced by name
8417 without using the parameter expansion syntax.
8418 A shell variable that is null or unset evaluates to 0 when referenced
8419 by name without using the parameter expansion syntax.
8420 The value of a variable is evaluated as an arithmetic expression
8421 when it is referenced, or when a variable which has been given the
8422 <var>integer</var> attribute using &lsquo;<samp>declare -i</samp>&rsquo; is assigned a value.
8423 A null value evaluates to 0.
8424 A shell variable need not have its <var>integer</var> attribute turned on
8425 to be used in an expression.
8426 </p>
8427 <p>Constants with a leading 0 are interpreted as octal numbers.
8428 A leading &lsquo;<samp>0x</samp>&rsquo; or &lsquo;<samp>0X</samp>&rsquo; denotes hexadecimal. Otherwise,
8429 numbers take the form [<var>base</var><code>#</code>]<var>n</var>, where the optional <var>base</var>
8430 is a decimal number between 2 and 64 representing the arithmetic
8431 base, and <var>n</var> is a number in that base.
8432 If <var>base</var><code>#</code> is omitted, then base 10 is used.
8433 When specifying <var>n</var>,
8434 the digits greater than 9 are represented by the lowercase letters,
8435 the uppercase letters, &lsquo;<samp>@</samp>&rsquo;, and &lsquo;<samp>_</samp>&rsquo;, in that order.
8436 If <var>base</var> is less than or equal to 36, lowercase and uppercase
8437 letters may be used interchangeably to represent numbers between 10
8438 and 35.
8439 </p>
8440 <p>Operators are evaluated in order of precedence. Sub-expressions in
8441 parentheses are evaluated first and may override the precedence
8442 rules above.
8443 </p>
8444 <hr>
8445 <a name="Aliases"></a>
8446 <div class="header">
8447 <p>
8448 Next: <a href="#Arrays" accesskey="n" rel="next">Arrays</a>, Previous: <a href="#Shell-Arithmetic" accesskey="p" rel="prev">Shell Arithmetic</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
8449 </div>
8450 <a name="Aliases-1"></a>
8451 <h3 class="section">6.6 Aliases</h3>
8452 <a name="index-alias-expansion"></a>
8453
8454 <p><var>Aliases</var> allow a string to be substituted for a word when it is used
8455 as the first word of a simple command.
8456 The shell maintains a list of aliases that may be set and unset with
8457 the <code>alias</code> and <code>unalias</code> builtin commands.
8458 </p>
8459 <p>The first word of each simple command, if unquoted, is checked to see
8460 if it has an alias.
8461 If so, that word is replaced by the text of the alias.
8462 The characters &lsquo;<samp>/</samp>&rsquo;, &lsquo;<samp>$</samp>&rsquo;, &lsquo;<samp>`</samp>&rsquo;, &lsquo;<samp>=</samp>&rsquo; and any of the
8463 shell metacharacters or quoting characters listed above may not appear
8464 in an alias name.
8465 The replacement text may contain any valid
8466 shell input, including shell metacharacters.
8467 The first word of the replacement text is tested for
8468 aliases, but a word that is identical to an alias being expanded
8469 is not expanded a second time.
8470 This means that one may alias <code>ls</code> to <code>&quot;ls -F&quot;</code>,
8471 for instance, and Bash does not try to recursively expand the
8472 replacement text.
8473 If the last character of the alias value is a
8474 <var>blank</var>, then the next command word following the
8475 alias is also checked for alias expansion.
8476 </p>
8477 <p>Aliases are created and listed with the <code>alias</code>
8478 command, and removed with the <code>unalias</code> command.
8479 </p>
8480 <p>There is no mechanism for using arguments in the replacement text,
8481 as in <code>csh</code>.
8482 If arguments are needed, a shell function should be used
8483 (see <a href="#Shell-Functions">Shell Functions</a>).
8484 </p>
8485 <p>Aliases are not expanded when the shell is not interactive,
8486 unless the <code>expand_aliases</code> shell option is set using
8487 <code>shopt</code> (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>).
8488 </p>
8489 <p>The rules concerning the definition and use of aliases are
8490 somewhat confusing. Bash
8491 always reads at least one complete line of input,
8492 and all lines that make up a compound command,
8493 before executing any of the commands on that line or the compound command.
8494 Aliases are expanded when a
8495 command is read, not when it is executed. Therefore, an
8496 alias definition appearing on the same line as another
8497 command does not take effect until the next line of input is read.
8498 The commands following the alias definition
8499 on that line are not affected by the new alias.
8500 This behavior is also an issue when functions are executed.
8501 Aliases are expanded when a function definition is read,
8502 not when the function is executed, because a function definition
8503 is itself a command. As a consequence, aliases
8504 defined in a function are not available until after that
8505 function is executed. To be safe, always put
8506 alias definitions on a separate line, and do not use <code>alias</code>
8507 in compound commands.
8508 </p>
8509 <p>For almost every purpose, shell functions are preferred over aliases.
8510 </p>
8511 <hr>
8512 <a name="Arrays"></a>
8513 <div class="header">
8514 <p>
8515 Next: <a href="#The-Directory-Stack" accesskey="n" rel="next">The Directory Stack</a>, Previous: <a href="#Aliases" accesskey="p" rel="prev">Aliases</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
8516 </div>
8517 <a name="Arrays-1"></a>
8518 <h3 class="section">6.7 Arrays</h3>
8519 <a name="index-arrays"></a>
8520
8521 <p>Bash provides one-dimensional indexed and associative array variables.
8522 Any variable may be used as an indexed array;
8523 the <code>declare</code> builtin will explicitly declare an array.
8524 There is no maximum
8525 limit on the size of an array, nor any requirement that members
8526 be indexed or assigned contiguously.
8527 Indexed arrays are referenced using integers (including arithmetic
8528 expressions (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>)) and are zero-based;
8529 associative arrays use arbitrary strings.
8530 Unless otherwise noted, indexed array indices must be non-negative integers.
8531 </p>
8532 <p>An indexed array is created automatically if any variable is assigned to
8533 using the syntax
8534 </p><div class="example">
8535 <pre class="example"><var>name</var>[<var>subscript</var>]=<var>value</var>
8536 </pre></div>
8537
8538 <p>The <var>subscript</var>
8539 is treated as an arithmetic expression that must evaluate to a number.
8540 To explicitly declare an array, use
8541 </p><div class="example">
8542 <pre class="example">declare -a <var>name</var>
8543 </pre></div>
8544 <p>The syntax
8545 </p><div class="example">
8546 <pre class="example">declare -a <var>name</var>[<var>subscript</var>]
8547 </pre></div>
8548 <p>is also accepted; the <var>subscript</var> is ignored.
8549 </p>
8550 <p>Associative arrays are created using
8551 </p><div class="example">
8552 <pre class="example">declare -A <var>name</var>.
8553 </pre></div>
8554
8555 <p>Attributes may be
8556 specified for an array variable using the <code>declare</code> and
8557 <code>readonly</code> builtins. Each attribute applies to all members of
8558 an array.
8559 </p>
8560 <p>Arrays are assigned to using compound assignments of the form
8561 </p><div class="example">
8562 <pre class="example"><var>name</var>=(<var>value1</var> <var>value2</var> &hellip; )
8563 </pre></div>
8564 <p>where each
8565 <var>value</var> is of the form <code>[<var>subscript</var>]=</code><var>string</var>.
8566 Indexed array assignments do not require anything but <var>string</var>.
8567 When assigning to indexed arrays, if
8568 the optional subscript is supplied, that index is assigned to;
8569 otherwise the index of the element assigned is the last index assigned
8570 to by the statement plus one. Indexing starts at zero.
8571 </p>
8572 <p>When assigning to an associative array, the subscript is required.
8573 </p>
8574 <p>This syntax is also accepted by the <code>declare</code>
8575 builtin. Individual array elements may be assigned to using the
8576 <code><var>name</var>[<var>subscript</var>]=<var>value</var></code> syntax introduced above.
8577 </p>
8578 <p>When assigning to an indexed array, if <var>name</var>
8579 is subscripted by a negative number, that number is
8580 interpreted as relative to one greater than the maximum index of
8581 <var>name</var>, so negative indices count back from the end of the
8582 array, and an index of -1 references the last element.
8583 </p>
8584 <p>Any element of an array may be referenced using
8585 <code>${<var>name</var>[<var>subscript</var>]}</code>.
8586 The braces are required to avoid
8587 conflicts with the shell&rsquo;s filename expansion operators. If the
8588 <var>subscript</var> is &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;, the word expands to all members
8589 of the array <var>name</var>. These subscripts differ only when the word
8590 appears within double quotes.
8591 If the word is double-quoted,
8592 <code>${<var>name</var>[*]}</code> expands to a single word with
8593 the value of each array member separated by the first character of the
8594 <code>IFS</code> variable, and <code>${<var>name</var>[@]}</code> expands each element of
8595 <var>name</var> to a separate word. When there are no array members,
8596 <code>${<var>name</var>[@]}</code> expands to nothing.
8597 If the double-quoted expansion occurs within a word, the expansion of
8598 the first parameter is joined with the beginning part of the original
8599 word, and the expansion of the last parameter is joined with the last
8600 part of the original word.
8601 This is analogous to the
8602 expansion of the special parameters &lsquo;<samp>@</samp>&rsquo; and &lsquo;<samp>*</samp>&rsquo;.
8603 <code>${#<var>name</var>[<var>subscript</var>]}</code> expands to the length of
8604 <code>${<var>name</var>[<var>subscript</var>]}</code>.
8605 If <var>subscript</var> is &lsquo;<samp>@</samp>&rsquo; or
8606 &lsquo;<samp>*</samp>&rsquo;, the expansion is the number of elements in the array.
8607 If the <var>subscript</var>
8608 used to reference an element of an indexed array
8609 evaluates to a number less than zero, it is
8610 interpreted as relative to one greater than the maximum index of the array,
8611 so negative indices count back from the end of the array,
8612 and an index of -1 refers to the last element.
8613 </p>
8614 <p>Referencing an array variable without a subscript is equivalent to
8615 referencing with a subscript of 0.
8616 Any reference to a variable using a valid subscript is legal, and
8617 <code>bash</code> will create an array if necessary.
8618 </p>
8619 <p>An array variable is considered set if a subscript has been assigned a
8620 value. The null string is a valid value.
8621 </p>
8622 <p>It is possible to obtain the keys (indices) of an array as well as the values.
8623 ${!<var>name</var>[@]} and ${!<var>name</var>[*]} expand to the indices
8624 assigned in array variable <var>name</var>.
8625 The treatment when in double quotes is similar to the expansion of the
8626 special parameters &lsquo;<samp>@</samp>&rsquo; and &lsquo;<samp>*</samp>&rsquo; within double quotes.
8627 </p>
8628 <p>The <code>unset</code> builtin is used to destroy arrays.
8629 <code>unset <var>name</var>[<var>subscript</var>]</code>
8630 destroys the array element at index <var>subscript</var>.
8631 Negative subscripts to indexed arrays are interpreted as described above.
8632 Unsetting the last element of an array variable does not unset the variable.
8633 <code>unset <var>name</var></code>, where <var>name</var> is an array, removes the
8634 entire array. A subscript of &lsquo;<samp>*</samp>&rsquo; or &lsquo;<samp>@</samp>&rsquo; also removes the
8635 entire array.
8636 </p>
8637 <p>When using a variable name with a subscript as an argument to a command,
8638 such as with <code>unset</code>, without using the word expansion syntax
8639 described above, the argument is subject to the shell&rsquo;s filename expansion.
8640 If filename expansion is not desired, the argument should be quoted.
8641 </p>
8642 <p>The <code>declare</code>, <code>local</code>, and <code>readonly</code>
8643 builtins each accept a <samp>-a</samp> option to specify an indexed
8644 array and a <samp>-A</samp> option to specify an associative array.
8645 If both options are supplied, <samp>-A</samp> takes precedence.
8646 The <code>read</code> builtin accepts a <samp>-a</samp>
8647 option to assign a list of words read from the standard input
8648 to an array, and can read values from the standard input into
8649 individual array elements. The <code>set</code> and <code>declare</code>
8650 builtins display array values in a way that allows them to be
8651 reused as input.
8652 </p>
8653 <hr>
8654 <a name="The-Directory-Stack"></a>
8655 <div class="header">
8656 <p>
8657 Next: <a href="#Controlling-the-Prompt" accesskey="n" rel="next">Controlling the Prompt</a>, Previous: <a href="#Arrays" accesskey="p" rel="prev">Arrays</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
8658 </div>
8659 <a name="The-Directory-Stack-1"></a>
8660 <h3 class="section">6.8 The Directory Stack</h3>
8661 <a name="index-directory-stack"></a>
8662
8663 <table class="menu" border="0" cellspacing="0">
8664 <tr><td align="left" valign="top">&bull; <a href="#Directory-Stack-Builtins" accesskey="1">Directory Stack Builtins</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Bash builtin commands to manipulate
8665 the directory stack.
8666 </td></tr>
8667 </table>
8668
8669 <p>The directory stack is a list of recently-visited directories. The
8670 <code>pushd</code> builtin adds directories to the stack as it changes
8671 the current directory, and the <code>popd</code> builtin removes specified
8672 directories from the stack and changes the current directory to
8673 the directory removed. The <code>dirs</code> builtin displays the contents
8674 of the directory stack. The current directory is always the &quot;top&quot;
8675 of the directory stack.
8676 </p>
8677 <p>The contents of the directory stack are also visible
8678 as the value of the <code>DIRSTACK</code> shell variable.
8679 </p>
8680 <hr>
8681 <a name="Directory-Stack-Builtins"></a>
8682 <div class="header">
8683 <p>
8684 Up: <a href="#The-Directory-Stack" accesskey="u" rel="up">The Directory Stack</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
8685 </div>
8686 <a name="Directory-Stack-Builtins-1"></a>
8687 <h4 class="subsection">6.8.1 Directory Stack Builtins</h4>
8688
8689 <dl compact="compact">
8690 <dt><code>dirs</code></dt>
8691 <dd><a name="index-dirs"></a>
8692 <div class="example">
8693 <pre class="example">dirs [-clpv] [+<var>N</var> | -<var>N</var>]
8694 </pre></div>
8695
8696 <p>Display the list of currently remembered directories. Directories
8697 are added to the list with the <code>pushd</code> command; the
8698 <code>popd</code> command removes directories from the list.
8699 The current directory is always the first directory in the stack.
8700 </p>
8701 <dl compact="compact">
8702 <dt><code>-c</code></dt>
8703 <dd><p>Clears the directory stack by deleting all of the elements.
8704 </p></dd>
8705 <dt><code>-l</code></dt>
8706 <dd><p>Produces a listing using full pathnames;
8707 the default listing format uses a tilde to denote the home directory.
8708 </p></dd>
8709 <dt><code>-p</code></dt>
8710 <dd><p>Causes <code>dirs</code> to print the directory stack with one entry per
8711 line.
8712 </p></dd>
8713 <dt><code>-v</code></dt>
8714 <dd><p>Causes <code>dirs</code> to print the directory stack with one entry per
8715 line, prefixing each entry with its index in the stack.
8716 </p></dd>
8717 <dt><code>+<var>N</var></code></dt>
8718 <dd><p>Displays the <var>N</var>th directory (counting from the left of the
8719 list printed by <code>dirs</code> when invoked without options), starting
8720 with zero.
8721 </p></dd>
8722 <dt><code>-<var>N</var></code></dt>
8723 <dd><p>Displays the <var>N</var>th directory (counting from the right of the
8724 list printed by <code>dirs</code> when invoked without options), starting
8725 with zero.
8726 </p></dd>
8727 </dl>
8728
8729 </dd>
8730 <dt><code>popd</code></dt>
8731 <dd><a name="index-popd"></a>
8732 <div class="example">
8733 <pre class="example">popd [-n] [+<var>N</var> | -<var>N</var>]
8734 </pre></div>
8735
8736 <p>When no arguments are given, <code>popd</code>
8737 removes the top directory from the stack and
8738 performs a <code>cd</code> to the new top directory.
8739 The elements are numbered from 0 starting at the first directory
8740 listed with <code>dirs</code>; that is, <code>popd</code> is equivalent to <code>popd +0</code>.
8741 </p>
8742 <dl compact="compact">
8743 <dt><code>-n</code></dt>
8744 <dd><p>Suppresses the normal change of directory when removing directories
8745 from the stack, so that only the stack is manipulated.
8746 </p></dd>
8747 <dt><code>+<var>N</var></code></dt>
8748 <dd><p>Removes the <var>N</var>th directory (counting from the left of the
8749 list printed by <code>dirs</code>), starting with zero.
8750 </p></dd>
8751 <dt><code>-<var>N</var></code></dt>
8752 <dd><p>Removes the <var>N</var>th directory (counting from the right of the
8753 list printed by <code>dirs</code>), starting with zero.
8754 </p></dd>
8755 </dl>
8756
8757 <a name="index-pushd"></a>
8758 </dd>
8759 <dt><code>pushd</code></dt>
8760 <dd><div class="example">
8761 <pre class="example">pushd [-n] [<var>+N</var> | <var>-N</var> | <var>dir</var>]
8762 </pre></div>
8763
8764 <p>Save the current directory on the top of the directory stack
8765 and then <code>cd</code> to <var>dir</var>.
8766 With no arguments, <code>pushd</code> exchanges the top two directories
8767 and makes the new top the current directory.
8768 </p>
8769 <dl compact="compact">
8770 <dt><code>-n</code></dt>
8771 <dd><p>Suppresses the normal change of directory when rotating or
8772 adding directories to the stack, so that only the stack is manipulated.
8773 </p></dd>
8774 <dt><code>+<var>N</var></code></dt>
8775 <dd><p>Brings the <var>N</var>th directory (counting from the left of the
8776 list printed by <code>dirs</code>, starting with zero) to the top of
8777 the list by rotating the stack.
8778 </p></dd>
8779 <dt><code>-<var>N</var></code></dt>
8780 <dd><p>Brings the <var>N</var>th directory (counting from the right of the
8781 list printed by <code>dirs</code>, starting with zero) to the top of
8782 the list by rotating the stack.
8783 </p></dd>
8784 <dt><code><var>dir</var></code></dt>
8785 <dd><p>Makes <var>dir</var> be the top of the stack, making
8786 it the new current directory as if it had been supplied as an argument
8787 to the <code>cd</code> builtin.
8788 </p></dd>
8789 </dl>
8790 </dd>
8791 </dl>
8792
8793 <hr>
8794 <a name="Controlling-the-Prompt"></a>
8795 <div class="header">
8796 <p>
8797 Next: <a href="#The-Restricted-Shell" accesskey="n" rel="next">The Restricted Shell</a>, Previous: <a href="#The-Directory-Stack" accesskey="p" rel="prev">The Directory Stack</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
8798 </div>
8799 <a name="Controlling-the-Prompt-1"></a>
8800 <h3 class="section">6.9 Controlling the Prompt</h3>
8801 <a name="index-prompting"></a>
8802
8803 <p>The value of the variable <code>PROMPT_COMMAND</code> is examined just before
8804 Bash prints each primary prompt. If <code>PROMPT_COMMAND</code> is set and
8805 has a non-null value, then the
8806 value is executed just as if it had been typed on the command line.
8807 </p>
8808 <p>In addition, the following table describes the special characters which
8809 can appear in the prompt variables <code>PS0</code>, <code>PS1</code>, <code>PS2</code>, and
8810 <code>PS4</code>:
8811 </p>
8812 <dl compact="compact">
8813 <dt><code>\a</code></dt>
8814 <dd><p>A bell character.
8815 </p></dd>
8816 <dt><code>\d</code></dt>
8817 <dd><p>The date, in &quot;Weekday Month Date&quot; format (e.g., &quot;Tue May 26&quot;).
8818 </p></dd>
8819 <dt><code>\D{<var>format</var>}</code></dt>
8820 <dd><p>The <var>format</var> is passed to <code>strftime</code>(3) and the result is inserted
8821 into the prompt string; an empty <var>format</var> results in a locale-specific
8822 time representation. The braces are required.
8823 </p></dd>
8824 <dt><code>\e</code></dt>
8825 <dd><p>An escape character.
8826 </p></dd>
8827 <dt><code>\h</code></dt>
8828 <dd><p>The hostname, up to the first &lsquo;.&rsquo;.
8829 </p></dd>
8830 <dt><code>\H</code></dt>
8831 <dd><p>The hostname.
8832 </p></dd>
8833 <dt><code>\j</code></dt>
8834 <dd><p>The number of jobs currently managed by the shell.
8835 </p></dd>
8836 <dt><code>\l</code></dt>
8837 <dd><p>The basename of the shell&rsquo;s terminal device name.
8838 </p></dd>
8839 <dt><code>\n</code></dt>
8840 <dd><p>A newline.
8841 </p></dd>
8842 <dt><code>\r</code></dt>
8843 <dd><p>A carriage return.
8844 </p></dd>
8845 <dt><code>\s</code></dt>
8846 <dd><p>The name of the shell, the basename of <code>$0</code> (the portion
8847 following the final slash).
8848 </p></dd>
8849 <dt><code>\t</code></dt>
8850 <dd><p>The time, in 24-hour HH:MM:SS format.
8851 </p></dd>
8852 <dt><code>\T</code></dt>
8853 <dd><p>The time, in 12-hour HH:MM:SS format.
8854 </p></dd>
8855 <dt><code>\@</code></dt>
8856 <dd><p>The time, in 12-hour am/pm format.
8857 </p></dd>
8858 <dt><code>\A</code></dt>
8859 <dd><p>The time, in 24-hour HH:MM format.
8860 </p></dd>
8861 <dt><code>\u</code></dt>
8862 <dd><p>The username of the current user.
8863 </p></dd>
8864 <dt><code>\v</code></dt>
8865 <dd><p>The version of Bash (e.g., 2.00)
8866 </p></dd>
8867 <dt><code>\V</code></dt>
8868 <dd><p>The release of Bash, version + patchlevel (e.g., 2.00.0)
8869 </p></dd>
8870 <dt><code>\w</code></dt>
8871 <dd><p>The current working directory, with <code>$HOME</code> abbreviated with a tilde
8872 (uses the <code>$PROMPT_DIRTRIM</code> variable).
8873 </p></dd>
8874 <dt><code>\W</code></dt>
8875 <dd><p>The basename of <code>$PWD</code>, with <code>$HOME</code> abbreviated with a tilde.
8876 </p></dd>
8877 <dt><code>\!</code></dt>
8878 <dd><p>The history number of this command.
8879 </p></dd>
8880 <dt><code>\#</code></dt>
8881 <dd><p>The command number of this command.
8882 </p></dd>
8883 <dt><code>\$</code></dt>
8884 <dd><p>If the effective uid is 0, <code>#</code>, otherwise <code>$</code>.
8885 </p></dd>
8886 <dt><code>\<var>nnn</var></code></dt>
8887 <dd><p>The character whose ASCII code is the octal value <var>nnn</var>.
8888 </p></dd>
8889 <dt><code>\\</code></dt>
8890 <dd><p>A backslash.
8891 </p></dd>
8892 <dt><code>\[</code></dt>
8893 <dd><p>Begin a sequence of non-printing characters. This could be used to
8894 embed a terminal control sequence into the prompt.
8895 </p></dd>
8896 <dt><code>\]</code></dt>
8897 <dd><p>End a sequence of non-printing characters.
8898 </p></dd>
8899 </dl>
8900
8901 <p>The command number and the history number are usually different:
8902 the history number of a command is its position in the history
8903 list, which may include commands restored from the history file
8904 (see <a href="#Bash-History-Facilities">Bash History Facilities</a>), while the command number is
8905 the position in the sequence of commands executed during the current
8906 shell session.
8907 </p>
8908 <p>After the string is decoded, it is expanded via
8909 parameter expansion, command substitution, arithmetic
8910 expansion, and quote removal, subject to the value of the
8911 <code>promptvars</code> shell option (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>).
8912 </p>
8913 <hr>
8914 <a name="The-Restricted-Shell"></a>
8915 <div class="header">
8916 <p>
8917 Next: <a href="#Bash-POSIX-Mode" accesskey="n" rel="next">Bash POSIX Mode</a>, Previous: <a href="#Controlling-the-Prompt" accesskey="p" rel="prev">Controlling the Prompt</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
8918 </div>
8919 <a name="The-Restricted-Shell-1"></a>
8920 <h3 class="section">6.10 The Restricted Shell</h3>
8921 <a name="index-restricted-shell"></a>
8922
8923 <p>If Bash is started with the name <code>rbash</code>, or the
8924 <samp>--restricted</samp>
8925 or
8926 <samp>-r</samp>
8927 option is supplied at invocation, the shell becomes restricted.
8928 A restricted shell is used to
8929 set up an environment more controlled than the standard shell.
8930 A restricted shell behaves identically to <code>bash</code>
8931 with the exception that the following are disallowed or not performed:
8932 </p>
8933 <ul>
8934 <li> Changing directories with the <code>cd</code> builtin.
8935 </li><li> Setting or unsetting the values of the <code>SHELL</code>, <code>PATH</code>,
8936 <code>ENV</code>, or <code>BASH_ENV</code> variables.
8937 </li><li> Specifying command names containing slashes.
8938 </li><li> Specifying a filename containing a slash as an argument to the <code>.</code>
8939 builtin command.
8940 </li><li> Specifying a filename containing a slash as an argument to the <samp>-p</samp>
8941 option to the <code>hash</code> builtin command.
8942 </li><li> Importing function definitions from the shell environment at startup.
8943 </li><li> Parsing the value of <code>SHELLOPTS</code> from the shell environment at startup.
8944 </li><li> Redirecting output using the &lsquo;<samp>&gt;</samp>&rsquo;, &lsquo;<samp>&gt;|</samp>&rsquo;, &lsquo;<samp>&lt;&gt;</samp>&rsquo;, &lsquo;<samp>&gt;&amp;</samp>&rsquo;,
8945 &lsquo;<samp>&amp;&gt;</samp>&rsquo;, and &lsquo;<samp>&gt;&gt;</samp>&rsquo; redirection operators.
8946 </li><li> Using the <code>exec</code> builtin to replace the shell with another command.
8947 </li><li> Adding or deleting builtin commands with the
8948 <samp>-f</samp> and <samp>-d</samp> options to the <code>enable</code> builtin.
8949 </li><li> Using the <code>enable</code> builtin command to enable disabled shell builtins.
8950 </li><li> Specifying the <samp>-p</samp> option to the <code>command</code> builtin.
8951 </li><li> Turning off restricted mode with &lsquo;<samp>set +r</samp>&rsquo; or &lsquo;<samp>set +o restricted</samp>&rsquo;.
8952 </li></ul>
8953
8954 <p>These restrictions are enforced after any startup files are read.
8955 </p>
8956 <p>When a command that is found to be a shell script is executed
8957 (see <a href="#Shell-Scripts">Shell Scripts</a>), <code>rbash</code> turns off any restrictions in
8958 the shell spawned to execute the script.
8959 </p>
8960 <hr>
8961 <a name="Bash-POSIX-Mode"></a>
8962 <div class="header">
8963 <p>
8964 Previous: <a href="#The-Restricted-Shell" accesskey="p" rel="prev">The Restricted Shell</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
8965 </div>
8966 <a name="Bash-POSIX-Mode-1"></a>
8967 <h3 class="section">6.11 Bash POSIX Mode</h3>
8968 <a name="index-POSIX-Mode"></a>
8969
8970 <p>Starting Bash with the <samp>--posix</samp> command-line option or executing
8971 &lsquo;<samp>set -o posix</samp>&rsquo; while Bash is running will cause Bash to conform more
8972 closely to the <small>POSIX</small> standard by changing the behavior to
8973 match that specified by <small>POSIX</small> in areas where the Bash default differs.
8974 </p>
8975 <p>When invoked as <code>sh</code>, Bash enters <small>POSIX</small> mode after reading the
8976 startup files.
8977 </p>
8978 <p>The following list is what&rsquo;s changed when &lsquo;<small>POSIX</small> mode&rsquo; is in effect:
8979 </p>
8980 <ol>
8981 <li> Bash ensures that the <code>POSIXLY_CORRECT</code> variable is set.
8982
8983 </li><li> When a command in the hash table no longer exists, Bash will re-search
8984 <code>$PATH</code> to find the new location. This is also available with
8985 &lsquo;<samp>shopt -s checkhash</samp>&rsquo;.
8986
8987 </li><li> The message printed by the job control code and builtins when a job
8988 exits with a non-zero status is &lsquo;Done(status)&rsquo;.
8989
8990 </li><li> The message printed by the job control code and builtins when a job
8991 is stopped is &lsquo;Stopped(<var>signame</var>)&rsquo;, where <var>signame</var> is, for
8992 example, <code>SIGTSTP</code>.
8993
8994 </li><li> Alias expansion is always enabled, even in non-interactive shells.
8995
8996 </li><li> Reserved words appearing in a context where reserved words are recognized
8997 do not undergo alias expansion.
8998
8999 </li><li> The <small>POSIX</small> <code>PS1</code> and <code>PS2</code> expansions of &lsquo;<samp>!</samp>&rsquo; to
9000 the history number and &lsquo;<samp>!!</samp>&rsquo; to &lsquo;<samp>!</samp>&rsquo; are enabled,
9001 and parameter expansion is performed on the values of <code>PS1</code> and
9002 <code>PS2</code> regardless of the setting of the <code>promptvars</code> option.
9003
9004 </li><li> The <small>POSIX</small> startup files are executed (<code>$ENV</code>) rather than
9005 the normal Bash files.
9006
9007 </li><li> Tilde expansion is only performed on assignments preceding a command
9008 name, rather than on all assignment statements on the line.
9009
9010 </li><li> The default history file is <samp>~/.sh_history</samp> (this is the
9011 default value of <code>$HISTFILE</code>).
9012
9013 </li><li> Redirection operators do not perform filename expansion on the word
9014 in the redirection unless the shell is interactive.
9015
9016 </li><li> Redirection operators do not perform word splitting on the word in the
9017 redirection.
9018
9019 </li><li> Function names must be valid shell <code>name</code>s. That is, they may not
9020 contain characters other than letters, digits, and underscores, and
9021 may not start with a digit. Declaring a function with an invalid name
9022 causes a fatal syntax error in non-interactive shells.
9023
9024 </li><li> Function names may not be the same as one of the <small>POSIX</small> special
9025 builtins.
9026
9027 </li><li> <small>POSIX</small> special builtins are found before shell functions
9028 during command lookup.
9029
9030 </li><li> When printing shell function definitions (e.g., by <code>type</code>), Bash does
9031 not print the <code>function</code> keyword.
9032
9033 </li><li> Literal tildes that appear as the first character in elements of
9034 the <code>PATH</code> variable are not expanded as described above
9035 under <a href="#Tilde-Expansion">Tilde Expansion</a>.
9036
9037 </li><li> The <code>time</code> reserved word may be used by itself as a command. When
9038 used in this way, it displays timing statistics for the shell and its
9039 completed children. The <code>TIMEFORMAT</code> variable controls the format
9040 of the timing information.
9041
9042 </li><li> When parsing and expanding a ${&hellip;} expansion that appears within
9043 double quotes, single quotes are no longer special and cannot be used to
9044 quote a closing brace or other special character, unless the operator is
9045 one of those defined to perform pattern removal. In this case, they do
9046 not have to appear as matched pairs.
9047
9048 </li><li> The parser does not recognize <code>time</code> as a reserved word if the next
9049 token begins with a &lsquo;<samp>-</samp>&rsquo;.
9050
9051 </li><li> The &lsquo;<samp>!</samp>&rsquo; character does not introduce history expansion within a
9052 double-quoted string, even if the <code>histexpand</code> option is enabled.
9053
9054 </li><li> If a <small>POSIX</small> special builtin returns an error status, a
9055 non-interactive shell exits. The fatal errors are those listed in
9056 the <small>POSIX</small> standard, and include things like passing incorrect options,
9057 redirection errors, variable assignment errors for assignments preceding
9058 the command name, and so on.
9059
9060 </li><li> A non-interactive shell exits with an error status if a variable
9061 assignment error occurs when no command name follows the assignment
9062 statements.
9063 A variable assignment error occurs, for example, when trying to assign
9064 a value to a readonly variable.
9065
9066 </li><li> A non-interactive shell exits with an error status if a variable
9067 assignment error occurs in an assignment statement preceding a special
9068 builtin, but not with any other simple command.
9069
9070 </li><li> A non-interactive shell exits with an error status if the iteration
9071 variable in a <code>for</code> statement or the selection variable in a
9072 <code>select</code> statement is a readonly variable.
9073
9074 </li><li> Non-interactive shells exit if <var>filename</var> in <code>.</code> <var>filename</var>
9075 is not found.
9076
9077 </li><li> Non-interactive shells exit if a syntax error in an arithmetic expansion
9078 results in an invalid expression.
9079
9080 </li><li> Non-interactive shells exit if a parameter expansion error occurs.
9081
9082 </li><li> Non-interactive shells exit if there is a syntax error in a script read
9083 with the <code>.</code> or <code>source</code> builtins, or in a string processed by
9084 the <code>eval</code> builtin.
9085
9086 </li><li> Process substitution is not available.
9087
9088 </li><li> While variable indirection is available, it may not be applied to the
9089 &lsquo;<samp>#</samp>&rsquo; and &lsquo;<samp>?</samp>&rsquo; special parameters.
9090
9091 </li><li> When expanding the &lsquo;<samp>*</samp>&rsquo; special parameter in a pattern context where the
9092 expansion is double-quoted does not treat the <code>$*</code> as if it were
9093 double-quoted.
9094
9095 </li><li> Assignment statements preceding <small>POSIX</small> special builtins
9096 persist in the shell environment after the builtin completes.
9097
9098 </li><li> Assignment statements preceding shell function calls persist in the
9099 shell environment after the function returns, as if a <small>POSIX</small>
9100 special builtin command had been executed.
9101
9102 </li><li> The <code>command</code> builtin does not prevent builtins that take assignment
9103 statements as arguments from expanding them as assignment statements;
9104 when not in <small>POSIX</small> mode, assignment builtins lose their assignment
9105 statement expansion properties when preceded by <code>command</code>.
9106
9107 </li><li> The <code>bg</code> builtin uses the required format to describe each job placed
9108 in the background, which does not include an indication of whether the job
9109 is the current or previous job.
9110
9111 </li><li> The output of &lsquo;<samp>kill -l</samp>&rsquo; prints all the signal names on a single line,
9112 separated by spaces, without the &lsquo;<samp>SIG</samp>&rsquo; prefix.
9113
9114 </li><li> The <code>kill</code> builtin does not accept signal names with a &lsquo;<samp>SIG</samp>&rsquo;
9115 prefix.
9116
9117 </li><li> The <code>export</code> and <code>readonly</code> builtin commands display their
9118 output in the format required by <small>POSIX</small>.
9119
9120 </li><li> The <code>trap</code> builtin displays signal names without the leading
9121 <code>SIG</code>.
9122
9123 </li><li> The <code>trap</code> builtin doesn&rsquo;t check the first argument for a possible
9124 signal specification and revert the signal handling to the original
9125 disposition if it is, unless that argument consists solely of digits and
9126 is a valid signal number. If users want to reset the handler for a given
9127 signal to the original disposition, they should use &lsquo;<samp>-</samp>&rsquo; as the
9128 first argument.
9129
9130 </li><li> The <code>.</code> and <code>source</code> builtins do not search the current directory
9131 for the filename argument if it is not found by searching <code>PATH</code>.
9132
9133 </li><li> Enabling <small>POSIX</small> mode has the effect of setting the
9134 <code>inherit_errexit</code> option, so
9135 subshells spawned to execute command substitutions inherit the value of
9136 the <samp>-e</samp> option from the parent shell.
9137 When the <code>inherit_errexit</code> option is not enabled,
9138 Bash clears the <samp>-e</samp> option in such subshells.
9139
9140 </li><li> Enabling <small>POSIX</small> mode has the effect of setting the
9141 <code>shift_verbose</code> option, so numeric arguments to <code>shift</code>
9142 that exceed the number of positional parameters will result in an
9143 error message.
9144
9145 </li><li> When the <code>alias</code> builtin displays alias definitions, it does not
9146 display them with a leading &lsquo;<samp>alias </samp>&rsquo; unless the <samp>-p</samp> option
9147 is supplied.
9148
9149 </li><li> When the <code>set</code> builtin is invoked without options, it does not display
9150 shell function names and definitions.
9151
9152 </li><li> When the <code>set</code> builtin is invoked without options, it displays
9153 variable values without quotes, unless they contain shell metacharacters,
9154 even if the result contains nonprinting characters.
9155
9156 </li><li> When the <code>cd</code> builtin is invoked in <var>logical</var> mode, and the pathname
9157 constructed from <code>$PWD</code> and the directory name supplied as an argument
9158 does not refer to an existing directory, <code>cd</code> will fail instead of
9159 falling back to <var>physical</var> mode.
9160
9161 </li><li> When the <code>cd</code> builtin cannot change a directory because the
9162 length of the pathname
9163 constructed from <code>$PWD</code> and the directory name supplied as an argument
9164 exceeds <var>PATH_MAX</var> when all symbolic links are expanded, <code>cd</code> will
9165 fail instead of attempting to use only the supplied directory name.
9166
9167 </li><li> The <code>pwd</code> builtin verifies that the value it prints is the same as the
9168 current directory, even if it is not asked to check the file system with the
9169 <samp>-P</samp> option.
9170
9171 </li><li> When listing the history, the <code>fc</code> builtin does not include an
9172 indication of whether or not a history entry has been modified.
9173
9174 </li><li> The default editor used by <code>fc</code> is <code>ed</code>.
9175
9176 </li><li> The <code>type</code> and <code>command</code> builtins will not report a non-executable
9177 file as having been found, though the shell will attempt to execute such a
9178 file if it is the only so-named file found in <code>$PATH</code>.
9179
9180 </li><li> The <code>vi</code> editing mode will invoke the <code>vi</code> editor directly when
9181 the &lsquo;<samp>v</samp>&rsquo; command is run, instead of checking <code>$VISUAL</code> and
9182 <code>$EDITOR</code>.
9183
9184 </li><li> When the <code>xpg_echo</code> option is enabled, Bash does not attempt to interpret
9185 any arguments to <code>echo</code> as options. Each argument is displayed, after
9186 escape characters are converted.
9187
9188 </li><li> The <code>ulimit</code> builtin uses a block size of 512 bytes for the <samp>-c</samp>
9189 and <samp>-f</samp> options.
9190
9191 </li><li> The arrival of <code>SIGCHLD</code> when a trap is set on <code>SIGCHLD</code> does
9192 not interrupt the <code>wait</code> builtin and cause it to return immediately.
9193 The trap command is run once for each child that exits.
9194
9195 </li><li> The <code>read</code> builtin may be interrupted by a signal for which a trap
9196 has been set.
9197 If Bash receives a trapped signal while executing <code>read</code>, the trap
9198 handler executes and <code>read</code> returns an exit status greater than 128.
9199
9200 </li><li> Bash removes an exited background process&rsquo;s status from the list of such
9201 statuses after the <code>wait</code> builtin is used to obtain it.
9202
9203 </li></ol>
9204
9205 <p>There is other <small>POSIX</small> behavior that Bash does not implement by
9206 default even when in <small>POSIX</small> mode.
9207 Specifically:
9208 </p>
9209 <ol>
9210 <li> The <code>fc</code> builtin checks <code>$EDITOR</code> as a program to edit history
9211 entries if <code>FCEDIT</code> is unset, rather than defaulting directly to
9212 <code>ed</code>. <code>fc</code> uses <code>ed</code> if <code>EDITOR</code> is unset.
9213
9214 </li><li> As noted above, Bash requires the <code>xpg_echo</code> option to be enabled for
9215 the <code>echo</code> builtin to be fully conformant.
9216
9217 </li></ol>
9218
9219 <p>Bash can be configured to be <small>POSIX</small>-conformant by default, by specifying
9220 the <samp>--enable-strict-posix-default</samp> to <code>configure</code> when building
9221 (see <a href="#Optional-Features">Optional Features</a>).
9222 </p>
9223 <hr>
9224 <a name="Job-Control"></a>
9225 <div class="header">
9226 <p>
9227 Next: <a href="#Command-Line-Editing" accesskey="n" rel="next">Command Line Editing</a>, Previous: <a href="#Bash-Features" accesskey="p" rel="prev">Bash Features</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
9228 </div>
9229 <a name="Job-Control-1"></a>
9230 <h2 class="chapter">7 Job Control</h2>
9231
9232 <p>This chapter discusses what job control is, how it works, and how
9233 Bash allows you to access its facilities.
9234 </p>
9235 <table class="menu" border="0" cellspacing="0">
9236 <tr><td align="left" valign="top">&bull; <a href="#Job-Control-Basics" accesskey="1">Job Control Basics</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How job control works.
9237 </td></tr>
9238 <tr><td align="left" valign="top">&bull; <a href="#Job-Control-Builtins" accesskey="2">Job Control Builtins</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Bash builtin commands used to interact
9239 with job control.
9240 </td></tr>
9241 <tr><td align="left" valign="top">&bull; <a href="#Job-Control-Variables" accesskey="3">Job Control Variables</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Variables Bash uses to customize job
9242 control.
9243 </td></tr>
9244 </table>
9245
9246 <hr>
9247 <a name="Job-Control-Basics"></a>
9248 <div class="header">
9249 <p>
9250 Next: <a href="#Job-Control-Builtins" accesskey="n" rel="next">Job Control Builtins</a>, Up: <a href="#Job-Control" accesskey="u" rel="up">Job Control</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
9251 </div>
9252 <a name="Job-Control-Basics-1"></a>
9253 <h3 class="section">7.1 Job Control Basics</h3>
9254 <a name="index-job-control-1"></a>
9255 <a name="index-foreground"></a>
9256 <a name="index-background"></a>
9257 <a name="index-suspending-jobs"></a>
9258
9259 <p>Job control
9260 refers to the ability to selectively stop (suspend)
9261 the execution of processes and continue (resume)
9262 their execution at a later point. A user typically employs
9263 this facility via an interactive interface supplied jointly
9264 by the operating system kernel&rsquo;s terminal driver and Bash.
9265 </p>
9266 <p>The shell associates a <var>job</var> with each pipeline. It keeps a
9267 table of currently executing jobs, which may be listed with the
9268 <code>jobs</code> command. When Bash starts a job
9269 asynchronously, it prints a line that looks
9270 like:
9271 </p><div class="example">
9272 <pre class="example">[1] 25647
9273 </pre></div>
9274 <p>indicating that this job is job number 1 and that the process <small>ID</small>
9275 of the last process in the pipeline associated with this job is
9276 25647. All of the processes in a single pipeline are members of
9277 the same job. Bash uses the <var>job</var> abstraction as the
9278 basis for job control.
9279 </p>
9280 <p>To facilitate the implementation of the user interface to job
9281 control, the operating system maintains the notion of a current terminal
9282 process group <small>ID</small>. Members of this process group (processes whose
9283 process group <small>ID</small> is equal to the current terminal process group
9284 <small>ID</small>) receive keyboard-generated signals such as <code>SIGINT</code>.
9285 These processes are said to be in the foreground. Background
9286 processes are those whose process group <small>ID</small> differs from the
9287 terminal&rsquo;s; such processes are immune to keyboard-generated
9288 signals. Only foreground processes are allowed to read from or, if
9289 the user so specifies with <code>stty tostop</code>, write to the terminal.
9290 Background processes which attempt to
9291 read from (write to when <code>stty tostop</code> is in effect) the
9292 terminal are sent a <code>SIGTTIN</code> (<code>SIGTTOU</code>)
9293 signal by the kernel&rsquo;s terminal driver,
9294 which, unless caught, suspends the process.
9295 </p>
9296 <p>If the operating system on which Bash is running supports
9297 job control, Bash contains facilities to use it. Typing the
9298 <var>suspend</var> character (typically &lsquo;<samp>^Z</samp>&rsquo;, Control-Z) while a
9299 process is running causes that process to be stopped and returns
9300 control to Bash. Typing the <var>delayed suspend</var> character
9301 (typically &lsquo;<samp>^Y</samp>&rsquo;, Control-Y) causes the process to be stopped
9302 when it attempts to read input from the terminal, and control to
9303 be returned to Bash. The user then manipulates the state of
9304 this job, using the <code>bg</code> command to continue it in the
9305 background, the <code>fg</code> command to continue it in the
9306 foreground, or the <code>kill</code> command to kill it. A &lsquo;<samp>^Z</samp>&rsquo;
9307 takes effect immediately, and has the additional side effect of
9308 causing pending output and typeahead to be discarded.
9309 </p>
9310 <p>There are a number of ways to refer to a job in the shell. The
9311 character &lsquo;<samp>%</samp>&rsquo; introduces a job specification (<var>jobspec</var>).
9312 </p>
9313 <p>Job number <code>n</code> may be referred to as &lsquo;<samp>%n</samp>&rsquo;.
9314 The symbols &lsquo;<samp>%%</samp>&rsquo; and &lsquo;<samp>%+</samp>&rsquo; refer to the shell&rsquo;s notion of the
9315 current job, which is the last job stopped while it was in the foreground
9316 or started in the background.
9317 A single &lsquo;<samp>%</samp>&rsquo; (with no accompanying job specification) also refers
9318 to the current job.
9319 The previous job may be referenced using &lsquo;<samp>%-</samp>&rsquo;.
9320 If there is only a single job, &lsquo;<samp>%+</samp>&rsquo; and &lsquo;<samp>%-</samp>&rsquo; can both be used
9321 to refer to that job.
9322 In output pertaining to jobs (e.g., the output of the <code>jobs</code>
9323 command), the current job is always flagged with a &lsquo;<samp>+</samp>&rsquo;, and the
9324 previous job with a &lsquo;<samp>-</samp>&rsquo;.
9325 </p>
9326 <p>A job may also be referred to
9327 using a prefix of the name used to start it, or using a substring
9328 that appears in its command line. For example, &lsquo;<samp>%ce</samp>&rsquo; refers
9329 to a stopped <code>ce</code> job. Using &lsquo;<samp>%?ce</samp>&rsquo;, on the
9330 other hand, refers to any job containing the string &lsquo;<samp>ce</samp>&rsquo; in
9331 its command line. If the prefix or substring matches more than one job,
9332 Bash reports an error.
9333 </p>
9334 <p>Simply naming a job can be used to bring it into the foreground:
9335 &lsquo;<samp>%1</samp>&rsquo; is a synonym for &lsquo;<samp>fg %1</samp>&rsquo;, bringing job 1 from the
9336 background into the foreground. Similarly, &lsquo;<samp>%1 &amp;</samp>&rsquo; resumes
9337 job 1 in the background, equivalent to &lsquo;<samp>bg %1</samp>&rsquo;
9338 </p>
9339 <p>The shell learns immediately whenever a job changes state.
9340 Normally, Bash waits until it is about to print a prompt
9341 before reporting changes in a job&rsquo;s status so as to not interrupt
9342 any other output.
9343 If the <samp>-b</samp> option to the <code>set</code> builtin is enabled,
9344 Bash reports such changes immediately (see <a href="#The-Set-Builtin">The Set Builtin</a>).
9345 Any trap on <code>SIGCHLD</code> is executed for each child process
9346 that exits.
9347 </p>
9348 <p>If an attempt to exit Bash is made while jobs are stopped, (or running, if
9349 the <code>checkjobs</code> option is enabled &ndash; see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), the
9350 shell prints a warning message, and if the <code>checkjobs</code> option is
9351 enabled, lists the jobs and their statuses.
9352 The <code>jobs</code> command may then be used to inspect their status.
9353 If a second attempt to exit is made without an intervening command,
9354 Bash does not print another warning, and any stopped jobs are terminated.
9355 </p>
9356 <p>When the shell is waiting for a job or process using the <code>wait</code>
9357 builtin, and job control is enabled, <code>wait</code> will return when the
9358 job changes state. The <samp>-f</samp> option will force <code>wait</code> to wait
9359 until the job or process terminates before returning.
9360 </p>
9361 <hr>
9362 <a name="Job-Control-Builtins"></a>
9363 <div class="header">
9364 <p>
9365 Next: <a href="#Job-Control-Variables" accesskey="n" rel="next">Job Control Variables</a>, Previous: <a href="#Job-Control-Basics" accesskey="p" rel="prev">Job Control Basics</a>, Up: <a href="#Job-Control" accesskey="u" rel="up">Job Control</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
9366 </div>
9367 <a name="Job-Control-Builtins-1"></a>
9368 <h3 class="section">7.2 Job Control Builtins</h3>
9369
9370 <dl compact="compact">
9371 <dt><code>bg</code></dt>
9372 <dd><a name="index-bg"></a>
9373 <div class="example">
9374 <pre class="example">bg [<var>jobspec</var> &hellip;]
9375 </pre></div>
9376
9377 <p>Resume each suspended job <var>jobspec</var> in the background, as if it
9378 had been started with &lsquo;<samp>&amp;</samp>&rsquo;.
9379 If <var>jobspec</var> is not supplied, the current job is used.
9380 The return status is zero unless it is run when job control is not
9381 enabled, or, when run with job control enabled, any
9382 <var>jobspec</var> was not found or specifies a job
9383 that was started without job control.
9384 </p>
9385 </dd>
9386 <dt><code>fg</code></dt>
9387 <dd><a name="index-fg"></a>
9388 <div class="example">
9389 <pre class="example">fg [<var>jobspec</var>]
9390 </pre></div>
9391
9392 <p>Resume the job <var>jobspec</var> in the foreground and make it the current job.
9393 If <var>jobspec</var> is not supplied, the current job is used.
9394 The return status is that of the command placed into the foreground,
9395 or non-zero if run when job control is disabled or, when run with
9396 job control enabled, <var>jobspec</var> does not specify a valid job or
9397 <var>jobspec</var> specifies a job that was started without job control.
9398 </p>
9399 </dd>
9400 <dt><code>jobs</code></dt>
9401 <dd><a name="index-jobs"></a>
9402 <div class="example">
9403 <pre class="example">jobs [-lnprs] [<var>jobspec</var>]
9404 jobs -x <var>command</var> [<var>arguments</var>]
9405 </pre></div>
9406
9407 <p>The first form lists the active jobs. The options have the
9408 following meanings:
9409 </p>
9410 <dl compact="compact">
9411 <dt><code>-l</code></dt>
9412 <dd><p>List process <small>ID</small>s in addition to the normal information.
9413 </p>
9414 </dd>
9415 <dt><code>-n</code></dt>
9416 <dd><p>Display information only about jobs that have changed status since
9417 the user was last notified of their status.
9418 </p>
9419 </dd>
9420 <dt><code>-p</code></dt>
9421 <dd><p>List only the process <small>ID</small> of the job&rsquo;s process group leader.
9422 </p>
9423 </dd>
9424 <dt><code>-r</code></dt>
9425 <dd><p>Display only running jobs.
9426 </p>
9427 </dd>
9428 <dt><code>-s</code></dt>
9429 <dd><p>Display only stopped jobs.
9430 </p></dd>
9431 </dl>
9432
9433 <p>If <var>jobspec</var> is given,
9434 output is restricted to information about that job.
9435 If <var>jobspec</var> is not supplied, the status of all jobs is
9436 listed.
9437 </p>
9438 <p>If the <samp>-x</samp> option is supplied, <code>jobs</code> replaces any
9439 <var>jobspec</var> found in <var>command</var> or <var>arguments</var> with the
9440 corresponding process group <small>ID</small>, and executes <var>command</var>,
9441 passing it <var>argument</var>s, returning its exit status.
9442 </p>
9443 </dd>
9444 <dt><code>kill</code></dt>
9445 <dd><a name="index-kill"></a>
9446 <div class="example">
9447 <pre class="example">kill [-s <var>sigspec</var>] [-n <var>signum</var>] [-<var>sigspec</var>] <var>jobspec</var> or <var>pid</var>
9448 kill -l|-L [<var>exit_status</var>]
9449 </pre></div>
9450
9451 <p>Send a signal specified by <var>sigspec</var> or <var>signum</var> to the process
9452 named by job specification <var>jobspec</var> or process <small>ID</small> <var>pid</var>.
9453 <var>sigspec</var> is either a case-insensitive signal name such as
9454 <code>SIGINT</code> (with or without the <code>SIG</code> prefix)
9455 or a signal number; <var>signum</var> is a signal number.
9456 If <var>sigspec</var> and <var>signum</var> are not present, <code>SIGTERM</code> is used.
9457 The <samp>-l</samp> option lists the signal names.
9458 If any arguments are supplied when <samp>-l</samp> is given, the names of the
9459 signals corresponding to the arguments are listed, and the return status
9460 is zero.
9461 <var>exit_status</var> is a number specifying a signal number or the exit
9462 status of a process terminated by a signal.
9463 The <samp>-L</samp> option is equivalent to <samp>-l</samp>.
9464 The return status is zero if at least one signal was successfully sent,
9465 or non-zero if an error occurs or an invalid option is encountered.
9466 </p>
9467 </dd>
9468 <dt><code>wait</code></dt>
9469 <dd><a name="index-wait"></a>
9470 <div class="example">
9471 <pre class="example">wait [-fn] [<var>jobspec</var> or <var>pid</var> &hellip;]
9472 </pre></div>
9473
9474 <p>Wait until the child process specified by each process <small>ID</small> <var>pid</var>
9475 or job specification <var>jobspec</var> exits and return the exit status of the
9476 last command waited for.
9477 If a job spec is given, all processes in the job are waited for.
9478 If no arguments are given, all currently active child processes are
9479 waited for, and the return status is zero.
9480 If the <samp>-n</samp> option is supplied, <code>wait</code> waits for any job to
9481 terminate and returns its exit status.
9482 If the <samp>-f</samp> option is supplied, and job control is enabled,
9483 <code>wait</code> forces each <var>pid</var> or <var>jobspec</var> to terminate before
9484 returning its status, intead of returning when it changes status.
9485 If neither <var>jobspec</var> nor <var>pid</var> specifies an active child process
9486 of the shell, the return status is 127.
9487 </p>
9488 </dd>
9489 <dt><code>disown</code></dt>
9490 <dd><a name="index-disown"></a>
9491 <div class="example">
9492 <pre class="example">disown [-ar] [-h] [<var>jobspec</var> &hellip; | <var>pid</var> &hellip; ]
9493 </pre></div>
9494
9495 <p>Without options, remove each <var>jobspec</var> from the table of
9496 active jobs.
9497 If the <samp>-h</samp> option is given, the job is not removed from the table,
9498 but is marked so that <code>SIGHUP</code> is not sent to the job if the shell
9499 receives a <code>SIGHUP</code>.
9500 If <var>jobspec</var> is not present, and neither the <samp>-a</samp> nor the
9501 <samp>-r</samp> option is supplied, the current job is used.
9502 If no <var>jobspec</var> is supplied, the <samp>-a</samp> option means to remove or
9503 mark all jobs; the <samp>-r</samp> option without a <var>jobspec</var>
9504 argument restricts operation to running jobs.
9505 </p>
9506 </dd>
9507 <dt><code>suspend</code></dt>
9508 <dd><a name="index-suspend"></a>
9509 <div class="example">
9510 <pre class="example">suspend [-f]
9511 </pre></div>
9512
9513 <p>Suspend the execution of this shell until it receives a
9514 <code>SIGCONT</code> signal.
9515 A login shell cannot be suspended; the <samp>-f</samp>
9516 option can be used to override this and force the suspension.
9517 </p></dd>
9518 </dl>
9519
9520 <p>When job control is not active, the <code>kill</code> and <code>wait</code>
9521 builtins do not accept <var>jobspec</var> arguments. They must be
9522 supplied process <small>ID</small>s.
9523 </p>
9524 <hr>
9525 <a name="Job-Control-Variables"></a>
9526 <div class="header">
9527 <p>
9528 Previous: <a href="#Job-Control-Builtins" accesskey="p" rel="prev">Job Control Builtins</a>, Up: <a href="#Job-Control" accesskey="u" rel="up">Job Control</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
9529 </div>
9530 <a name="Job-Control-Variables-1"></a>
9531 <h3 class="section">7.3 Job Control Variables</h3>
9532
9533 <dl compact="compact">
9534 <dt><code>auto_resume</code>
9535 <a name="index-auto_005fresume"></a>
9536 </dt>
9537 <dd><p>This variable controls how the shell interacts with the user and
9538 job control. If this variable exists then single word simple
9539 commands without redirections are treated as candidates for resumption
9540 of an existing job. There is no ambiguity allowed; if there is
9541 more than one job beginning with the string typed, then
9542 the most recently accessed job will be selected.
9543 The name of a stopped job, in this context, is the command line
9544 used to start it. If this variable is set to the value &lsquo;<samp>exact</samp>&rsquo;,
9545 the string supplied must match the name of a stopped job exactly;
9546 if set to &lsquo;<samp>substring</samp>&rsquo;,
9547 the string supplied needs to match a substring of the name of a
9548 stopped job. The &lsquo;<samp>substring</samp>&rsquo; value provides functionality
9549 analogous to the &lsquo;<samp>%?</samp>&rsquo; job <small>ID</small> (see <a href="#Job-Control-Basics">Job Control Basics</a>).
9550 If set to any other value, the supplied string must
9551 be a prefix of a stopped job&rsquo;s name; this provides functionality
9552 analogous to the &lsquo;<samp>%</samp>&rsquo; job <small>ID</small>.
9553 </p>
9554 </dd>
9555 </dl>
9556
9557 <a name="index-Readline_002c-how-to-use"></a>
9558
9559
9560
9561
9562 <hr>
9563 <a name="Command-Line-Editing"></a>
9564 <div class="header">
9565 <p>
9566 Next: <a href="#Using-History-Interactively" accesskey="n" rel="next">Using History Interactively</a>, Previous: <a href="#Job-Control" accesskey="p" rel="prev">Job Control</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
9567 </div>
9568 <a name="Command-Line-Editing-1"></a>
9569 <h2 class="chapter">8 Command Line Editing</h2>
9570
9571 <p>This chapter describes the basic features of the <small>GNU</small>
9572 command line editing interface.
9573 Command line editing is provided by the Readline library, which is
9574 used by several different programs, including Bash.
9575 Command line editing is enabled by default when using an interactive shell,
9576 unless the <samp>--noediting</samp> option is supplied at shell invocation.
9577 Line editing is also used when using the <samp>-e</samp> option to the
9578 <code>read</code> builtin command (see <a href="#Bash-Builtins">Bash Builtins</a>).
9579 By default, the line editing commands are similar to those of Emacs.
9580 A vi-style line editing interface is also available.
9581 Line editing can be enabled at any time using the <samp>-o emacs</samp> or
9582 <samp>-o vi</samp> options to the <code>set</code> builtin command
9583 (see <a href="#The-Set-Builtin">The Set Builtin</a>), or disabled using the <samp>+o emacs</samp> or
9584 <samp>+o vi</samp> options to <code>set</code>.
9585 </p>
9586 <table class="menu" border="0" cellspacing="0">
9587 <tr><td align="left" valign="top">&bull; <a href="#Introduction-and-Notation" accesskey="1">Introduction and Notation</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Notation used in this text.
9588 </td></tr>
9589 <tr><td align="left" valign="top">&bull; <a href="#Readline-Interaction" accesskey="2">Readline Interaction</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The minimum set of commands for editing a line.
9590 </td></tr>
9591 <tr><td align="left" valign="top">&bull; <a href="#Readline-Init-File" accesskey="3">Readline Init File</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Customizing Readline from a user&rsquo;s view.
9592 </td></tr>
9593 <tr><td align="left" valign="top">&bull; <a href="#Bindable-Readline-Commands" accesskey="4">Bindable Readline Commands</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A description of most of the Readline commands
9594 available for binding
9595 </td></tr>
9596 <tr><td align="left" valign="top">&bull; <a href="#Readline-vi-Mode" accesskey="5">Readline vi Mode</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A short description of how to make Readline
9597 behave like the vi editor.
9598 </td></tr>
9599 <tr><td align="left" valign="top">&bull; <a href="#Programmable-Completion" accesskey="6">Programmable Completion</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to specify the possible completions for
9600 a specific command.
9601 </td></tr>
9602 <tr><td align="left" valign="top">&bull; <a href="#Programmable-Completion-Builtins" accesskey="7">Programmable Completion Builtins</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Builtin commands to specify how to
9603 complete arguments for a particular command.
9604 </td></tr>
9605 <tr><td align="left" valign="top">&bull; <a href="#A-Programmable-Completion-Example" accesskey="8">A Programmable Completion Example</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">An example shell function for
9606 generating possible completions.
9607 </td></tr>
9608 </table>
9609
9610 <hr>
9611 <a name="Introduction-and-Notation"></a>
9612 <div class="header">
9613 <p>
9614 Next: <a href="#Readline-Interaction" accesskey="n" rel="next">Readline Interaction</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
9615 </div>
9616 <a name="Introduction-to-Line-Editing"></a>
9617 <h3 class="section">8.1 Introduction to Line Editing</h3>
9618
9619 <p>The following paragraphs describe the notation used to represent
9620 keystrokes.
9621 </p>
9622 <p>The text <kbd>C-k</kbd> is read as &lsquo;Control-K&rsquo; and describes the character
9623 produced when the <tt class="key">k</tt> key is pressed while the Control key
9624 is depressed.
9625 </p>
9626 <p>The text <kbd>M-k</kbd> is read as &lsquo;Meta-K&rsquo; and describes the character
9627 produced when the Meta key (if you have one) is depressed, and the <tt class="key">k</tt>
9628 key is pressed.
9629 The Meta key is labeled <tt class="key">ALT</tt> on many keyboards.
9630 On keyboards with two keys labeled <tt class="key">ALT</tt> (usually to either side of
9631 the space bar), the <tt class="key">ALT</tt> on the left side is generally set to
9632 work as a Meta key.
9633 The <tt class="key">ALT</tt> key on the right may also be configured to work as a
9634 Meta key or may be configured as some other modifier, such as a
9635 Compose key for typing accented characters.
9636 </p>
9637 <p>If you do not have a Meta or <tt class="key">ALT</tt> key, or another key working as
9638 a Meta key, the identical keystroke can be generated by typing <tt class="key">ESC</tt>
9639 <em>first</em>, and then typing <tt class="key">k</tt>.
9640 Either process is known as <em>metafying</em> the <tt class="key">k</tt> key.
9641 </p>
9642 <p>The text <kbd>M-C-k</kbd> is read as &lsquo;Meta-Control-k&rsquo; and describes the
9643 character produced by <em>metafying</em> <kbd>C-k</kbd>.
9644 </p>
9645 <p>In addition, several keys have their own names. Specifically,
9646 <tt class="key">DEL</tt>, <tt class="key">ESC</tt>, <tt class="key">LFD</tt>, <tt class="key">SPC</tt>, <tt class="key">RET</tt>, and <tt class="key">TAB</tt> all
9647 stand for themselves when seen in this text, or in an init file
9648 (see <a href="#Readline-Init-File">Readline Init File</a>).
9649 If your keyboard lacks a <tt class="key">LFD</tt> key, typing <tt class="key">C-j</tt> will
9650 produce the desired character.
9651 The <tt class="key">RET</tt> key may be labeled <tt class="key">Return</tt> or <tt class="key">Enter</tt> on
9652 some keyboards.
9653 </p>
9654 <hr>
9655 <a name="Readline-Interaction"></a>
9656 <div class="header">
9657 <p>
9658 Next: <a href="#Readline-Init-File" accesskey="n" rel="next">Readline Init File</a>, Previous: <a href="#Introduction-and-Notation" accesskey="p" rel="prev">Introduction and Notation</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
9659 </div>
9660 <a name="Readline-Interaction-1"></a>
9661 <h3 class="section">8.2 Readline Interaction</h3>
9662 <a name="index-interaction_002c-readline"></a>
9663
9664 <p>Often during an interactive session you type in a long line of text,
9665 only to notice that the first word on the line is misspelled. The
9666 Readline library gives you a set of commands for manipulating the text
9667 as you type it in, allowing you to just fix your typo, and not forcing
9668 you to retype the majority of the line. Using these editing commands,
9669 you move the cursor to the place that needs correction, and delete or
9670 insert the text of the corrections. Then, when you are satisfied with
9671 the line, you simply press <tt class="key">RET</tt>. You do not have to be at the
9672 end of the line to press <tt class="key">RET</tt>; the entire line is accepted
9673 regardless of the location of the cursor within the line.
9674 </p>
9675 <table class="menu" border="0" cellspacing="0">
9676 <tr><td align="left" valign="top">&bull; <a href="#Readline-Bare-Essentials" accesskey="1">Readline Bare Essentials</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The least you need to know about Readline.
9677 </td></tr>
9678 <tr><td align="left" valign="top">&bull; <a href="#Readline-Movement-Commands" accesskey="2">Readline Movement Commands</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Moving about the input line.
9679 </td></tr>
9680 <tr><td align="left" valign="top">&bull; <a href="#Readline-Killing-Commands" accesskey="3">Readline Killing Commands</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to delete text, and how to get it back!
9681 </td></tr>
9682 <tr><td align="left" valign="top">&bull; <a href="#Readline-Arguments" accesskey="4">Readline Arguments</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Giving numeric arguments to commands.
9683 </td></tr>
9684 <tr><td align="left" valign="top">&bull; <a href="#Searching" accesskey="5">Searching</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Searching through previous lines.
9685 </td></tr>
9686 </table>
9687
9688 <hr>
9689 <a name="Readline-Bare-Essentials"></a>
9690 <div class="header">
9691 <p>
9692 Next: <a href="#Readline-Movement-Commands" accesskey="n" rel="next">Readline Movement Commands</a>, Up: <a href="#Readline-Interaction" accesskey="u" rel="up">Readline Interaction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
9693 </div>
9694 <a name="Readline-Bare-Essentials-1"></a>
9695 <h4 class="subsection">8.2.1 Readline Bare Essentials</h4>
9696 <a name="index-notation_002c-readline"></a>
9697 <a name="index-command-editing"></a>
9698 <a name="index-editing-command-lines"></a>
9699
9700 <p>In order to enter characters into the line, simply type them. The typed
9701 character appears where the cursor was, and then the cursor moves one
9702 space to the right. If you mistype a character, you can use your
9703 erase character to back up and delete the mistyped character.
9704 </p>
9705 <p>Sometimes you may mistype a character, and
9706 not notice the error until you have typed several other characters. In
9707 that case, you can type <kbd>C-b</kbd> to move the cursor to the left, and then
9708 correct your mistake. Afterwards, you can move the cursor to the right
9709 with <kbd>C-f</kbd>.
9710 </p>
9711 <p>When you add text in the middle of a line, you will notice that characters
9712 to the right of the cursor are &lsquo;pushed over&rsquo; to make room for the text
9713 that you have inserted. Likewise, when you delete text behind the cursor,
9714 characters to the right of the cursor are &lsquo;pulled back&rsquo; to fill in the
9715 blank space created by the removal of the text. A list of the bare
9716 essentials for editing the text of an input line follows.
9717 </p>
9718 <dl compact="compact">
9719 <dt><kbd>C-b</kbd></dt>
9720 <dd><p>Move back one character.
9721 </p></dd>
9722 <dt><kbd>C-f</kbd></dt>
9723 <dd><p>Move forward one character.
9724 </p></dd>
9725 <dt><tt class="key">DEL</tt> or <tt class="key">Backspace</tt></dt>
9726 <dd><p>Delete the character to the left of the cursor.
9727 </p></dd>
9728 <dt><kbd>C-d</kbd></dt>
9729 <dd><p>Delete the character underneath the cursor.
9730 </p></dd>
9731 <dt>Printing&nbsp;characters<!-- /@w --></dt>
9732 <dd><p>Insert the character into the line at the cursor.
9733 </p></dd>
9734 <dt><kbd>C-_</kbd> or <kbd>C-x C-u</kbd></dt>
9735 <dd><p>Undo the last editing command. You can undo all the way back to an
9736 empty line.
9737 </p></dd>
9738 </dl>
9739
9740 <p>(Depending on your configuration, the <tt class="key">Backspace</tt> key be set to
9741 delete the character to the left of the cursor and the <tt class="key">DEL</tt> key set
9742 to delete the character underneath the cursor, like <kbd>C-d</kbd>, rather
9743 than the character to the left of the cursor.)
9744 </p>
9745 <hr>
9746 <a name="Readline-Movement-Commands"></a>
9747 <div class="header">
9748 <p>
9749 Next: <a href="#Readline-Killing-Commands" accesskey="n" rel="next">Readline Killing Commands</a>, Previous: <a href="#Readline-Bare-Essentials" accesskey="p" rel="prev">Readline Bare Essentials</a>, Up: <a href="#Readline-Interaction" accesskey="u" rel="up">Readline Interaction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
9750 </div>
9751 <a name="Readline-Movement-Commands-1"></a>
9752 <h4 class="subsection">8.2.2 Readline Movement Commands</h4>
9753
9754
9755 <p>The above table describes the most basic keystrokes that you need
9756 in order to do editing of the input line. For your convenience, many
9757 other commands have been added in addition to <kbd>C-b</kbd>, <kbd>C-f</kbd>,
9758 <kbd>C-d</kbd>, and <tt class="key">DEL</tt>. Here are some commands for moving more rapidly
9759 about the line.
9760 </p>
9761 <dl compact="compact">
9762 <dt><kbd>C-a</kbd></dt>
9763 <dd><p>Move to the start of the line.
9764 </p></dd>
9765 <dt><kbd>C-e</kbd></dt>
9766 <dd><p>Move to the end of the line.
9767 </p></dd>
9768 <dt><kbd>M-f</kbd></dt>
9769 <dd><p>Move forward a word, where a word is composed of letters and digits.
9770 </p></dd>
9771 <dt><kbd>M-b</kbd></dt>
9772 <dd><p>Move backward a word.
9773 </p></dd>
9774 <dt><kbd>C-l</kbd></dt>
9775 <dd><p>Clear the screen, reprinting the current line at the top.
9776 </p></dd>
9777 </dl>
9778
9779 <p>Notice how <kbd>C-f</kbd> moves forward a character, while <kbd>M-f</kbd> moves
9780 forward a word. It is a loose convention that control keystrokes
9781 operate on characters while meta keystrokes operate on words.
9782 </p>
9783 <hr>
9784 <a name="Readline-Killing-Commands"></a>
9785 <div class="header">
9786 <p>
9787 Next: <a href="#Readline-Arguments" accesskey="n" rel="next">Readline Arguments</a>, Previous: <a href="#Readline-Movement-Commands" accesskey="p" rel="prev">Readline Movement Commands</a>, Up: <a href="#Readline-Interaction" accesskey="u" rel="up">Readline Interaction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
9788 </div>
9789 <a name="Readline-Killing-Commands-1"></a>
9790 <h4 class="subsection">8.2.3 Readline Killing Commands</h4>
9791
9792 <a name="index-killing-text"></a>
9793 <a name="index-yanking-text"></a>
9794
9795 <p><em>Killing</em> text means to delete the text from the line, but to save
9796 it away for later use, usually by <em>yanking</em> (re-inserting)
9797 it back into the line.
9798 (&lsquo;Cut&rsquo; and &lsquo;paste&rsquo; are more recent jargon for &lsquo;kill&rsquo; and &lsquo;yank&rsquo;.)
9799 </p>
9800 <p>If the description for a command says that it &lsquo;kills&rsquo; text, then you can
9801 be sure that you can get the text back in a different (or the same)
9802 place later.
9803 </p>
9804 <p>When you use a kill command, the text is saved in a <em>kill-ring</em>.
9805 Any number of consecutive kills save all of the killed text together, so
9806 that when you yank it back, you get it all. The kill
9807 ring is not line specific; the text that you killed on a previously
9808 typed line is available to be yanked back later, when you are typing
9809 another line.
9810 <a name="index-kill-ring"></a>
9811 </p>
9812 <p>Here is the list of commands for killing text.
9813 </p>
9814 <dl compact="compact">
9815 <dt><kbd>C-k</kbd></dt>
9816 <dd><p>Kill the text from the current cursor position to the end of the line.
9817 </p>
9818 </dd>
9819 <dt><kbd>M-d</kbd></dt>
9820 <dd><p>Kill from the cursor to the end of the current word, or, if between
9821 words, to the end of the next word.
9822 Word boundaries are the same as those used by <kbd>M-f</kbd>.
9823 </p>
9824 </dd>
9825 <dt><kbd>M-<span class="key">DEL</span></kbd></dt>
9826 <dd><p>Kill from the cursor the start of the current word, or, if between
9827 words, to the start of the previous word.
9828 Word boundaries are the same as those used by <kbd>M-b</kbd>.
9829 </p>
9830 </dd>
9831 <dt><kbd>C-w</kbd></dt>
9832 <dd><p>Kill from the cursor to the previous whitespace. This is different than
9833 <kbd>M-<span class="key">DEL</span></kbd> because the word boundaries differ.
9834 </p>
9835 </dd>
9836 </dl>
9837
9838 <p>Here is how to <em>yank</em> the text back into the line. Yanking
9839 means to copy the most-recently-killed text from the kill buffer.
9840 </p>
9841 <dl compact="compact">
9842 <dt><kbd>C-y</kbd></dt>
9843 <dd><p>Yank the most recently killed text back into the buffer at the cursor.
9844 </p>
9845 </dd>
9846 <dt><kbd>M-y</kbd></dt>
9847 <dd><p>Rotate the kill-ring, and yank the new top. You can only do this if
9848 the prior command is <kbd>C-y</kbd> or <kbd>M-y</kbd>.
9849 </p></dd>
9850 </dl>
9851
9852 <hr>
9853 <a name="Readline-Arguments"></a>
9854 <div class="header">
9855 <p>
9856 Next: <a href="#Searching" accesskey="n" rel="next">Searching</a>, Previous: <a href="#Readline-Killing-Commands" accesskey="p" rel="prev">Readline Killing Commands</a>, Up: <a href="#Readline-Interaction" accesskey="u" rel="up">Readline Interaction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
9857 </div>
9858 <a name="Readline-Arguments-1"></a>
9859 <h4 class="subsection">8.2.4 Readline Arguments</h4>
9860
9861 <p>You can pass numeric arguments to Readline commands. Sometimes the
9862 argument acts as a repeat count, other times it is the <i>sign</i> of the
9863 argument that is significant. If you pass a negative argument to a
9864 command which normally acts in a forward direction, that command will
9865 act in a backward direction. For example, to kill text back to the
9866 start of the line, you might type &lsquo;<samp>M-- C-k</samp>&rsquo;.
9867 </p>
9868 <p>The general way to pass numeric arguments to a command is to type meta
9869 digits before the command. If the first &lsquo;digit&rsquo; typed is a minus
9870 sign (&lsquo;<samp>-</samp>&rsquo;), then the sign of the argument will be negative. Once
9871 you have typed one meta digit to get the argument started, you can type
9872 the remainder of the digits, and then the command. For example, to give
9873 the <kbd>C-d</kbd> command an argument of 10, you could type &lsquo;<samp>M-1 0 C-d</samp>&rsquo;,
9874 which will delete the next ten characters on the input line.
9875 </p>
9876 <hr>
9877 <a name="Searching"></a>
9878 <div class="header">
9879 <p>
9880 Previous: <a href="#Readline-Arguments" accesskey="p" rel="prev">Readline Arguments</a>, Up: <a href="#Readline-Interaction" accesskey="u" rel="up">Readline Interaction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
9881 </div>
9882 <a name="Searching-for-Commands-in-the-History"></a>
9883 <h4 class="subsection">8.2.5 Searching for Commands in the History</h4>
9884
9885 <p>Readline provides commands for searching through the command history
9886 (see <a href="#Bash-History-Facilities">Bash History Facilities</a>)
9887 for lines containing a specified string.
9888 There are two search modes: <em>incremental</em> and <em>non-incremental</em>.
9889 </p>
9890 <p>Incremental searches begin before the user has finished typing the
9891 search string.
9892 As each character of the search string is typed, Readline displays
9893 the next entry from the history matching the string typed so far.
9894 An incremental search requires only as many characters as needed to
9895 find the desired history entry.
9896 To search backward in the history for a particular string, type
9897 <kbd>C-r</kbd>. Typing <kbd>C-s</kbd> searches forward through the history.
9898 The characters present in the value of the <code>isearch-terminators</code> variable
9899 are used to terminate an incremental search.
9900 If that variable has not been assigned a value, the <tt class="key">ESC</tt> and
9901 <kbd>C-J</kbd> characters will terminate an incremental search.
9902 <kbd>C-g</kbd> will abort an incremental search and restore the original line.
9903 When the search is terminated, the history entry containing the
9904 search string becomes the current line.
9905 </p>
9906 <p>To find other matching entries in the history list, type <kbd>C-r</kbd> or
9907 <kbd>C-s</kbd> as appropriate.
9908 This will search backward or forward in the history for the next
9909 entry matching the search string typed so far.
9910 Any other key sequence bound to a Readline command will terminate
9911 the search and execute that command.
9912 For instance, a <tt class="key">RET</tt> will terminate the search and accept
9913 the line, thereby executing the command from the history list.
9914 A movement command will terminate the search, make the last line found
9915 the current line, and begin editing.
9916 </p>
9917 <p>Readline remembers the last incremental search string. If two
9918 <kbd>C-r</kbd>s are typed without any intervening characters defining a new
9919 search string, any remembered search string is used.
9920 </p>
9921 <p>Non-incremental searches read the entire search string before starting
9922 to search for matching history lines. The search string may be
9923 typed by the user or be part of the contents of the current line.
9924 </p>
9925 <hr>
9926 <a name="Readline-Init-File"></a>
9927 <div class="header">
9928 <p>
9929 Next: <a href="#Bindable-Readline-Commands" accesskey="n" rel="next">Bindable Readline Commands</a>, Previous: <a href="#Readline-Interaction" accesskey="p" rel="prev">Readline Interaction</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
9930 </div>
9931 <a name="Readline-Init-File-1"></a>
9932 <h3 class="section">8.3 Readline Init File</h3>
9933 <a name="index-initialization-file_002c-readline"></a>
9934
9935 <p>Although the Readline library comes with a set of Emacs-like
9936 keybindings installed by default, it is possible to use a different set
9937 of keybindings.
9938 Any user can customize programs that use Readline by putting
9939 commands in an <em>inputrc</em> file, conventionally in his home directory.
9940 The name of this
9941 file is taken from the value of the shell variable <code>INPUTRC</code>. If
9942 that variable is unset, the default is <samp>~/.inputrc</samp>. If that
9943 file does not exist or cannot be read, the ultimate default is
9944 <samp>/etc/inputrc</samp>.
9945 </p>
9946 <p>When a program which uses the Readline library starts up, the
9947 init file is read, and the key bindings are set.
9948 </p>
9949 <p>In addition, the <code>C-x C-r</code> command re-reads this init file, thus
9950 incorporating any changes that you might have made to it.
9951 </p>
9952 <table class="menu" border="0" cellspacing="0">
9953 <tr><td align="left" valign="top">&bull; <a href="#Readline-Init-File-Syntax" accesskey="1">Readline Init File Syntax</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Syntax for the commands in the inputrc file.
9954 </td></tr>
9955 <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
9956
9957 </pre></th></tr><tr><td align="left" valign="top">&bull; <a href="#Conditional-Init-Constructs" accesskey="2">Conditional Init Constructs</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Conditional key bindings in the inputrc file.
9958 </td></tr>
9959 <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
9960
9961 </pre></th></tr><tr><td align="left" valign="top">&bull; <a href="#Sample-Init-File" accesskey="3">Sample Init File</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">An example inputrc file.
9962 </td></tr>
9963 </table>
9964
9965 <hr>
9966 <a name="Readline-Init-File-Syntax"></a>
9967 <div class="header">
9968 <p>
9969 Next: <a href="#Conditional-Init-Constructs" accesskey="n" rel="next">Conditional Init Constructs</a>, Up: <a href="#Readline-Init-File" accesskey="u" rel="up">Readline Init File</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
9970 </div>
9971 <a name="Readline-Init-File-Syntax-1"></a>
9972 <h4 class="subsection">8.3.1 Readline Init File Syntax</h4>
9973
9974 <p>There are only a few basic constructs allowed in the
9975 Readline init file. Blank lines are ignored.
9976 Lines beginning with a &lsquo;<samp>#</samp>&rsquo; are comments.
9977 Lines beginning with a &lsquo;<samp>$</samp>&rsquo; indicate conditional
9978 constructs (see <a href="#Conditional-Init-Constructs">Conditional Init Constructs</a>). Other lines
9979 denote variable settings and key bindings.
9980 </p>
9981 <dl compact="compact">
9982 <dt>Variable Settings</dt>
9983 <dd><p>You can modify the run-time behavior of Readline by
9984 altering the values of variables in Readline
9985 using the <code>set</code> command within the init file.
9986 The syntax is simple:
9987 </p>
9988 <div class="example">
9989 <pre class="example">set <var>variable</var> <var>value</var>
9990 </pre></div>
9991
9992 <p>Here, for example, is how to
9993 change from the default Emacs-like key binding to use
9994 <code>vi</code> line editing commands:
9995 </p>
9996 <div class="example">
9997 <pre class="example">set editing-mode vi
9998 </pre></div>
9999
10000 <p>Variable names and values, where appropriate, are recognized without regard
10001 to case. Unrecognized variable names are ignored.
10002 </p>
10003 <p>Boolean variables (those that can be set to on or off) are set to on if
10004 the value is null or empty, <var>on</var> (case-insensitive), or 1. Any other
10005 value results in the variable being set to off.
10006 </p>
10007 <p>The <code>bind&nbsp;<span class="nolinebreak">-V</span></code><!-- /@w --> command lists the current Readline variable names
10008 and values. See <a href="#Bash-Builtins">Bash Builtins</a>.
10009 </p>
10010 <p>A great deal of run-time behavior is changeable with the following
10011 variables.
10012 </p>
10013 <a name="index-variables_002c-readline"></a>
10014 <dl compact="compact">
10015 <dt><code>bell-style</code></dt>
10016 <dd><a name="index-bell_002dstyle"></a>
10017 <p>Controls what happens when Readline wants to ring the terminal bell.
10018 If set to &lsquo;<samp>none</samp>&rsquo;, Readline never rings the bell. If set to
10019 &lsquo;<samp>visible</samp>&rsquo;, Readline uses a visible bell if one is available.
10020 If set to &lsquo;<samp>audible</samp>&rsquo; (the default), Readline attempts to ring
10021 the terminal&rsquo;s bell.
10022 </p>
10023 </dd>
10024 <dt><code>bind-tty-special-chars</code></dt>
10025 <dd><a name="index-bind_002dtty_002dspecial_002dchars"></a>
10026 <p>If set to &lsquo;<samp>on</samp>&rsquo; (the default), Readline attempts to bind the control
10027 characters treated specially by the kernel&rsquo;s terminal driver to their
10028 Readline equivalents.
10029 </p>
10030 </dd>
10031 <dt><code>blink-matching-paren</code></dt>
10032 <dd><a name="index-blink_002dmatching_002dparen"></a>
10033 <p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline attempts to briefly move the cursor to an
10034 opening parenthesis when a closing parenthesis is inserted. The default
10035 is &lsquo;<samp>off</samp>&rsquo;.
10036 </p>
10037 </dd>
10038 <dt><code>colored-completion-prefix</code></dt>
10039 <dd><a name="index-colored_002dcompletion_002dprefix"></a>
10040 <p>If set to &lsquo;<samp>on</samp>&rsquo;, when listing completions, Readline displays the
10041 common prefix of the set of possible completions using a different color.
10042 The color definitions are taken from the value of the <code>LS_COLORS</code>
10043 environment variable.
10044 The default is &lsquo;<samp>off</samp>&rsquo;.
10045 </p>
10046 </dd>
10047 <dt><code>colored-stats</code></dt>
10048 <dd><a name="index-colored_002dstats"></a>
10049 <p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline displays possible completions using different
10050 colors to indicate their file type.
10051 The color definitions are taken from the value of the <code>LS_COLORS</code>
10052 environment variable.
10053 The default is &lsquo;<samp>off</samp>&rsquo;.
10054 </p>
10055 </dd>
10056 <dt><code>comment-begin</code></dt>
10057 <dd><a name="index-comment_002dbegin"></a>
10058 <p>The string to insert at the beginning of the line when the
10059 <code>insert-comment</code> command is executed. The default value
10060 is <code>&quot;#&quot;</code>.
10061 </p>
10062 </dd>
10063 <dt><code>completion-display-width</code></dt>
10064 <dd><a name="index-completion_002ddisplay_002dwidth"></a>
10065 <p>The number of screen columns used to display possible matches
10066 when performing completion.
10067 The value is ignored if it is less than 0 or greater than the terminal
10068 screen width.
10069 A value of 0 will cause matches to be displayed one per line.
10070 The default value is -1.
10071 </p>
10072 </dd>
10073 <dt><code>completion-ignore-case</code></dt>
10074 <dd><a name="index-completion_002dignore_002dcase"></a>
10075 <p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline performs filename matching and completion
10076 in a case-insensitive fashion.
10077 The default value is &lsquo;<samp>off</samp>&rsquo;.
10078 </p>
10079 </dd>
10080 <dt><code>completion-map-case</code></dt>
10081 <dd><a name="index-completion_002dmap_002dcase"></a>
10082 <p>If set to &lsquo;<samp>on</samp>&rsquo;, and <var>completion-ignore-case</var> is enabled, Readline
10083 treats hyphens (&lsquo;<samp>-</samp>&rsquo;) and underscores (&lsquo;<samp>_</samp>&rsquo;) as equivalent when
10084 performing case-insensitive filename matching and completion.
10085 The default value is &lsquo;<samp>off</samp>&rsquo;.
10086 </p>
10087 </dd>
10088 <dt><code>completion-prefix-display-length</code></dt>
10089 <dd><a name="index-completion_002dprefix_002ddisplay_002dlength"></a>
10090 <p>The length in characters of the common prefix of a list of possible
10091 completions that is displayed without modification. When set to a
10092 value greater than zero, common prefixes longer than this value are
10093 replaced with an ellipsis when displaying possible completions.
10094 </p>
10095 </dd>
10096 <dt><code>completion-query-items</code></dt>
10097 <dd><a name="index-completion_002dquery_002ditems"></a>
10098 <p>The number of possible completions that determines when the user is
10099 asked whether the list of possibilities should be displayed.
10100 If the number of possible completions is greater than this value,
10101 Readline will ask the user whether or not he wishes to view
10102 them; otherwise, they are simply listed.
10103 This variable must be set to an integer value greater than or equal to 0.
10104 A negative value means Readline should never ask.
10105 The default limit is <code>100</code>.
10106 </p>
10107 </dd>
10108 <dt><code>convert-meta</code></dt>
10109 <dd><a name="index-convert_002dmeta"></a>
10110 <p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline will convert characters with the
10111 eighth bit set to an <small>ASCII</small> key sequence by stripping the eighth
10112 bit and prefixing an <tt class="key">ESC</tt> character, converting them to a
10113 meta-prefixed key sequence. The default value is &lsquo;<samp>on</samp>&rsquo;, but
10114 will be set to &lsquo;<samp>off</samp>&rsquo; if the locale is one that contains
10115 eight-bit characters.
10116 </p>
10117 </dd>
10118 <dt><code>disable-completion</code></dt>
10119 <dd><a name="index-disable_002dcompletion"></a>
10120 <p>If set to &lsquo;<samp>On</samp>&rsquo;, Readline will inhibit word completion.
10121 Completion characters will be inserted into the line as if they had
10122 been mapped to <code>self-insert</code>. The default is &lsquo;<samp>off</samp>&rsquo;.
10123 </p>
10124 </dd>
10125 <dt><code>echo-control-characters</code></dt>
10126 <dd><a name="index-echo_002dcontrol_002dcharacters"></a>
10127 <p>When set to &lsquo;<samp>on</samp>&rsquo;, on operating systems that indicate they support it,
10128 readline echoes a character corresponding to a signal generated from the
10129 keyboard. The default is &lsquo;<samp>on</samp>&rsquo;.
10130 </p>
10131 </dd>
10132 <dt><code>editing-mode</code></dt>
10133 <dd><a name="index-editing_002dmode"></a>
10134 <p>The <code>editing-mode</code> variable controls which default set of
10135 key bindings is used. By default, Readline starts up in Emacs editing
10136 mode, where the keystrokes are most similar to Emacs. This variable can be
10137 set to either &lsquo;<samp>emacs</samp>&rsquo; or &lsquo;<samp>vi</samp>&rsquo;.
10138 </p>
10139 </dd>
10140 <dt><code>emacs-mode-string</code></dt>
10141 <dd><a name="index-emacs_002dmode_002dstring"></a>
10142 <p>If the <var>show-mode-in-prompt</var> variable is enabled,
10143 this string is displayed immediately before the last line of the primary
10144 prompt when emacs editing mode is active. The value is expanded like a
10145 key binding, so the standard set of meta- and control prefixes and
10146 backslash escape sequences is available.
10147 Use the &lsquo;<samp>\1</samp>&rsquo; and &lsquo;<samp>\2</samp>&rsquo; escapes to begin and end sequences of
10148 non-printing characters, which can be used to embed a terminal control
10149 sequence into the mode string.
10150 The default is &lsquo;<samp>@</samp>&rsquo;.
10151 </p>
10152 </dd>
10153 <dt><code>enable-bracketed-paste</code></dt>
10154 <dd><a name="index-enable_002dbracketed_002dpaste"></a>
10155 <p>When set to &lsquo;<samp>On</samp>&rsquo;, Readline will configure the terminal in a way
10156 that will enable it to insert each paste into the editing buffer as a
10157 single string of characters, instead of treating each character as if
10158 it had been read from the keyboard. This can prevent pasted characters
10159 from being interpreted as editing commands. The default is &lsquo;<samp>off</samp>&rsquo;.
10160 </p>
10161 </dd>
10162 <dt><code>enable-keypad</code></dt>
10163 <dd><a name="index-enable_002dkeypad"></a>
10164 <p>When set to &lsquo;<samp>on</samp>&rsquo;, Readline will try to enable the application
10165 keypad when it is called. Some systems need this to enable the
10166 arrow keys. The default is &lsquo;<samp>off</samp>&rsquo;.
10167 </p>
10168 </dd>
10169 <dt><code>enable-meta-key</code></dt>
10170 <dd><p>When set to &lsquo;<samp>on</samp>&rsquo;, Readline will try to enable any meta modifier
10171 key the terminal claims to support when it is called. On many terminals,
10172 the meta key is used to send eight-bit characters.
10173 The default is &lsquo;<samp>on</samp>&rsquo;.
10174 </p>
10175 </dd>
10176 <dt><code>expand-tilde</code></dt>
10177 <dd><a name="index-expand_002dtilde"></a>
10178 <p>If set to &lsquo;<samp>on</samp>&rsquo;, tilde expansion is performed when Readline
10179 attempts word completion. The default is &lsquo;<samp>off</samp>&rsquo;.
10180 </p>
10181 </dd>
10182 <dt><code>history-preserve-point</code></dt>
10183 <dd><a name="index-history_002dpreserve_002dpoint"></a>
10184 <p>If set to &lsquo;<samp>on</samp>&rsquo;, the history code attempts to place the point (the
10185 current cursor position) at the
10186 same location on each history line retrieved with <code>previous-history</code>
10187 or <code>next-history</code>. The default is &lsquo;<samp>off</samp>&rsquo;.
10188 </p>
10189 </dd>
10190 <dt><code>history-size</code></dt>
10191 <dd><a name="index-history_002dsize"></a>
10192 <p>Set the maximum number of history entries saved in the history list.
10193 If set to zero, any existing history entries are deleted and no new entries
10194 are saved.
10195 If set to a value less than zero, the number of history entries is not
10196 limited.
10197 By default, the number of history entries is not limited.
10198 If an attempt is made to set <var>history-size</var> to a non-numeric value,
10199 the maximum number of history entries will be set to 500.
10200 </p>
10201 </dd>
10202 <dt><code>horizontal-scroll-mode</code></dt>
10203 <dd><a name="index-horizontal_002dscroll_002dmode"></a>
10204 <p>This variable can be set to either &lsquo;<samp>on</samp>&rsquo; or &lsquo;<samp>off</samp>&rsquo;. Setting it
10205 to &lsquo;<samp>on</samp>&rsquo; means that the text of the lines being edited will scroll
10206 horizontally on a single screen line when they are longer than the width
10207 of the screen, instead of wrapping onto a new screen line. By default,
10208 this variable is set to &lsquo;<samp>off</samp>&rsquo;.
10209 </p>
10210 </dd>
10211 <dt><code>input-meta</code></dt>
10212 <dd><a name="index-input_002dmeta"></a>
10213 <a name="index-meta_002dflag"></a>
10214 <p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline will enable eight-bit input (it
10215 will not clear the eighth bit in the characters it reads),
10216 regardless of what the terminal claims it can support. The
10217 default value is &lsquo;<samp>off</samp>&rsquo;, but Readline will set it to &lsquo;<samp>on</samp>&rsquo; if the
10218 locale contains eight-bit characters.
10219 The name <code>meta-flag</code> is a synonym for this variable.
10220 </p>
10221 </dd>
10222 <dt><code>isearch-terminators</code></dt>
10223 <dd><a name="index-isearch_002dterminators"></a>
10224 <p>The string of characters that should terminate an incremental search without
10225 subsequently executing the character as a command (see <a href="#Searching">Searching</a>).
10226 If this variable has not been given a value, the characters <tt class="key">ESC</tt> and
10227 <kbd>C-J</kbd> will terminate an incremental search.
10228 </p>
10229 </dd>
10230 <dt><code>keymap</code></dt>
10231 <dd><a name="index-keymap"></a>
10232 <p>Sets Readline&rsquo;s idea of the current keymap for key binding commands.
10233 Built-in <code>keymap</code> names are
10234 <code>emacs</code>,
10235 <code>emacs-standard</code>,
10236 <code>emacs-meta</code>,
10237 <code>emacs-ctlx</code>,
10238 <code>vi</code>,
10239 <code>vi-move</code>,
10240 <code>vi-command</code>, and
10241 <code>vi-insert</code>.
10242 <code>vi</code> is equivalent to <code>vi-command</code> (<code>vi-move</code> is also a
10243 synonym); <code>emacs</code> is equivalent to <code>emacs-standard</code>.
10244 Applications may add additional names.
10245 The default value is <code>emacs</code>.
10246 The value of the <code>editing-mode</code> variable also affects the
10247 default keymap.
10248 </p>
10249 </dd>
10250 <dt><code>keyseq-timeout</code></dt>
10251 <dd><p>Specifies the duration Readline will wait for a character when reading an
10252 ambiguous key sequence (one that can form a complete key sequence using
10253 the input read so far, or can take additional input to complete a longer
10254 key sequence).
10255 If no input is received within the timeout, Readline will use the shorter
10256 but complete key sequence.
10257 Readline uses this value to determine whether or not input is
10258 available on the current input source (<code>rl_instream</code> by default).
10259 The value is specified in milliseconds, so a value of 1000 means that
10260 Readline will wait one second for additional input.
10261 If this variable is set to a value less than or equal to zero, or to a
10262 non-numeric value, Readline will wait until another key is pressed to
10263 decide which key sequence to complete.
10264 The default value is <code>500</code>.
10265 </p>
10266 </dd>
10267 <dt><code>mark-directories</code></dt>
10268 <dd><p>If set to &lsquo;<samp>on</samp>&rsquo;, completed directory names have a slash
10269 appended. The default is &lsquo;<samp>on</samp>&rsquo;.
10270 </p>
10271 </dd>
10272 <dt><code>mark-modified-lines</code></dt>
10273 <dd><a name="index-mark_002dmodified_002dlines"></a>
10274 <p>This variable, when set to &lsquo;<samp>on</samp>&rsquo;, causes Readline to display an
10275 asterisk (&lsquo;<samp>*</samp>&rsquo;) at the start of history lines which have been modified.
10276 This variable is &lsquo;<samp>off</samp>&rsquo; by default.
10277 </p>
10278 </dd>
10279 <dt><code>mark-symlinked-directories</code></dt>
10280 <dd><a name="index-mark_002dsymlinked_002ddirectories"></a>
10281 <p>If set to &lsquo;<samp>on</samp>&rsquo;, completed names which are symbolic links
10282 to directories have a slash appended (subject to the value of
10283 <code>mark-directories</code>).
10284 The default is &lsquo;<samp>off</samp>&rsquo;.
10285 </p>
10286 </dd>
10287 <dt><code>match-hidden-files</code></dt>
10288 <dd><a name="index-match_002dhidden_002dfiles"></a>
10289 <p>This variable, when set to &lsquo;<samp>on</samp>&rsquo;, causes Readline to match files whose
10290 names begin with a &lsquo;<samp>.</samp>&rsquo; (hidden files) when performing filename
10291 completion.
10292 If set to &lsquo;<samp>off</samp>&rsquo;, the leading &lsquo;<samp>.</samp>&rsquo; must be
10293 supplied by the user in the filename to be completed.
10294 This variable is &lsquo;<samp>on</samp>&rsquo; by default.
10295 </p>
10296 </dd>
10297 <dt><code>menu-complete-display-prefix</code></dt>
10298 <dd><a name="index-menu_002dcomplete_002ddisplay_002dprefix"></a>
10299 <p>If set to &lsquo;<samp>on</samp>&rsquo;, menu completion displays the common prefix of the
10300 list of possible completions (which may be empty) before cycling through
10301 the list. The default is &lsquo;<samp>off</samp>&rsquo;.
10302 </p>
10303 </dd>
10304 <dt><code>output-meta</code></dt>
10305 <dd><a name="index-output_002dmeta"></a>
10306 <p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline will display characters with the
10307 eighth bit set directly rather than as a meta-prefixed escape
10308 sequence.
10309 The default is &lsquo;<samp>off</samp>&rsquo;, but Readline will set it to &lsquo;<samp>on</samp>&rsquo; if the
10310 locale contains eight-bit characters.
10311 </p>
10312 </dd>
10313 <dt><code>page-completions</code></dt>
10314 <dd><a name="index-page_002dcompletions"></a>
10315 <p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline uses an internal <code>more</code>-like pager
10316 to display a screenful of possible completions at a time.
10317 This variable is &lsquo;<samp>on</samp>&rsquo; by default.
10318 </p>
10319 </dd>
10320 <dt><code>print-completions-horizontally</code></dt>
10321 <dd><p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline will display completions with matches
10322 sorted horizontally in alphabetical order, rather than down the screen.
10323 The default is &lsquo;<samp>off</samp>&rsquo;.
10324 </p>
10325 </dd>
10326 <dt><code>revert-all-at-newline</code></dt>
10327 <dd><a name="index-revert_002dall_002dat_002dnewline"></a>
10328 <p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline will undo all changes to history lines
10329 before returning when <code>accept-line</code> is executed. By default,
10330 history lines may be modified and retain individual undo lists across
10331 calls to <code>readline</code>. The default is &lsquo;<samp>off</samp>&rsquo;.
10332 </p>
10333 </dd>
10334 <dt><code>show-all-if-ambiguous</code></dt>
10335 <dd><a name="index-show_002dall_002dif_002dambiguous"></a>
10336 <p>This alters the default behavior of the completion functions. If
10337 set to &lsquo;<samp>on</samp>&rsquo;,
10338 words which have more than one possible completion cause the
10339 matches to be listed immediately instead of ringing the bell.
10340 The default value is &lsquo;<samp>off</samp>&rsquo;.
10341 </p>
10342 </dd>
10343 <dt><code>show-all-if-unmodified</code></dt>
10344 <dd><a name="index-show_002dall_002dif_002dunmodified"></a>
10345 <p>This alters the default behavior of the completion functions in
10346 a fashion similar to <var>show-all-if-ambiguous</var>.
10347 If set to &lsquo;<samp>on</samp>&rsquo;,
10348 words which have more than one possible completion without any
10349 possible partial completion (the possible completions don&rsquo;t share
10350 a common prefix) cause the matches to be listed immediately instead
10351 of ringing the bell.
10352 The default value is &lsquo;<samp>off</samp>&rsquo;.
10353 </p>
10354 </dd>
10355 <dt><code>show-mode-in-prompt</code></dt>
10356 <dd><a name="index-show_002dmode_002din_002dprompt"></a>
10357 <p>If set to &lsquo;<samp>on</samp>&rsquo;, add a string to the beginning of the prompt
10358 indicating the editing mode: emacs, vi command, or vi insertion.
10359 The mode strings are user-settable (e.g., <var>emacs-mode-string</var>).
10360 The default value is &lsquo;<samp>off</samp>&rsquo;.
10361 </p>
10362 </dd>
10363 <dt><code>skip-completed-text</code></dt>
10364 <dd><a name="index-skip_002dcompleted_002dtext"></a>
10365 <p>If set to &lsquo;<samp>on</samp>&rsquo;, this alters the default completion behavior when
10366 inserting a single match into the line. It&rsquo;s only active when
10367 performing completion in the middle of a word. If enabled, readline
10368 does not insert characters from the completion that match characters
10369 after point in the word being completed, so portions of the word
10370 following the cursor are not duplicated.
10371 For instance, if this is enabled, attempting completion when the cursor
10372 is after the &lsquo;<samp>e</samp>&rsquo; in &lsquo;<samp>Makefile</samp>&rsquo; will result in &lsquo;<samp>Makefile</samp>&rsquo;
10373 rather than &lsquo;<samp>Makefilefile</samp>&rsquo;, assuming there is a single possible
10374 completion.
10375 The default value is &lsquo;<samp>off</samp>&rsquo;.
10376 </p>
10377 </dd>
10378 <dt><code>vi-cmd-mode-string</code></dt>
10379 <dd><a name="index-vi_002dcmd_002dmode_002dstring"></a>
10380 <p>If the <var>show-mode-in-prompt</var> variable is enabled,
10381 this string is displayed immediately before the last line of the primary
10382 prompt when vi editing mode is active and in command mode.
10383 The value is expanded like a
10384 key binding, so the standard set of meta- and control prefixes and
10385 backslash escape sequences is available.
10386 Use the &lsquo;<samp>\1</samp>&rsquo; and &lsquo;<samp>\2</samp>&rsquo; escapes to begin and end sequences of
10387 non-printing characters, which can be used to embed a terminal control
10388 sequence into the mode string.
10389 The default is &lsquo;<samp>(cmd)</samp>&rsquo;.
10390 </p>
10391 </dd>
10392 <dt><code>vi-ins-mode-string</code></dt>
10393 <dd><a name="index-vi_002dins_002dmode_002dstring"></a>
10394 <p>If the <var>show-mode-in-prompt</var> variable is enabled,
10395 this string is displayed immediately before the last line of the primary
10396 prompt when vi editing mode is active and in insertion mode.
10397 The value is expanded like a
10398 key binding, so the standard set of meta- and control prefixes and
10399 backslash escape sequences is available.
10400 Use the &lsquo;<samp>\1</samp>&rsquo; and &lsquo;<samp>\2</samp>&rsquo; escapes to begin and end sequences of
10401 non-printing characters, which can be used to embed a terminal control
10402 sequence into the mode string.
10403 The default is &lsquo;<samp>(ins)</samp>&rsquo;.
10404 </p>
10405 </dd>
10406 <dt><code>visible-stats</code></dt>
10407 <dd><a name="index-visible_002dstats"></a>
10408 <p>If set to &lsquo;<samp>on</samp>&rsquo;, a character denoting a file&rsquo;s type
10409 is appended to the filename when listing possible
10410 completions. The default is &lsquo;<samp>off</samp>&rsquo;.
10411 </p>
10412 </dd>
10413 </dl>
10414
10415 </dd>
10416 <dt>Key Bindings</dt>
10417 <dd><p>The syntax for controlling key bindings in the init file is
10418 simple. First you need to find the name of the command that you
10419 want to change. The following sections contain tables of the command
10420 name, the default keybinding, if any, and a short description of what
10421 the command does.
10422 </p>
10423 <p>Once you know the name of the command, simply place on a line
10424 in the init file the name of the key
10425 you wish to bind the command to, a colon, and then the name of the
10426 command.
10427 There can be no space between the key name and the colon &ndash; that will be
10428 interpreted as part of the key name.
10429 The name of the key can be expressed in different ways, depending on
10430 what you find most comfortable.
10431 </p>
10432 <p>In addition to command names, readline allows keys to be bound
10433 to a string that is inserted when the key is pressed (a <var>macro</var>).
10434 </p>
10435 <p>The <code>bind&nbsp;<span class="nolinebreak">-p</span></code><!-- /@w --> command displays Readline function names and
10436 bindings in a format that can put directly into an initialization file.
10437 See <a href="#Bash-Builtins">Bash Builtins</a>.
10438 </p>
10439 <dl compact="compact">
10440 <dt><var>keyname</var>:&nbsp;<var><span class="nolinebreak">function-name</span></var>&nbsp;or&nbsp;<var>macro</var><!-- /@w --></dt>
10441 <dd><p><var>keyname</var> is the name of a key spelled out in English. For example:
10442 </p><div class="example">
10443 <pre class="example">Control-u: universal-argument
10444 Meta-Rubout: backward-kill-word
10445 Control-o: &quot;&gt; output&quot;
10446 </pre></div>
10447
10448 <p>In the example above, <kbd>C-u</kbd> is bound to the function
10449 <code>universal-argument</code>,
10450 <kbd>M-DEL</kbd> is bound to the function <code>backward-kill-word</code>, and
10451 <kbd>C-o</kbd> is bound to run the macro
10452 expressed on the right hand side (that is, to insert the text
10453 &lsquo;<samp>&gt; output</samp>&rsquo; into the line).
10454 </p>
10455 <p>A number of symbolic character names are recognized while
10456 processing this key binding syntax:
10457 <var>DEL</var>,
10458 <var>ESC</var>,
10459 <var>ESCAPE</var>,
10460 <var>LFD</var>,
10461 <var>NEWLINE</var>,
10462 <var>RET</var>,
10463 <var>RETURN</var>,
10464 <var>RUBOUT</var>,
10465 <var>SPACE</var>,
10466 <var>SPC</var>,
10467 and
10468 <var>TAB</var>.
10469 </p>
10470 </dd>
10471 <dt>&quot;<var>keyseq</var>&quot;:&nbsp;<var><span class="nolinebreak">function-name</span></var>&nbsp;or&nbsp;<var>macro</var><!-- /@w --></dt>
10472 <dd><p><var>keyseq</var> differs from <var>keyname</var> above in that strings
10473 denoting an entire key sequence can be specified, by placing
10474 the key sequence in double quotes. Some <small>GNU</small> Emacs style key
10475 escapes can be used, as in the following example, but the
10476 special character names are not recognized.
10477 </p>
10478 <div class="example">
10479 <pre class="example">&quot;\C-u&quot;: universal-argument
10480 &quot;\C-x\C-r&quot;: re-read-init-file
10481 &quot;\e[11~&quot;: &quot;Function Key 1&quot;
10482 </pre></div>
10483
10484 <p>In the above example, <kbd>C-u</kbd> is again bound to the function
10485 <code>universal-argument</code> (just as it was in the first example),
10486 &lsquo;<samp><kbd>C-x</kbd> <kbd>C-r</kbd></samp>&rsquo; is bound to the function <code>re-read-init-file</code>,
10487 and &lsquo;<samp><span class="key">ESC</span> <span class="key">[</span> <span class="key">1</span> <span class="key">1</span> <span class="key">~</span></samp>&rsquo; is bound to insert
10488 the text &lsquo;<samp>Function Key 1</samp>&rsquo;.
10489 </p>
10490 </dd>
10491 </dl>
10492
10493 <p>The following <small>GNU</small> Emacs style escape sequences are available when
10494 specifying key sequences:
10495 </p>
10496 <dl compact="compact">
10497 <dt><code><kbd>\C-</kbd></code></dt>
10498 <dd><p>control prefix
10499 </p></dd>
10500 <dt><code><kbd>\M-</kbd></code></dt>
10501 <dd><p>meta prefix
10502 </p></dd>
10503 <dt><code><kbd>\e</kbd></code></dt>
10504 <dd><p>an escape character
10505 </p></dd>
10506 <dt><code><kbd>\\</kbd></code></dt>
10507 <dd><p>backslash
10508 </p></dd>
10509 <dt><code><kbd>\&quot;</kbd></code></dt>
10510 <dd><p><tt class="key">&quot;</tt>, a double quotation mark
10511 </p></dd>
10512 <dt><code><kbd>\'</kbd></code></dt>
10513 <dd><p><tt class="key">'</tt>, a single quote or apostrophe
10514 </p></dd>
10515 </dl>
10516
10517 <p>In addition to the <small>GNU</small> Emacs style escape sequences, a second
10518 set of backslash escapes is available:
10519 </p>
10520 <dl compact="compact">
10521 <dt><code>\a</code></dt>
10522 <dd><p>alert (bell)
10523 </p></dd>
10524 <dt><code>\b</code></dt>
10525 <dd><p>backspace
10526 </p></dd>
10527 <dt><code>\d</code></dt>
10528 <dd><p>delete
10529 </p></dd>
10530 <dt><code>\f</code></dt>
10531 <dd><p>form feed
10532 </p></dd>
10533 <dt><code>\n</code></dt>
10534 <dd><p>newline
10535 </p></dd>
10536 <dt><code>\r</code></dt>
10537 <dd><p>carriage return
10538 </p></dd>
10539 <dt><code>\t</code></dt>
10540 <dd><p>horizontal tab
10541 </p></dd>
10542 <dt><code>\v</code></dt>
10543 <dd><p>vertical tab
10544 </p></dd>
10545 <dt><code>\<var>nnn</var></code></dt>
10546 <dd><p>the eight-bit character whose value is the octal value <var>nnn</var>
10547 (one to three digits)
10548 </p></dd>
10549 <dt><code>\x<var>HH</var></code></dt>
10550 <dd><p>the eight-bit character whose value is the hexadecimal value <var>HH</var>
10551 (one or two hex digits)
10552 </p></dd>
10553 </dl>
10554
10555 <p>When entering the text of a macro, single or double quotes must
10556 be used to indicate a macro definition.
10557 Unquoted text is assumed to be a function name.
10558 In the macro body, the backslash escapes described above are expanded.
10559 Backslash will quote any other character in the macro text,
10560 including &lsquo;<samp>&quot;</samp>&rsquo; and &lsquo;<samp>'</samp>&rsquo;.
10561 For example, the following binding will make &lsquo;<samp><kbd>C-x</kbd> \</samp>&rsquo;
10562 insert a single &lsquo;<samp>\</samp>&rsquo; into the line:
10563 </p><div class="example">
10564 <pre class="example">&quot;\C-x\\&quot;: &quot;\\&quot;
10565 </pre></div>
10566
10567 </dd>
10568 </dl>
10569
10570 <hr>
10571 <a name="Conditional-Init-Constructs"></a>
10572 <div class="header">
10573 <p>
10574 Next: <a href="#Sample-Init-File" accesskey="n" rel="next">Sample Init File</a>, Previous: <a href="#Readline-Init-File-Syntax" accesskey="p" rel="prev">Readline Init File Syntax</a>, Up: <a href="#Readline-Init-File" accesskey="u" rel="up">Readline Init File</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
10575 </div>
10576 <a name="Conditional-Init-Constructs-1"></a>
10577 <h4 class="subsection">8.3.2 Conditional Init Constructs</h4>
10578
10579 <p>Readline implements a facility similar in spirit to the conditional
10580 compilation features of the C preprocessor which allows key
10581 bindings and variable settings to be performed as the result
10582 of tests. There are four parser directives used.
10583 </p>
10584 <dl compact="compact">
10585 <dt><code>$if</code></dt>
10586 <dd><p>The <code>$if</code> construct allows bindings to be made based on the
10587 editing mode, the terminal being used, or the application using
10588 Readline. The text of the test, after any comparison operator,
10589 extends to the end of the line;
10590 unless otherwise noted, no characters are required to isolate it.
10591 </p>
10592 <dl compact="compact">
10593 <dt><code>mode</code></dt>
10594 <dd><p>The <code>mode=</code> form of the <code>$if</code> directive is used to test
10595 whether Readline is in <code>emacs</code> or <code>vi</code> mode.
10596 This may be used in conjunction
10597 with the &lsquo;<samp>set keymap</samp>&rsquo; command, for instance, to set bindings in
10598 the <code>emacs-standard</code> and <code>emacs-ctlx</code> keymaps only if
10599 Readline is starting out in <code>emacs</code> mode.
10600 </p>
10601 </dd>
10602 <dt><code>term</code></dt>
10603 <dd><p>The <code>term=</code> form may be used to include terminal-specific
10604 key bindings, perhaps to bind the key sequences output by the
10605 terminal&rsquo;s function keys. The word on the right side of the
10606 &lsquo;<samp>=</samp>&rsquo; is tested against both the full name of the terminal and
10607 the portion of the terminal name before the first &lsquo;<samp>-</samp>&rsquo;. This
10608 allows <code>sun</code> to match both <code>sun</code> and <code>sun-cmd</code>,
10609 for instance.
10610 </p>
10611 </dd>
10612 <dt><code>version</code></dt>
10613 <dd><p>The <code>version</code> test may be used to perform comparisons against
10614 specific Readline versions.
10615 The <code>version</code> expands to the current Readline version.
10616 The set of comparison operators includes
10617 &lsquo;<samp>=</samp>&rsquo; (and &lsquo;<samp>==</samp>&rsquo;), &lsquo;<samp>!=</samp>&rsquo;, &lsquo;<samp>&lt;=</samp>&rsquo;, &lsquo;<samp>&gt;=</samp>&rsquo;, &lsquo;<samp>&lt;</samp>&rsquo;,
10618 and &lsquo;<samp>&gt;</samp>&rsquo;.
10619 The version number supplied on the right side of the operator consists
10620 of a major version number, an optional decimal point, and an optional
10621 minor version (e.g., &lsquo;<samp>7.1</samp>&rsquo;). If the minor version is omitted, it
10622 is assumed to be &lsquo;<samp>0</samp>&rsquo;.
10623 The operator may be separated from the string <code>version</code> and
10624 from the version number argument by whitespace.
10625 The following example sets a variable if the Readline version being used
10626 is 7.0 or newer:
10627 </p><div class="example">
10628 <pre class="example">$if version &gt;= 7.0
10629 set show-mode-in-prompt on
10630 $endif
10631 </pre></div>
10632
10633 </dd>
10634 <dt><code>application</code></dt>
10635 <dd><p>The <var>application</var> construct is used to include
10636 application-specific settings. Each program using the Readline
10637 library sets the <var>application name</var>, and you can test for
10638 a particular value.
10639 This could be used to bind key sequences to functions useful for
10640 a specific program. For instance, the following command adds a
10641 key sequence that quotes the current or previous word in Bash:
10642 </p><div class="example">
10643 <pre class="example">$if Bash
10644 # Quote the current or previous word
10645 &quot;\C-xq&quot;: &quot;\eb\&quot;\ef\&quot;&quot;
10646 $endif
10647 </pre></div>
10648
10649 </dd>
10650 <dt><code>variable</code></dt>
10651 <dd><p>The <var>variable</var> construct provides simple equality tests for Readline
10652 variables and values.
10653 The permitted comparison operators are &lsquo;<samp>=</samp>&rsquo;, &lsquo;<samp>==</samp>&rsquo;, and &lsquo;<samp>!=</samp>&rsquo;.
10654 The variable name must be separated from the comparison operator by
10655 whitespace; the operator may be separated from the value on the right hand
10656 side by whitespace.
10657 Both string and boolean variables may be tested. Boolean variables must be
10658 tested against the values <var>on</var> and <var>off</var>.
10659 The following example is equivalent to the <code>mode=emacs</code> test described
10660 above:
10661 </p><div class="example">
10662 <pre class="example">$if editing-mode == emacs
10663 set show-mode-in-prompt on
10664 $endif
10665 </pre></div>
10666 </dd>
10667 </dl>
10668
10669 </dd>
10670 <dt><code>$endif</code></dt>
10671 <dd><p>This command, as seen in the previous example, terminates an
10672 <code>$if</code> command.
10673 </p>
10674 </dd>
10675 <dt><code>$else</code></dt>
10676 <dd><p>Commands in this branch of the <code>$if</code> directive are executed if
10677 the test fails.
10678 </p>
10679 </dd>
10680 <dt><code>$include</code></dt>
10681 <dd><p>This directive takes a single filename as an argument and reads commands
10682 and bindings from that file.
10683 For example, the following directive reads from <samp>/etc/inputrc</samp>:
10684 </p><div class="example">
10685 <pre class="example">$include /etc/inputrc
10686 </pre></div>
10687 </dd>
10688 </dl>
10689
10690 <hr>
10691 <a name="Sample-Init-File"></a>
10692 <div class="header">
10693 <p>
10694 Previous: <a href="#Conditional-Init-Constructs" accesskey="p" rel="prev">Conditional Init Constructs</a>, Up: <a href="#Readline-Init-File" accesskey="u" rel="up">Readline Init File</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
10695 </div>
10696 <a name="Sample-Init-File-1"></a>
10697 <h4 class="subsection">8.3.3 Sample Init File</h4>
10698
10699 <p>Here is an example of an <var>inputrc</var> file. This illustrates key
10700 binding, variable assignment, and conditional syntax.
10701 </p>
10702 <div class="example">
10703 <pre class="example"># This file controls the behaviour of line input editing for
10704 # programs that use the GNU Readline library. Existing
10705 # programs include FTP, Bash, and GDB.
10706 #
10707 # You can re-read the inputrc file with C-x C-r.
10708 # Lines beginning with '#' are comments.
10709 #
10710 # First, include any system-wide bindings and variable
10711 # assignments from /etc/Inputrc
10712 $include /etc/Inputrc
10713
10714 #
10715 # Set various bindings for emacs mode.
10716
10717 set editing-mode emacs
10718
10719 $if mode=emacs
10720
10721 Meta-Control-h: backward-kill-word Text after the function name is ignored
10722
10723 #
10724 # Arrow keys in keypad mode
10725 #
10726 #&quot;\M-OD&quot;: backward-char
10727 #&quot;\M-OC&quot;: forward-char
10728 #&quot;\M-OA&quot;: previous-history
10729 #&quot;\M-OB&quot;: next-history
10730 #
10731 # Arrow keys in ANSI mode
10732 #
10733 &quot;\M-[D&quot;: backward-char
10734 &quot;\M-[C&quot;: forward-char
10735 &quot;\M-[A&quot;: previous-history
10736 &quot;\M-[B&quot;: next-history
10737 #
10738 # Arrow keys in 8 bit keypad mode
10739 #
10740 #&quot;\M-\C-OD&quot;: backward-char
10741 #&quot;\M-\C-OC&quot;: forward-char
10742 #&quot;\M-\C-OA&quot;: previous-history
10743 #&quot;\M-\C-OB&quot;: next-history
10744 #
10745 # Arrow keys in 8 bit ANSI mode
10746 #
10747 #&quot;\M-\C-[D&quot;: backward-char
10748 #&quot;\M-\C-[C&quot;: forward-char
10749 #&quot;\M-\C-[A&quot;: previous-history
10750 #&quot;\M-\C-[B&quot;: next-history
10751
10752 C-q: quoted-insert
10753
10754 $endif
10755
10756 # An old-style binding. This happens to be the default.
10757 TAB: complete
10758
10759 # Macros that are convenient for shell interaction
10760 $if Bash
10761 # edit the path
10762 &quot;\C-xp&quot;: &quot;PATH=${PATH}\e\C-e\C-a\ef\C-f&quot;
10763 # prepare to type a quoted word --
10764 # insert open and close double quotes
10765 # and move to just after the open quote
10766 &quot;\C-x\&quot;&quot;: &quot;\&quot;\&quot;\C-b&quot;
10767 # insert a backslash (testing backslash escapes
10768 # in sequences and macros)
10769 &quot;\C-x\\&quot;: &quot;\\&quot;
10770 # Quote the current or previous word
10771 &quot;\C-xq&quot;: &quot;\eb\&quot;\ef\&quot;&quot;
10772 # Add a binding to refresh the line, which is unbound
10773 &quot;\C-xr&quot;: redraw-current-line
10774 # Edit variable on current line.
10775 &quot;\M-\C-v&quot;: &quot;\C-a\C-k$\C-y\M-\C-e\C-a\C-y=&quot;
10776 $endif
10777
10778 # use a visible bell if one is available
10779 set bell-style visible
10780
10781 # don't strip characters to 7 bits when reading
10782 set input-meta on
10783
10784 # allow iso-latin1 characters to be inserted rather
10785 # than converted to prefix-meta sequences
10786 set convert-meta off
10787
10788 # display characters with the eighth bit set directly
10789 # rather than as meta-prefixed characters
10790 set output-meta on
10791
10792 # if there are more than 150 possible completions for
10793 # a word, ask the user if he wants to see all of them
10794 set completion-query-items 150
10795
10796 # For FTP
10797 $if Ftp
10798 &quot;\C-xg&quot;: &quot;get \M-?&quot;
10799 &quot;\C-xt&quot;: &quot;put \M-?&quot;
10800 &quot;\M-.&quot;: yank-last-arg
10801 $endif
10802 </pre></div>
10803
10804 <hr>
10805 <a name="Bindable-Readline-Commands"></a>
10806 <div class="header">
10807 <p>
10808 Next: <a href="#Readline-vi-Mode" accesskey="n" rel="next">Readline vi Mode</a>, Previous: <a href="#Readline-Init-File" accesskey="p" rel="prev">Readline Init File</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
10809 </div>
10810 <a name="Bindable-Readline-Commands-1"></a>
10811 <h3 class="section">8.4 Bindable Readline Commands</h3>
10812
10813 <table class="menu" border="0" cellspacing="0">
10814 <tr><td align="left" valign="top">&bull; <a href="#Commands-For-Moving" accesskey="1">Commands For Moving</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Moving about the line.
10815 </td></tr>
10816 <tr><td align="left" valign="top">&bull; <a href="#Commands-For-History" accesskey="2">Commands For History</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Getting at previous lines.
10817 </td></tr>
10818 <tr><td align="left" valign="top">&bull; <a href="#Commands-For-Text" accesskey="3">Commands For Text</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Commands for changing text.
10819 </td></tr>
10820 <tr><td align="left" valign="top">&bull; <a href="#Commands-For-Killing" accesskey="4">Commands For Killing</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Commands for killing and yanking.
10821 </td></tr>
10822 <tr><td align="left" valign="top">&bull; <a href="#Numeric-Arguments" accesskey="5">Numeric Arguments</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Specifying numeric arguments, repeat counts.
10823 </td></tr>
10824 <tr><td align="left" valign="top">&bull; <a href="#Commands-For-Completion" accesskey="6">Commands For Completion</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Getting Readline to do the typing for you.
10825 </td></tr>
10826 <tr><td align="left" valign="top">&bull; <a href="#Keyboard-Macros" accesskey="7">Keyboard Macros</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Saving and re-executing typed characters
10827 </td></tr>
10828 <tr><td align="left" valign="top">&bull; <a href="#Miscellaneous-Commands" accesskey="8">Miscellaneous Commands</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Other miscellaneous commands.
10829 </td></tr>
10830 </table>
10831
10832 <p>This section describes Readline commands that may be bound to key
10833 sequences.
10834 You can list your key bindings by executing
10835 <code>bind&nbsp;<span class="nolinebreak">-P</span></code><!-- /@w --> or, for a more terse format, suitable for an
10836 <var>inputrc</var> file, <code>bind&nbsp;<span class="nolinebreak">-p</span></code><!-- /@w -->. (See <a href="#Bash-Builtins">Bash Builtins</a>.)
10837 Command names without an accompanying key sequence are unbound by default.
10838 </p>
10839 <p>In the following descriptions, <em>point</em> refers to the current cursor
10840 position, and <em>mark</em> refers to a cursor position saved by the
10841 <code>set-mark</code> command.
10842 The text between the point and mark is referred to as the <em>region</em>.
10843 </p>
10844 <hr>
10845 <a name="Commands-For-Moving"></a>
10846 <div class="header">
10847 <p>
10848 Next: <a href="#Commands-For-History" accesskey="n" rel="next">Commands For History</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
10849 </div>
10850 <a name="Commands-For-Moving-1"></a>
10851 <h4 class="subsection">8.4.1 Commands For Moving</h4>
10852 <dl compact="compact">
10853 <dt><code>beginning-of-line (C-a)</code>
10854 <a name="index-beginning_002dof_002dline-_0028C_002da_0029"></a>
10855 </dt>
10856 <dd><p>Move to the start of the current line.
10857 </p>
10858 </dd>
10859 <dt><code>end-of-line (C-e)</code>
10860 <a name="index-end_002dof_002dline-_0028C_002de_0029"></a>
10861 </dt>
10862 <dd><p>Move to the end of the line.
10863 </p>
10864 </dd>
10865 <dt><code>forward-char (C-f)</code>
10866 <a name="index-forward_002dchar-_0028C_002df_0029"></a>
10867 </dt>
10868 <dd><p>Move forward a character.
10869 </p>
10870 </dd>
10871 <dt><code>backward-char (C-b)</code>
10872 <a name="index-backward_002dchar-_0028C_002db_0029"></a>
10873 </dt>
10874 <dd><p>Move back a character.
10875 </p>
10876 </dd>
10877 <dt><code>forward-word (M-f)</code>
10878 <a name="index-forward_002dword-_0028M_002df_0029"></a>
10879 </dt>
10880 <dd><p>Move forward to the end of the next word.
10881 Words are composed of letters and digits.
10882 </p>
10883 </dd>
10884 <dt><code>backward-word (M-b)</code>
10885 <a name="index-backward_002dword-_0028M_002db_0029"></a>
10886 </dt>
10887 <dd><p>Move back to the start of the current or previous word.
10888 Words are composed of letters and digits.
10889 </p>
10890 </dd>
10891 <dt><code>shell-forward-word ()</code>
10892 <a name="index-shell_002dforward_002dword-_0028_0029"></a>
10893 </dt>
10894 <dd><p>Move forward to the end of the next word.
10895 Words are delimited by non-quoted shell metacharacters.
10896 </p>
10897 </dd>
10898 <dt><code>shell-backward-word ()</code>
10899 <a name="index-shell_002dbackward_002dword-_0028_0029"></a>
10900 </dt>
10901 <dd><p>Move back to the start of the current or previous word.
10902 Words are delimited by non-quoted shell metacharacters.
10903 </p>
10904 </dd>
10905 <dt><code>previous-screen-line ()</code>
10906 <a name="index-previous_002dscreen_002dline-_0028_0029"></a>
10907 </dt>
10908 <dd><p>Attempt to move point to the same physical screen column on the previous
10909 physical screen line. This will not have the desired effect if the current
10910 Readline line does not take up more than one physical line or if point is not
10911 greater than the length of the prompt plus the screen width.
10912 </p>
10913 </dd>
10914 <dt><code>next-screen-line ()</code>
10915 <a name="index-next_002dscreen_002dline-_0028_0029"></a>
10916 </dt>
10917 <dd><p>Attempt to move point to the same physical screen column on the next
10918 physical screen line. This will not have the desired effect if the current
10919 Readline line does not take up more than one physical line or if the length
10920 of the current Readline line is not greater than the length of the prompt
10921 plus the screen width.
10922 </p>
10923 </dd>
10924 <dt><code>clear-screen (C-l)</code>
10925 <a name="index-clear_002dscreen-_0028C_002dl_0029"></a>
10926 </dt>
10927 <dd><p>Clear the screen and redraw the current line,
10928 leaving the current line at the top of the screen.
10929 </p>
10930 </dd>
10931 <dt><code>redraw-current-line ()</code>
10932 <a name="index-redraw_002dcurrent_002dline-_0028_0029"></a>
10933 </dt>
10934 <dd><p>Refresh the current line. By default, this is unbound.
10935 </p>
10936 </dd>
10937 </dl>
10938
10939 <hr>
10940 <a name="Commands-For-History"></a>
10941 <div class="header">
10942 <p>
10943 Next: <a href="#Commands-For-Text" accesskey="n" rel="next">Commands For Text</a>, Previous: <a href="#Commands-For-Moving" accesskey="p" rel="prev">Commands For Moving</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
10944 </div>
10945 <a name="Commands-For-Manipulating-The-History"></a>
10946 <h4 class="subsection">8.4.2 Commands For Manipulating The History</h4>
10947
10948 <dl compact="compact">
10949 <dt><code>accept-line (Newline or Return)</code>
10950 <a name="index-accept_002dline-_0028Newline-or-Return_0029"></a>
10951 </dt>
10952 <dd><p>Accept the line regardless of where the cursor is.
10953 If this line is
10954 non-empty, add it to the history list according to the setting of
10955 the <code>HISTCONTROL</code> and <code>HISTIGNORE</code> variables.
10956 If this line is a modified history line, then restore the history line
10957 to its original state.
10958 </p>
10959 </dd>
10960 <dt><code>previous-history (C-p)</code>
10961 <a name="index-previous_002dhistory-_0028C_002dp_0029"></a>
10962 </dt>
10963 <dd><p>Move &lsquo;back&rsquo; through the history list, fetching the previous command.
10964 </p>
10965 </dd>
10966 <dt><code>next-history (C-n)</code>
10967 <a name="index-next_002dhistory-_0028C_002dn_0029"></a>
10968 </dt>
10969 <dd><p>Move &lsquo;forward&rsquo; through the history list, fetching the next command.
10970 </p>
10971 </dd>
10972 <dt><code>beginning-of-history (M-&lt;)</code>
10973 <a name="index-beginning_002dof_002dhistory-_0028M_002d_003c_0029"></a>
10974 </dt>
10975 <dd><p>Move to the first line in the history.
10976 </p>
10977 </dd>
10978 <dt><code>end-of-history (M-&gt;)</code>
10979 <a name="index-end_002dof_002dhistory-_0028M_002d_003e_0029"></a>
10980 </dt>
10981 <dd><p>Move to the end of the input history, i.e., the line currently
10982 being entered.
10983 </p>
10984 </dd>
10985 <dt><code>reverse-search-history (C-r)</code>
10986 <a name="index-reverse_002dsearch_002dhistory-_0028C_002dr_0029"></a>
10987 </dt>
10988 <dd><p>Search backward starting at the current line and moving &lsquo;up&rsquo; through
10989 the history as necessary. This is an incremental search.
10990 </p>
10991 </dd>
10992 <dt><code>forward-search-history (C-s)</code>
10993 <a name="index-forward_002dsearch_002dhistory-_0028C_002ds_0029"></a>
10994 </dt>
10995 <dd><p>Search forward starting at the current line and moving &lsquo;down&rsquo; through
10996 the history as necessary. This is an incremental search.
10997 </p>
10998 </dd>
10999 <dt><code>non-incremental-reverse-search-history (M-p)</code>
11000 <a name="index-non_002dincremental_002dreverse_002dsearch_002dhistory-_0028M_002dp_0029"></a>
11001 </dt>
11002 <dd><p>Search backward starting at the current line and moving &lsquo;up&rsquo;
11003 through the history as necessary using a non-incremental search
11004 for a string supplied by the user.
11005 The search string may match anywhere in a history line.
11006 </p>
11007 </dd>
11008 <dt><code>non-incremental-forward-search-history (M-n)</code>
11009 <a name="index-non_002dincremental_002dforward_002dsearch_002dhistory-_0028M_002dn_0029"></a>
11010 </dt>
11011 <dd><p>Search forward starting at the current line and moving &lsquo;down&rsquo;
11012 through the history as necessary using a non-incremental search
11013 for a string supplied by the user.
11014 The search string may match anywhere in a history line.
11015 </p>
11016 </dd>
11017 <dt><code>history-search-forward ()</code>
11018 <a name="index-history_002dsearch_002dforward-_0028_0029"></a>
11019 </dt>
11020 <dd><p>Search forward through the history for the string of characters
11021 between the start of the current line and the point.
11022 The search string must match at the beginning of a history line.
11023 This is a non-incremental search.
11024 By default, this command is unbound.
11025 </p>
11026 </dd>
11027 <dt><code>history-search-backward ()</code>
11028 <a name="index-history_002dsearch_002dbackward-_0028_0029"></a>
11029 </dt>
11030 <dd><p>Search backward through the history for the string of characters
11031 between the start of the current line and the point.
11032 The search string must match at the beginning of a history line.
11033 This is a non-incremental search.
11034 By default, this command is unbound.
11035 </p>
11036 </dd>
11037 <dt><code>history-substring-search-forward ()</code>
11038 <a name="index-history_002dsubstring_002dsearch_002dforward-_0028_0029"></a>
11039 </dt>
11040 <dd><p>Search forward through the history for the string of characters
11041 between the start of the current line and the point.
11042 The search string may match anywhere in a history line.
11043 This is a non-incremental search.
11044 By default, this command is unbound.
11045 </p>
11046 </dd>
11047 <dt><code>history-substring-search-backward ()</code>
11048 <a name="index-history_002dsubstring_002dsearch_002dbackward-_0028_0029"></a>
11049 </dt>
11050 <dd><p>Search backward through the history for the string of characters
11051 between the start of the current line and the point.
11052 The search string may match anywhere in a history line.
11053 This is a non-incremental search.
11054 By default, this command is unbound.
11055 </p>
11056 </dd>
11057 <dt><code>yank-nth-arg (M-C-y)</code>
11058 <a name="index-yank_002dnth_002darg-_0028M_002dC_002dy_0029"></a>
11059 </dt>
11060 <dd><p>Insert the first argument to the previous command (usually
11061 the second word on the previous line) at point.
11062 With an argument <var>n</var>,
11063 insert the <var>n</var>th word from the previous command (the words
11064 in the previous command begin with word 0). A negative argument
11065 inserts the <var>n</var>th word from the end of the previous command.
11066 Once the argument <var>n</var> is computed, the argument is extracted
11067 as if the &lsquo;<samp>!<var>n</var></samp>&rsquo; history expansion had been specified.
11068 </p>
11069 </dd>
11070 <dt><code>yank-last-arg (M-. or M-_)</code>
11071 <a name="index-yank_002dlast_002darg-_0028M_002d_002e-or-M_002d_005f_0029"></a>
11072 </dt>
11073 <dd><p>Insert last argument to the previous command (the last word of the
11074 previous history entry).
11075 With a numeric argument, behave exactly like <code>yank-nth-arg</code>.
11076 Successive calls to <code>yank-last-arg</code> move back through the history
11077 list, inserting the last word (or the word specified by the argument to
11078 the first call) of each line in turn.
11079 Any numeric argument supplied to these successive calls determines
11080 the direction to move through the history. A negative argument switches
11081 the direction through the history (back or forward).
11082 The history expansion facilities are used to extract the last argument,
11083 as if the &lsquo;<samp>!$</samp>&rsquo; history expansion had been specified.
11084 </p>
11085 </dd>
11086 </dl>
11087
11088 <hr>
11089 <a name="Commands-For-Text"></a>
11090 <div class="header">
11091 <p>
11092 Next: <a href="#Commands-For-Killing" accesskey="n" rel="next">Commands For Killing</a>, Previous: <a href="#Commands-For-History" accesskey="p" rel="prev">Commands For History</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
11093 </div>
11094 <a name="Commands-For-Changing-Text"></a>
11095 <h4 class="subsection">8.4.3 Commands For Changing Text</h4>
11096
11097 <dl compact="compact">
11098 <dt><code><i>end-of-file</i> (usually C-d)</code>
11099 <a name="index-end_002dof_002dfile-_0028usually-C_002dd_0029"></a>
11100 </dt>
11101 <dd><p>The character indicating end-of-file as set, for example, by
11102 <code>stty</code>. If this character is read when there are no characters
11103 on the line, and point is at the beginning of the line, Readline
11104 interprets it as the end of input and returns <small>EOF</small>.
11105 </p>
11106 </dd>
11107 <dt><code>delete-char (C-d)</code>
11108 <a name="index-delete_002dchar-_0028C_002dd_0029"></a>
11109 </dt>
11110 <dd><p>Delete the character at point. If this function is bound to the
11111 same character as the tty <small>EOF</small> character, as <kbd>C-d</kbd>
11112 commonly is, see above for the effects.
11113 </p>
11114 </dd>
11115 <dt><code>backward-delete-char (Rubout)</code>
11116 <a name="index-backward_002ddelete_002dchar-_0028Rubout_0029"></a>
11117 </dt>
11118 <dd><p>Delete the character behind the cursor. A numeric argument means
11119 to kill the characters instead of deleting them.
11120 </p>
11121 </dd>
11122 <dt><code>forward-backward-delete-char ()</code>
11123 <a name="index-forward_002dbackward_002ddelete_002dchar-_0028_0029"></a>
11124 </dt>
11125 <dd><p>Delete the character under the cursor, unless the cursor is at the
11126 end of the line, in which case the character behind the cursor is
11127 deleted. By default, this is not bound to a key.
11128 </p>
11129 </dd>
11130 <dt><code>quoted-insert (C-q or C-v)</code>
11131 <a name="index-quoted_002dinsert-_0028C_002dq-or-C_002dv_0029"></a>
11132 </dt>
11133 <dd><p>Add the next character typed to the line verbatim. This is
11134 how to insert key sequences like <kbd>C-q</kbd>, for example.
11135 </p>
11136
11137 </dd>
11138 <dt><code>self-insert (a, b, A, 1, !, &hellip;)</code>
11139 <a name="index-self_002dinsert-_0028a_002c-b_002c-A_002c-1_002c-_0021_002c-_2026_0029"></a>
11140 </dt>
11141 <dd><p>Insert yourself.
11142 </p>
11143 </dd>
11144 <dt><code>bracketed-paste-begin ()</code>
11145 <a name="index-bracketed_002dpaste_002dbegin-_0028_0029"></a>
11146 </dt>
11147 <dd><p>This function is intended to be bound to the &quot;bracketed paste&quot; escape
11148 sequence sent by some terminals, and such a binding is assigned by default.
11149 It allows Readline to insert the pasted text as a single unit without treating
11150 each character as if it had been read from the keyboard. The characters
11151 are inserted as if each one was bound to <code>self-insert</code> instead of
11152 executing any editing commands.
11153 </p>
11154 </dd>
11155 <dt><code>transpose-chars (C-t)</code>
11156 <a name="index-transpose_002dchars-_0028C_002dt_0029"></a>
11157 </dt>
11158 <dd><p>Drag the character before the cursor forward over
11159 the character at the cursor, moving the
11160 cursor forward as well. If the insertion point
11161 is at the end of the line, then this
11162 transposes the last two characters of the line.
11163 Negative arguments have no effect.
11164 </p>
11165 </dd>
11166 <dt><code>transpose-words (M-t)</code>
11167 <a name="index-transpose_002dwords-_0028M_002dt_0029"></a>
11168 </dt>
11169 <dd><p>Drag the word before point past the word after point,
11170 moving point past that word as well.
11171 If the insertion point is at the end of the line, this transposes
11172 the last two words on the line.
11173 </p>
11174 </dd>
11175 <dt><code>upcase-word (M-u)</code>
11176 <a name="index-upcase_002dword-_0028M_002du_0029"></a>
11177 </dt>
11178 <dd><p>Uppercase the current (or following) word. With a negative argument,
11179 uppercase the previous word, but do not move the cursor.
11180 </p>
11181 </dd>
11182 <dt><code>downcase-word (M-l)</code>
11183 <a name="index-downcase_002dword-_0028M_002dl_0029"></a>
11184 </dt>
11185 <dd><p>Lowercase the current (or following) word. With a negative argument,
11186 lowercase the previous word, but do not move the cursor.
11187 </p>
11188 </dd>
11189 <dt><code>capitalize-word (M-c)</code>
11190 <a name="index-capitalize_002dword-_0028M_002dc_0029"></a>
11191 </dt>
11192 <dd><p>Capitalize the current (or following) word. With a negative argument,
11193 capitalize the previous word, but do not move the cursor.
11194 </p>
11195 </dd>
11196 <dt><code>overwrite-mode ()</code>
11197 <a name="index-overwrite_002dmode-_0028_0029"></a>
11198 </dt>
11199 <dd><p>Toggle overwrite mode. With an explicit positive numeric argument,
11200 switches to overwrite mode. With an explicit non-positive numeric
11201 argument, switches to insert mode. This command affects only
11202 <code>emacs</code> mode; <code>vi</code> mode does overwrite differently.
11203 Each call to <code>readline()</code> starts in insert mode.
11204 </p>
11205 <p>In overwrite mode, characters bound to <code>self-insert</code> replace
11206 the text at point rather than pushing the text to the right.
11207 Characters bound to <code>backward-delete-char</code> replace the character
11208 before point with a space.
11209 </p>
11210 <p>By default, this command is unbound.
11211 </p>
11212 </dd>
11213 </dl>
11214
11215 <hr>
11216 <a name="Commands-For-Killing"></a>
11217 <div class="header">
11218 <p>
11219 Next: <a href="#Numeric-Arguments" accesskey="n" rel="next">Numeric Arguments</a>, Previous: <a href="#Commands-For-Text" accesskey="p" rel="prev">Commands For Text</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
11220 </div>
11221 <a name="Killing-And-Yanking"></a>
11222 <h4 class="subsection">8.4.4 Killing And Yanking</h4>
11223
11224 <dl compact="compact">
11225 <dt><code>kill-line (C-k)</code>
11226 <a name="index-kill_002dline-_0028C_002dk_0029"></a>
11227 </dt>
11228 <dd><p>Kill the text from point to the end of the line.
11229 </p>
11230 </dd>
11231 <dt><code>backward-kill-line (C-x Rubout)</code>
11232 <a name="index-backward_002dkill_002dline-_0028C_002dx-Rubout_0029"></a>
11233 </dt>
11234 <dd><p>Kill backward from the cursor to the beginning of the current line.
11235 </p>
11236 </dd>
11237 <dt><code>unix-line-discard (C-u)</code>
11238 <a name="index-unix_002dline_002ddiscard-_0028C_002du_0029"></a>
11239 </dt>
11240 <dd><p>Kill backward from the cursor to the beginning of the current line.
11241 </p>
11242 </dd>
11243 <dt><code>kill-whole-line ()</code>
11244 <a name="index-kill_002dwhole_002dline-_0028_0029"></a>
11245 </dt>
11246 <dd><p>Kill all characters on the current line, no matter where point is.
11247 By default, this is unbound.
11248 </p>
11249 </dd>
11250 <dt><code>kill-word (M-d)</code>
11251 <a name="index-kill_002dword-_0028M_002dd_0029"></a>
11252 </dt>
11253 <dd><p>Kill from point to the end of the current word, or if between
11254 words, to the end of the next word.
11255 Word boundaries are the same as <code>forward-word</code>.
11256 </p>
11257 </dd>
11258 <dt><code>backward-kill-word (M-<span class="key">DEL</span>)</code>
11259 <a name="index-backward_002dkill_002dword-_0028M_002dDEL_0029"></a>
11260 </dt>
11261 <dd><p>Kill the word behind point.
11262 Word boundaries are the same as <code>backward-word</code>.
11263 </p>
11264 </dd>
11265 <dt><code>shell-kill-word ()</code>
11266 <a name="index-shell_002dkill_002dword-_0028_0029"></a>
11267 </dt>
11268 <dd><p>Kill from point to the end of the current word, or if between
11269 words, to the end of the next word.
11270 Word boundaries are the same as <code>shell-forward-word</code>.
11271 </p>
11272 </dd>
11273 <dt><code>shell-backward-kill-word ()</code>
11274 <a name="index-shell_002dbackward_002dkill_002dword-_0028_0029"></a>
11275 </dt>
11276 <dd><p>Kill the word behind point.
11277 Word boundaries are the same as <code>shell-backward-word</code>.
11278 </p>
11279 </dd>
11280 <dt><code>unix-word-rubout (C-w)</code>
11281 <a name="index-unix_002dword_002drubout-_0028C_002dw_0029"></a>
11282 </dt>
11283 <dd><p>Kill the word behind point, using white space as a word boundary.
11284 The killed text is saved on the kill-ring.
11285 </p>
11286 </dd>
11287 <dt><code>unix-filename-rubout ()</code>
11288 <a name="index-unix_002dfilename_002drubout-_0028_0029"></a>
11289 </dt>
11290 <dd><p>Kill the word behind point, using white space and the slash character
11291 as the word boundaries.
11292 The killed text is saved on the kill-ring.
11293 </p>
11294 </dd>
11295 <dt><code>delete-horizontal-space ()</code>
11296 <a name="index-delete_002dhorizontal_002dspace-_0028_0029"></a>
11297 </dt>
11298 <dd><p>Delete all spaces and tabs around point. By default, this is unbound.
11299 </p>
11300 </dd>
11301 <dt><code>kill-region ()</code>
11302 <a name="index-kill_002dregion-_0028_0029"></a>
11303 </dt>
11304 <dd><p>Kill the text in the current region.
11305 By default, this command is unbound.
11306 </p>
11307 </dd>
11308 <dt><code>copy-region-as-kill ()</code>
11309 <a name="index-copy_002dregion_002das_002dkill-_0028_0029"></a>
11310 </dt>
11311 <dd><p>Copy the text in the region to the kill buffer, so it can be yanked
11312 right away. By default, this command is unbound.
11313 </p>
11314 </dd>
11315 <dt><code>copy-backward-word ()</code>
11316 <a name="index-copy_002dbackward_002dword-_0028_0029"></a>
11317 </dt>
11318 <dd><p>Copy the word before point to the kill buffer.
11319 The word boundaries are the same as <code>backward-word</code>.
11320 By default, this command is unbound.
11321 </p>
11322 </dd>
11323 <dt><code>copy-forward-word ()</code>
11324 <a name="index-copy_002dforward_002dword-_0028_0029"></a>
11325 </dt>
11326 <dd><p>Copy the word following point to the kill buffer.
11327 The word boundaries are the same as <code>forward-word</code>.
11328 By default, this command is unbound.
11329 </p>
11330 </dd>
11331 <dt><code>yank (C-y)</code>
11332 <a name="index-yank-_0028C_002dy_0029"></a>
11333 </dt>
11334 <dd><p>Yank the top of the kill ring into the buffer at point.
11335 </p>
11336 </dd>
11337 <dt><code>yank-pop (M-y)</code>
11338 <a name="index-yank_002dpop-_0028M_002dy_0029"></a>
11339 </dt>
11340 <dd><p>Rotate the kill-ring, and yank the new top. You can only do this if
11341 the prior command is <code>yank</code> or <code>yank-pop</code>.
11342 </p></dd>
11343 </dl>
11344
11345 <hr>
11346 <a name="Numeric-Arguments"></a>
11347 <div class="header">
11348 <p>
11349 Next: <a href="#Commands-For-Completion" accesskey="n" rel="next">Commands For Completion</a>, Previous: <a href="#Commands-For-Killing" accesskey="p" rel="prev">Commands For Killing</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
11350 </div>
11351 <a name="Specifying-Numeric-Arguments"></a>
11352 <h4 class="subsection">8.4.5 Specifying Numeric Arguments</h4>
11353 <dl compact="compact">
11354 <dt><code>digit-argument (<kbd>M-0</kbd>, <kbd>M-1</kbd>, &hellip; <kbd>M--</kbd>)</code>
11355 <a name="index-digit_002dargument-_0028M_002d0_002c-M_002d1_002c-_2026-M_002d_002d_0029"></a>
11356 </dt>
11357 <dd><p>Add this digit to the argument already accumulating, or start a new
11358 argument. <kbd>M--</kbd> starts a negative argument.
11359 </p>
11360 </dd>
11361 <dt><code>universal-argument ()</code>
11362 <a name="index-universal_002dargument-_0028_0029"></a>
11363 </dt>
11364 <dd><p>This is another way to specify an argument.
11365 If this command is followed by one or more digits, optionally with a
11366 leading minus sign, those digits define the argument.
11367 If the command is followed by digits, executing <code>universal-argument</code>
11368 again ends the numeric argument, but is otherwise ignored.
11369 As a special case, if this command is immediately followed by a
11370 character that is neither a digit nor minus sign, the argument count
11371 for the next command is multiplied by four.
11372 The argument count is initially one, so executing this function the
11373 first time makes the argument count four, a second time makes the
11374 argument count sixteen, and so on.
11375 By default, this is not bound to a key.
11376 </p></dd>
11377 </dl>
11378
11379 <hr>
11380 <a name="Commands-For-Completion"></a>
11381 <div class="header">
11382 <p>
11383 Next: <a href="#Keyboard-Macros" accesskey="n" rel="next">Keyboard Macros</a>, Previous: <a href="#Numeric-Arguments" accesskey="p" rel="prev">Numeric Arguments</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
11384 </div>
11385 <a name="Letting-Readline-Type-For-You"></a>
11386 <h4 class="subsection">8.4.6 Letting Readline Type For You</h4>
11387
11388 <dl compact="compact">
11389 <dt><code>complete (<span class="key">TAB</span>)</code>
11390 <a name="index-complete-_0028TAB_0029"></a>
11391 </dt>
11392 <dd><p>Attempt to perform completion on the text before point.
11393 The actual completion performed is application-specific.
11394 Bash attempts completion treating the text as a variable (if the
11395 text begins with &lsquo;<samp>$</samp>&rsquo;), username (if the text begins with
11396 &lsquo;<samp>~</samp>&rsquo;), hostname (if the text begins with &lsquo;<samp>@</samp>&rsquo;), or
11397 command (including aliases and functions) in turn. If none
11398 of these produces a match, filename completion is attempted.
11399 </p>
11400 </dd>
11401 <dt><code>possible-completions (M-?)</code>
11402 <a name="index-possible_002dcompletions-_0028M_002d_003f_0029"></a>
11403 </dt>
11404 <dd><p>List the possible completions of the text before point.
11405 When displaying completions, Readline sets the number of columns used
11406 for display to the value of <code>completion-display-width</code>, the value of
11407 the environment variable <code>COLUMNS</code>, or the screen width, in that order.
11408 </p>
11409 </dd>
11410 <dt><code>insert-completions (M-*)</code>
11411 <a name="index-insert_002dcompletions-_0028M_002d_002a_0029"></a>
11412 </dt>
11413 <dd><p>Insert all completions of the text before point that would have
11414 been generated by <code>possible-completions</code>.
11415 </p>
11416 </dd>
11417 <dt><code>menu-complete ()</code>
11418 <a name="index-menu_002dcomplete-_0028_0029"></a>
11419 </dt>
11420 <dd><p>Similar to <code>complete</code>, but replaces the word to be completed
11421 with a single match from the list of possible completions.
11422 Repeated execution of <code>menu-complete</code> steps through the list
11423 of possible completions, inserting each match in turn.
11424 At the end of the list of completions, the bell is rung
11425 (subject to the setting of <code>bell-style</code>)
11426 and the original text is restored.
11427 An argument of <var>n</var> moves <var>n</var> positions forward in the list
11428 of matches; a negative argument may be used to move backward
11429 through the list.
11430 This command is intended to be bound to <tt class="key">TAB</tt>, but is unbound
11431 by default.
11432 </p>
11433 </dd>
11434 <dt><code>menu-complete-backward ()</code>
11435 <a name="index-menu_002dcomplete_002dbackward-_0028_0029"></a>
11436 </dt>
11437 <dd><p>Identical to <code>menu-complete</code>, but moves backward through the list
11438 of possible completions, as if <code>menu-complete</code> had been given a
11439 negative argument.
11440 </p>
11441 </dd>
11442 <dt><code>delete-char-or-list ()</code>
11443 <a name="index-delete_002dchar_002dor_002dlist-_0028_0029"></a>
11444 </dt>
11445 <dd><p>Deletes the character under the cursor if not at the beginning or
11446 end of the line (like <code>delete-char</code>).
11447 If at the end of the line, behaves identically to
11448 <code>possible-completions</code>.
11449 This command is unbound by default.
11450 </p>
11451 </dd>
11452 <dt><code>complete-filename (M-/)</code>
11453 <a name="index-complete_002dfilename-_0028M_002d_002f_0029"></a>
11454 </dt>
11455 <dd><p>Attempt filename completion on the text before point.
11456 </p>
11457 </dd>
11458 <dt><code>possible-filename-completions (C-x /)</code>
11459 <a name="index-possible_002dfilename_002dcompletions-_0028C_002dx-_002f_0029"></a>
11460 </dt>
11461 <dd><p>List the possible completions of the text before point,
11462 treating it as a filename.
11463 </p>
11464 </dd>
11465 <dt><code>complete-username (M-~)</code>
11466 <a name="index-complete_002dusername-_0028M_002d_007e_0029"></a>
11467 </dt>
11468 <dd><p>Attempt completion on the text before point, treating
11469 it as a username.
11470 </p>
11471 </dd>
11472 <dt><code>possible-username-completions (C-x ~)</code>
11473 <a name="index-possible_002dusername_002dcompletions-_0028C_002dx-_007e_0029"></a>
11474 </dt>
11475 <dd><p>List the possible completions of the text before point,
11476 treating it as a username.
11477 </p>
11478 </dd>
11479 <dt><code>complete-variable (M-$)</code>
11480 <a name="index-complete_002dvariable-_0028M_002d_0024_0029"></a>
11481 </dt>
11482 <dd><p>Attempt completion on the text before point, treating
11483 it as a shell variable.
11484 </p>
11485 </dd>
11486 <dt><code>possible-variable-completions (C-x $)</code>
11487 <a name="index-possible_002dvariable_002dcompletions-_0028C_002dx-_0024_0029"></a>
11488 </dt>
11489 <dd><p>List the possible completions of the text before point,
11490 treating it as a shell variable.
11491 </p>
11492 </dd>
11493 <dt><code>complete-hostname (M-@)</code>
11494 <a name="index-complete_002dhostname-_0028M_002d_0040_0029"></a>
11495 </dt>
11496 <dd><p>Attempt completion on the text before point, treating
11497 it as a hostname.
11498 </p>
11499 </dd>
11500 <dt><code>possible-hostname-completions (C-x @)</code>
11501 <a name="index-possible_002dhostname_002dcompletions-_0028C_002dx-_0040_0029"></a>
11502 </dt>
11503 <dd><p>List the possible completions of the text before point,
11504 treating it as a hostname.
11505 </p>
11506 </dd>
11507 <dt><code>complete-command (M-!)</code>
11508 <a name="index-complete_002dcommand-_0028M_002d_0021_0029"></a>
11509 </dt>
11510 <dd><p>Attempt completion on the text before point, treating
11511 it as a command name. Command completion attempts to
11512 match the text against aliases, reserved words, shell
11513 functions, shell builtins, and finally executable filenames,
11514 in that order.
11515 </p>
11516 </dd>
11517 <dt><code>possible-command-completions (C-x !)</code>
11518 <a name="index-possible_002dcommand_002dcompletions-_0028C_002dx-_0021_0029"></a>
11519 </dt>
11520 <dd><p>List the possible completions of the text before point,
11521 treating it as a command name.
11522 </p>
11523 </dd>
11524 <dt><code>dynamic-complete-history (M-<span class="key">TAB</span>)</code>
11525 <a name="index-dynamic_002dcomplete_002dhistory-_0028M_002dTAB_0029"></a>
11526 </dt>
11527 <dd><p>Attempt completion on the text before point, comparing
11528 the text against lines from the history list for possible
11529 completion matches.
11530 </p>
11531 </dd>
11532 <dt><code>dabbrev-expand ()</code>
11533 <a name="index-dabbrev_002dexpand-_0028_0029"></a>
11534 </dt>
11535 <dd><p>Attempt menu completion on the text before point, comparing
11536 the text against lines from the history list for possible
11537 completion matches.
11538 </p>
11539 </dd>
11540 <dt><code>complete-into-braces (M-{)</code>
11541 <a name="index-complete_002dinto_002dbraces-_0028M_002d_007b_0029"></a>
11542 </dt>
11543 <dd><p>Perform filename completion and insert the list of possible completions
11544 enclosed within braces so the list is available to the shell
11545 (see <a href="#Brace-Expansion">Brace Expansion</a>).
11546 </p>
11547 </dd>
11548 </dl>
11549
11550 <hr>
11551 <a name="Keyboard-Macros"></a>
11552 <div class="header">
11553 <p>
11554 Next: <a href="#Miscellaneous-Commands" accesskey="n" rel="next">Miscellaneous Commands</a>, Previous: <a href="#Commands-For-Completion" accesskey="p" rel="prev">Commands For Completion</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
11555 </div>
11556 <a name="Keyboard-Macros-1"></a>
11557 <h4 class="subsection">8.4.7 Keyboard Macros</h4>
11558 <dl compact="compact">
11559 <dt><code>start-kbd-macro (C-x ()</code>
11560 <a name="index-start_002dkbd_002dmacro-_0028C_002dx-_0028_0029"></a>
11561 </dt>
11562 <dd><p>Begin saving the characters typed into the current keyboard macro.
11563 </p>
11564 </dd>
11565 <dt><code>end-kbd-macro (C-x ))</code>
11566 <a name="index-end_002dkbd_002dmacro-_0028C_002dx-_0029_0029"></a>
11567 </dt>
11568 <dd><p>Stop saving the characters typed into the current keyboard macro
11569 and save the definition.
11570 </p>
11571 </dd>
11572 <dt><code>call-last-kbd-macro (C-x e)</code>
11573 <a name="index-call_002dlast_002dkbd_002dmacro-_0028C_002dx-e_0029"></a>
11574 </dt>
11575 <dd><p>Re-execute the last keyboard macro defined, by making the characters
11576 in the macro appear as if typed at the keyboard.
11577 </p>
11578 </dd>
11579 <dt><code>print-last-kbd-macro ()</code>
11580 <a name="index-print_002dlast_002dkbd_002dmacro-_0028_0029"></a>
11581 </dt>
11582 <dd><p>Print the last keboard macro defined in a format suitable for the
11583 <var>inputrc</var> file.
11584 </p>
11585 </dd>
11586 </dl>
11587
11588 <hr>
11589 <a name="Miscellaneous-Commands"></a>
11590 <div class="header">
11591 <p>
11592 Previous: <a href="#Keyboard-Macros" accesskey="p" rel="prev">Keyboard Macros</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
11593 </div>
11594 <a name="Some-Miscellaneous-Commands"></a>
11595 <h4 class="subsection">8.4.8 Some Miscellaneous Commands</h4>
11596 <dl compact="compact">
11597 <dt><code>re-read-init-file (C-x C-r)</code>
11598 <a name="index-re_002dread_002dinit_002dfile-_0028C_002dx-C_002dr_0029"></a>
11599 </dt>
11600 <dd><p>Read in the contents of the <var>inputrc</var> file, and incorporate
11601 any bindings or variable assignments found there.
11602 </p>
11603 </dd>
11604 <dt><code>abort (C-g)</code>
11605 <a name="index-abort-_0028C_002dg_0029"></a>
11606 </dt>
11607 <dd><p>Abort the current editing command and
11608 ring the terminal&rsquo;s bell (subject to the setting of
11609 <code>bell-style</code>).
11610 </p>
11611 </dd>
11612 <dt><code>do-lowercase-version (M-A, M-B, M-<var>x</var>, &hellip;)</code>
11613 <a name="index-do_002dlowercase_002dversion-_0028M_002dA_002c-M_002dB_002c-M_002dx_002c-_2026_0029"></a>
11614 </dt>
11615 <dd><p>If the metafied character <var>x</var> is upper case, run the command
11616 that is bound to the corresponding metafied lower case character.
11617 The behavior is undefined if <var>x</var> is already lower case.
11618 </p>
11619 </dd>
11620 <dt><code>prefix-meta (<span class="key">ESC</span>)</code>
11621 <a name="index-prefix_002dmeta-_0028ESC_0029"></a>
11622 </dt>
11623 <dd><p>Metafy the next character typed. This is for keyboards
11624 without a meta key. Typing &lsquo;<samp><span class="key">ESC</span> f</samp>&rsquo; is equivalent to typing
11625 <kbd>M-f</kbd>.
11626 </p>
11627 </dd>
11628 <dt><code>undo (C-_ or C-x C-u)</code>
11629 <a name="index-undo-_0028C_002d_005f-or-C_002dx-C_002du_0029"></a>
11630 </dt>
11631 <dd><p>Incremental undo, separately remembered for each line.
11632 </p>
11633 </dd>
11634 <dt><code>revert-line (M-r)</code>
11635 <a name="index-revert_002dline-_0028M_002dr_0029"></a>
11636 </dt>
11637 <dd><p>Undo all changes made to this line. This is like executing the <code>undo</code>
11638 command enough times to get back to the beginning.
11639 </p>
11640 </dd>
11641 <dt><code>tilde-expand (M-&amp;)</code>
11642 <a name="index-tilde_002dexpand-_0028M_002d_0026_0029"></a>
11643 </dt>
11644 <dd><p>Perform tilde expansion on the current word.
11645 </p>
11646 </dd>
11647 <dt><code>set-mark (C-@)</code>
11648 <a name="index-set_002dmark-_0028C_002d_0040_0029"></a>
11649 </dt>
11650 <dd><p>Set the mark to the point. If a
11651 numeric argument is supplied, the mark is set to that position.
11652 </p>
11653 </dd>
11654 <dt><code>exchange-point-and-mark (C-x C-x)</code>
11655 <a name="index-exchange_002dpoint_002dand_002dmark-_0028C_002dx-C_002dx_0029"></a>
11656 </dt>
11657 <dd><p>Swap the point with the mark. The current cursor position is set to
11658 the saved position, and the old cursor position is saved as the mark.
11659 </p>
11660 </dd>
11661 <dt><code>character-search (C-])</code>
11662 <a name="index-character_002dsearch-_0028C_002d_005d_0029"></a>
11663 </dt>
11664 <dd><p>A character is read and point is moved to the next occurrence of that
11665 character. A negative count searches for previous occurrences.
11666 </p>
11667 </dd>
11668 <dt><code>character-search-backward (M-C-])</code>
11669 <a name="index-character_002dsearch_002dbackward-_0028M_002dC_002d_005d_0029"></a>
11670 </dt>
11671 <dd><p>A character is read and point is moved to the previous occurrence
11672 of that character. A negative count searches for subsequent
11673 occurrences.
11674 </p>
11675 </dd>
11676 <dt><code>skip-csi-sequence ()</code>
11677 <a name="index-skip_002dcsi_002dsequence-_0028_0029"></a>
11678 </dt>
11679 <dd><p>Read enough characters to consume a multi-key sequence such as those
11680 defined for keys like Home and End. Such sequences begin with a
11681 Control Sequence Indicator (CSI), usually ESC-[. If this sequence is
11682 bound to &quot;\e[&quot;, keys producing such sequences will have no effect
11683 unless explicitly bound to a readline command, instead of inserting
11684 stray characters into the editing buffer. This is unbound by default,
11685 but usually bound to ESC-[.
11686 </p>
11687 </dd>
11688 <dt><code>insert-comment (M-#)</code>
11689 <a name="index-insert_002dcomment-_0028M_002d_0023_0029"></a>
11690 </dt>
11691 <dd><p>Without a numeric argument, the value of the <code>comment-begin</code>
11692 variable is inserted at the beginning of the current line.
11693 If a numeric argument is supplied, this command acts as a toggle: if
11694 the characters at the beginning of the line do not match the value
11695 of <code>comment-begin</code>, the value is inserted, otherwise
11696 the characters in <code>comment-begin</code> are deleted from the beginning of
11697 the line.
11698 In either case, the line is accepted as if a newline had been typed.
11699 The default value of <code>comment-begin</code> causes this command
11700 to make the current line a shell comment.
11701 If a numeric argument causes the comment character to be removed, the line
11702 will be executed by the shell.
11703 </p>
11704 </dd>
11705 <dt><code>dump-functions ()</code>
11706 <a name="index-dump_002dfunctions-_0028_0029"></a>
11707 </dt>
11708 <dd><p>Print all of the functions and their key bindings to the
11709 Readline output stream. If a numeric argument is supplied,
11710 the output is formatted in such a way that it can be made part
11711 of an <var>inputrc</var> file. This command is unbound by default.
11712 </p>
11713 </dd>
11714 <dt><code>dump-variables ()</code>
11715 <a name="index-dump_002dvariables-_0028_0029"></a>
11716 </dt>
11717 <dd><p>Print all of the settable variables and their values to the
11718 Readline output stream. If a numeric argument is supplied,
11719 the output is formatted in such a way that it can be made part
11720 of an <var>inputrc</var> file. This command is unbound by default.
11721 </p>
11722 </dd>
11723 <dt><code>dump-macros ()</code>
11724 <a name="index-dump_002dmacros-_0028_0029"></a>
11725 </dt>
11726 <dd><p>Print all of the Readline key sequences bound to macros and the
11727 strings they output. If a numeric argument is supplied,
11728 the output is formatted in such a way that it can be made part
11729 of an <var>inputrc</var> file. This command is unbound by default.
11730 </p>
11731 </dd>
11732 <dt><code>glob-complete-word (M-g)</code>
11733 <a name="index-glob_002dcomplete_002dword-_0028M_002dg_0029"></a>
11734 </dt>
11735 <dd><p>The word before point is treated as a pattern for pathname expansion,
11736 with an asterisk implicitly appended. This pattern is used to
11737 generate a list of matching file names for possible completions.
11738 </p>
11739 </dd>
11740 <dt><code>glob-expand-word (C-x *)</code>
11741 <a name="index-glob_002dexpand_002dword-_0028C_002dx-_002a_0029"></a>
11742 </dt>
11743 <dd><p>The word before point is treated as a pattern for pathname expansion,
11744 and the list of matching file names is inserted, replacing the word.
11745 If a numeric argument is supplied, a &lsquo;<samp>*</samp>&rsquo; is appended before
11746 pathname expansion.
11747 </p>
11748 </dd>
11749 <dt><code>glob-list-expansions (C-x g)</code>
11750 <a name="index-glob_002dlist_002dexpansions-_0028C_002dx-g_0029"></a>
11751 </dt>
11752 <dd><p>The list of expansions that would have been generated by
11753 <code>glob-expand-word</code> is displayed, and the line is redrawn.
11754 If a numeric argument is supplied, a &lsquo;<samp>*</samp>&rsquo; is appended before
11755 pathname expansion.
11756 </p>
11757 </dd>
11758 <dt><code>display-shell-version (C-x C-v)</code>
11759 <a name="index-display_002dshell_002dversion-_0028C_002dx-C_002dv_0029"></a>
11760 </dt>
11761 <dd><p>Display version information about the current instance of Bash.
11762 </p>
11763 </dd>
11764 <dt><code>shell-expand-line (M-C-e)</code>
11765 <a name="index-shell_002dexpand_002dline-_0028M_002dC_002de_0029"></a>
11766 </dt>
11767 <dd><p>Expand the line as the shell does.
11768 This performs alias and history expansion as well as all of the shell
11769 word expansions (see <a href="#Shell-Expansions">Shell Expansions</a>).
11770 </p>
11771 </dd>
11772 <dt><code>history-expand-line (M-^)</code>
11773 <a name="index-history_002dexpand_002dline-_0028M_002d_005e_0029"></a>
11774 </dt>
11775 <dd><p>Perform history expansion on the current line.
11776 </p>
11777 </dd>
11778 <dt><code>magic-space ()</code>
11779 <a name="index-magic_002dspace-_0028_0029"></a>
11780 </dt>
11781 <dd><p>Perform history expansion on the current line and insert a space
11782 (see <a href="#History-Interaction">History Interaction</a>).
11783 </p>
11784 </dd>
11785 <dt><code>alias-expand-line ()</code>
11786 <a name="index-alias_002dexpand_002dline-_0028_0029"></a>
11787 </dt>
11788 <dd><p>Perform alias expansion on the current line (see <a href="#Aliases">Aliases</a>).
11789 </p>
11790 </dd>
11791 <dt><code>history-and-alias-expand-line ()</code>
11792 <a name="index-history_002dand_002dalias_002dexpand_002dline-_0028_0029"></a>
11793 </dt>
11794 <dd><p>Perform history and alias expansion on the current line.
11795 </p>
11796 </dd>
11797 <dt><code>insert-last-argument (M-. or M-_)</code>
11798 <a name="index-insert_002dlast_002dargument-_0028M_002d_002e-or-M_002d_005f_0029"></a>
11799 </dt>
11800 <dd><p>A synonym for <code>yank-last-arg</code>.
11801 </p>
11802 </dd>
11803 <dt><code>operate-and-get-next (C-o)</code>
11804 <a name="index-operate_002dand_002dget_002dnext-_0028C_002do_0029"></a>
11805 </dt>
11806 <dd><p>Accept the current line for execution and fetch the next line
11807 relative to the current line from the history for editing.
11808 A numeric argument, if supplied, specifies the history entry to use instead
11809 of the current line.
11810 </p>
11811 </dd>
11812 <dt><code>edit-and-execute-command (C-x C-e)</code>
11813 <a name="index-edit_002dand_002dexecute_002dcommand-_0028C_002dx-C_002de_0029"></a>
11814 </dt>
11815 <dd><p>Invoke an editor on the current command line, and execute the result as shell
11816 commands.
11817 Bash attempts to invoke
11818 <code>$VISUAL</code>, <code>$EDITOR</code>, and <code>emacs</code>
11819 as the editor, in that order.
11820 </p>
11821
11822
11823 </dd>
11824 </dl>
11825
11826 <hr>
11827 <a name="Readline-vi-Mode"></a>
11828 <div class="header">
11829 <p>
11830 Next: <a href="#Programmable-Completion" accesskey="n" rel="next">Programmable Completion</a>, Previous: <a href="#Bindable-Readline-Commands" accesskey="p" rel="prev">Bindable Readline Commands</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
11831 </div>
11832 <a name="Readline-vi-Mode-1"></a>
11833 <h3 class="section">8.5 Readline vi Mode</h3>
11834
11835 <p>While the Readline library does not have a full set of <code>vi</code>
11836 editing functions, it does contain enough to allow simple editing
11837 of the line. The Readline <code>vi</code> mode behaves as specified in
11838 the <small>POSIX</small> standard.
11839 </p>
11840 <p>In order to switch interactively between <code>emacs</code> and <code>vi</code>
11841 editing modes, use the &lsquo;<samp>set -o emacs</samp>&rsquo; and &lsquo;<samp>set -o vi</samp>&rsquo;
11842 commands (see <a href="#The-Set-Builtin">The Set Builtin</a>).
11843 The Readline default is <code>emacs</code> mode.
11844 </p>
11845 <p>When you enter a line in <code>vi</code> mode, you are already placed in
11846 &lsquo;insertion&rsquo; mode, as if you had typed an &lsquo;<samp>i</samp>&rsquo;. Pressing <tt class="key">ESC</tt>
11847 switches you into &lsquo;command&rsquo; mode, where you can edit the text of the
11848 line with the standard <code>vi</code> movement keys, move to previous
11849 history lines with &lsquo;<samp>k</samp>&rsquo; and subsequent lines with &lsquo;<samp>j</samp>&rsquo;, and
11850 so forth.
11851 </p>
11852 <hr>
11853 <a name="Programmable-Completion"></a>
11854 <div class="header">
11855 <p>
11856 Next: <a href="#Programmable-Completion-Builtins" accesskey="n" rel="next">Programmable Completion Builtins</a>, Previous: <a href="#Readline-vi-Mode" accesskey="p" rel="prev">Readline vi Mode</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
11857 </div>
11858 <a name="Programmable-Completion-1"></a>
11859 <h3 class="section">8.6 Programmable Completion</h3>
11860 <a name="index-programmable-completion"></a>
11861
11862 <p>When word completion is attempted for an argument to a command for
11863 which a completion specification (a <var>compspec</var>) has been defined
11864 using the <code>complete</code> builtin (see <a href="#Programmable-Completion-Builtins">Programmable Completion Builtins</a>),
11865 the programmable completion facilities are invoked.
11866 </p>
11867 <p>First, the command name is identified.
11868 If a compspec has been defined for that command, the
11869 compspec is used to generate the list of possible completions for the word.
11870 If the command word is the empty string (completion attempted at the
11871 beginning of an empty line), any compspec defined with
11872 the <samp>-E</samp> option to <code>complete</code> is used.
11873 If the command word is a full pathname, a compspec for the full
11874 pathname is searched for first.
11875 If no compspec is found for the full pathname, an attempt is made to
11876 find a compspec for the portion following the final slash.
11877 If those searches do not result in a compspec, any compspec defined with
11878 the <samp>-D</samp> option to <code>complete</code> is used as the default.
11879 If there is no default compspec, Bash attempts alias expansion
11880 on the command word as a final resort, and attempts to find a compspec
11881 for the command word from any successful expansion
11882 </p>
11883 <p>Once a compspec has been found, it is used to generate the list of
11884 matching words.
11885 If a compspec is not found, the default Bash completion
11886 described above (see <a href="#Commands-For-Completion">Commands For Completion</a>) is performed.
11887 </p>
11888 <p>First, the actions specified by the compspec are used.
11889 Only matches which are prefixed by the word being completed are
11890 returned.
11891 When the <samp>-f</samp> or <samp>-d</samp> option is used for filename or
11892 directory name completion, the shell variable <code>FIGNORE</code> is
11893 used to filter the matches.
11894 See <a href="#Bash-Variables">Bash Variables</a>, for a description of <code>FIGNORE</code>.
11895 </p>
11896 <p>Any completions specified by a filename expansion pattern to the
11897 <samp>-G</samp> option are generated next.
11898 The words generated by the pattern need not match the word being completed.
11899 The <code>GLOBIGNORE</code> shell variable is not used to filter the matches,
11900 but the <code>FIGNORE</code> shell variable is used.
11901 </p>
11902 <p>Next, the string specified as the argument to the <samp>-W</samp> option
11903 is considered.
11904 The string is first split using the characters in the <code>IFS</code>
11905 special variable as delimiters.
11906 Shell quoting is honored within the string, in order to provide a
11907 mechanism for the words to contain shell metacharacters or characters
11908 in the value of <code>IFS</code>.
11909 Each word is then expanded using
11910 brace expansion, tilde expansion, parameter and variable expansion,
11911 command substitution, and arithmetic expansion,
11912 as described above (see <a href="#Shell-Expansions">Shell Expansions</a>).
11913 The results are split using the rules described above
11914 (see <a href="#Word-Splitting">Word Splitting</a>).
11915 The results of the expansion are prefix-matched against the word being
11916 completed, and the matching words become the possible completions.
11917 </p>
11918 <p>After these matches have been generated, any shell function or command
11919 specified with the <samp>-F</samp> and <samp>-C</samp> options is invoked.
11920 When the command or function is invoked, the <code>COMP_LINE</code>,
11921 <code>COMP_POINT</code>, <code>COMP_KEY</code>, and <code>COMP_TYPE</code> variables are
11922 assigned values as described above (see <a href="#Bash-Variables">Bash Variables</a>).
11923 If a shell function is being invoked, the <code>COMP_WORDS</code> and
11924 <code>COMP_CWORD</code> variables are also set.
11925 When the function or command is invoked, the first argument ($1) is the
11926 name of the command whose arguments are being completed, the
11927 second argument ($2) is the word being completed, and the third argument
11928 ($3) is the word preceding the word being completed on the current command
11929 line.
11930 No filtering of the generated completions against the word being completed
11931 is performed; the function or command has complete freedom in generating
11932 the matches.
11933 </p>
11934 <p>Any function specified with <samp>-F</samp> is invoked first.
11935 The function may use any of the shell facilities, including the
11936 <code>compgen</code> and <code>compopt</code> builtins described below
11937 (see <a href="#Programmable-Completion-Builtins">Programmable Completion Builtins</a>), to generate the matches.
11938 It must put the possible completions in the <code>COMPREPLY</code> array
11939 variable, one per array element.
11940 </p>
11941 <p>Next, any command specified with the <samp>-C</samp> option is invoked
11942 in an environment equivalent to command substitution.
11943 It should print a list of completions, one per line, to
11944 the standard output.
11945 Backslash may be used to escape a newline, if necessary.
11946 </p>
11947 <p>After all of the possible completions are generated, any filter
11948 specified with the <samp>-X</samp> option is applied to the list.
11949 The filter is a pattern as used for pathname expansion; a &lsquo;<samp>&amp;</samp>&rsquo;
11950 in the pattern is replaced with the text of the word being completed.
11951 A literal &lsquo;<samp>&amp;</samp>&rsquo; may be escaped with a backslash; the backslash
11952 is removed before attempting a match.
11953 Any completion that matches the pattern will be removed from the list.
11954 A leading &lsquo;<samp>!</samp>&rsquo; negates the pattern; in this case any completion
11955 not matching the pattern will be removed.
11956 If the <code>nocasematch</code> shell option
11957 (see the description of <code>shopt</code> in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>)
11958 is enabled, the match is performed without regard to the case
11959 of alphabetic characters.
11960 </p>
11961 <p>Finally, any prefix and suffix specified with the <samp>-P</samp> and <samp>-S</samp>
11962 options are added to each member of the completion list, and the result is
11963 returned to the Readline completion code as the list of possible
11964 completions.
11965 </p>
11966 <p>If the previously-applied actions do not generate any matches, and the
11967 <samp>-o dirnames</samp> option was supplied to <code>complete</code> when the
11968 compspec was defined, directory name completion is attempted.
11969 </p>
11970 <p>If the <samp>-o plusdirs</samp> option was supplied to <code>complete</code> when
11971 the compspec was defined, directory name completion is attempted and any
11972 matches are added to the results of the other actions.
11973 </p>
11974 <p>By default, if a compspec is found, whatever it generates is returned to
11975 the completion code as the full set of possible completions.
11976 The default Bash completions are not attempted, and the Readline default
11977 of filename completion is disabled.
11978 If the <samp>-o bashdefault</samp> option was supplied to <code>complete</code> when
11979 the compspec was defined, the default Bash completions are attempted
11980 if the compspec generates no matches.
11981 If the <samp>-o default</samp> option was supplied to <code>complete</code> when the
11982 compspec was defined, Readline&rsquo;s default completion will be performed
11983 if the compspec (and, if attempted, the default Bash completions)
11984 generate no matches.
11985 </p>
11986 <p>When a compspec indicates that directory name completion is desired,
11987 the programmable completion functions force Readline to append a slash
11988 to completed names which are symbolic links to directories, subject to
11989 the value of the <var>mark-directories</var> Readline variable, regardless
11990 of the setting of the <var>mark-symlinked-directories</var> Readline variable.
11991 </p>
11992 <p>There is some support for dynamically modifying completions. This is
11993 most useful when used in combination with a default completion specified
11994 with <samp>-D</samp>. It&rsquo;s possible for shell functions executed as completion
11995 handlers to indicate that completion should be retried by returning an
11996 exit status of 124. If a shell function returns 124, and changes
11997 the compspec associated with the command on which completion is being
11998 attempted (supplied as the first argument when the function is executed),
11999 programmable completion restarts from the beginning, with an
12000 attempt to find a new compspec for that command. This allows a set of
12001 completions to be built dynamically as completion is attempted, rather than
12002 being loaded all at once.
12003 </p>
12004 <p>For instance, assuming that there is a library of compspecs, each kept in a
12005 file corresponding to the name of the command, the following default
12006 completion function would load completions dynamically:
12007 </p>
12008 <div class="example">
12009 <pre class="example">_completion_loader()
12010 {
12011 . &quot;/etc/bash_completion.d/$1.sh&quot; &gt;/dev/null 2&gt;&amp;1 &amp;&amp; return 124
12012 }
12013 complete -D -F _completion_loader -o bashdefault -o default
12014 </pre></div>
12015
12016 <hr>
12017 <a name="Programmable-Completion-Builtins"></a>
12018 <div class="header">
12019 <p>
12020 Next: <a href="#A-Programmable-Completion-Example" accesskey="n" rel="next">A Programmable Completion Example</a>, Previous: <a href="#Programmable-Completion" accesskey="p" rel="prev">Programmable Completion</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
12021 </div>
12022 <a name="Programmable-Completion-Builtins-1"></a>
12023 <h3 class="section">8.7 Programmable Completion Builtins</h3>
12024 <a name="index-completion-builtins"></a>
12025
12026 <p>Three builtin commands are available to manipulate the programmable completion
12027 facilities: one to specify how the arguments to a particular command are to
12028 be completed, and two to modify the completion as it is happening.
12029 </p>
12030 <dl compact="compact">
12031 <dt><code>compgen</code></dt>
12032 <dd><a name="index-compgen"></a>
12033 <div class="example">
12034 <pre class="example"><code>compgen [<var>option</var>] [<var>word</var>]</code>
12035 </pre></div>
12036
12037 <p>Generate possible completion matches for <var>word</var> according to
12038 the <var>option</var>s, which may be any option accepted by the
12039 <code>complete</code>
12040 builtin with the exception of <samp>-p</samp> and <samp>-r</samp>, and write
12041 the matches to the standard output.
12042 When using the <samp>-F</samp> or <samp>-C</samp> options, the various shell variables
12043 set by the programmable completion facilities, while available, will not
12044 have useful values.
12045 </p>
12046 <p>The matches will be generated in the same way as if the programmable
12047 completion code had generated them directly from a completion specification
12048 with the same flags.
12049 If <var>word</var> is specified, only those completions matching <var>word</var>
12050 will be displayed.
12051 </p>
12052 <p>The return value is true unless an invalid option is supplied, or no
12053 matches were generated.
12054 </p>
12055 </dd>
12056 <dt><code>complete</code></dt>
12057 <dd><a name="index-complete"></a>
12058 <div class="example">
12059 <pre class="example"><code>complete [-abcdefgjksuv] [-o <var>comp-option</var>] [-DEI] [-A <var>action</var>] [-G <var>globpat</var>]
12060 [-W <var>wordlist</var>] [-F <var>function</var>] [-C <var>command</var>] [-X <var>filterpat</var>]
12061 [-P <var>prefix</var>] [-S <var>suffix</var>] <var>name</var> [<var>name</var> &hellip;]</code>
12062 <code>complete -pr [-DEI] [<var>name</var> &hellip;]</code>
12063 </pre></div>
12064
12065 <p>Specify how arguments to each <var>name</var> should be completed.
12066 If the <samp>-p</samp> option is supplied, or if no options are supplied, existing
12067 completion specifications are printed in a way that allows them to be
12068 reused as input.
12069 The <samp>-r</samp> option removes a completion specification for
12070 each <var>name</var>, or, if no <var>name</var>s are supplied, all
12071 completion specifications.
12072 The <samp>-D</samp> option indicates that other supplied options and actions should
12073 apply to the &ldquo;default&rdquo; command completion; that is, completion attempted
12074 on a command for which no completion has previously been defined.
12075 The <samp>-E</samp> option indicates that other supplied options and actions should
12076 apply to &ldquo;empty&rdquo; command completion; that is, completion attempted on a
12077 blank line.
12078 The <samp>-I</samp> option indicates that other supplied options and actions should
12079 apply to completion on the inital non-assignment word on the line, or after a
12080 command delimiter such as &lsquo;<samp>;</samp>&rsquo; or &lsquo;<samp>|</samp>&rsquo;, which is usually command
12081 name completion.
12082 If multiple options are supplied, the <samp>-D</samp> option takes precedence
12083 over <samp>-E</samp>, and both take precedence over <samp>-I</samp>.
12084 If any of <samp>-D</samp>, <samp>-E</samp>, or <samp>-I</samp> are supplied, any other
12085 <var>name</var> arguments are ignored; these completions only apply to the case
12086 specified by the option.
12087 </p>
12088 <p>The process of applying these completion specifications when word completion
12089 is attempted is described above (see <a href="#Programmable-Completion">Programmable Completion</a>).
12090 </p>
12091 <p>Other options, if specified, have the following meanings.
12092 The arguments to the <samp>-G</samp>, <samp>-W</samp>, and <samp>-X</samp> options
12093 (and, if necessary, the <samp>-P</samp> and <samp>-S</samp> options)
12094 should be quoted to protect them from expansion before the
12095 <code>complete</code> builtin is invoked.
12096 </p>
12097
12098 <dl compact="compact">
12099 <dt><code>-o <var>comp-option</var></code></dt>
12100 <dd><p>The <var>comp-option</var> controls several aspects of the compspec&rsquo;s behavior
12101 beyond the simple generation of completions.
12102 <var>comp-option</var> may be one of:
12103 </p>
12104 <dl compact="compact">
12105 <dt><code>bashdefault</code></dt>
12106 <dd><p>Perform the rest of the default Bash completions if the compspec
12107 generates no matches.
12108 </p>
12109 </dd>
12110 <dt><code>default</code></dt>
12111 <dd><p>Use Readline&rsquo;s default filename completion if the compspec generates
12112 no matches.
12113 </p>
12114 </dd>
12115 <dt><code>dirnames</code></dt>
12116 <dd><p>Perform directory name completion if the compspec generates no matches.
12117 </p>
12118 </dd>
12119 <dt><code>filenames</code></dt>
12120 <dd><p>Tell Readline that the compspec generates filenames, so it can perform any
12121 filename-specific processing (like adding a slash to directory names,
12122 quoting special characters, or suppressing trailing spaces).
12123 This option is intended to be used with shell functions specified
12124 with <samp>-F</samp>.
12125 </p>
12126 </dd>
12127 <dt><code>noquote</code></dt>
12128 <dd><p>Tell Readline not to quote the completed words if they are filenames
12129 (quoting filenames is the default).
12130 </p>
12131 </dd>
12132 <dt><code>nosort</code></dt>
12133 <dd><p>Tell Readline not to sort the list of possible completions alphabetically.
12134 </p>
12135 </dd>
12136 <dt><code>nospace</code></dt>
12137 <dd><p>Tell Readline not to append a space (the default) to words completed at
12138 the end of the line.
12139 </p>
12140 </dd>
12141 <dt><code>plusdirs</code></dt>
12142 <dd><p>After any matches defined by the compspec are generated,
12143 directory name completion is attempted and any
12144 matches are added to the results of the other actions.
12145 </p>
12146 </dd>
12147 </dl>
12148
12149 </dd>
12150 <dt><code>-A <var>action</var></code></dt>
12151 <dd><p>The <var>action</var> may be one of the following to generate a list of possible
12152 completions:
12153 </p>
12154 <dl compact="compact">
12155 <dt><code>alias</code></dt>
12156 <dd><p>Alias names. May also be specified as <samp>-a</samp>.
12157 </p>
12158 </dd>
12159 <dt><code>arrayvar</code></dt>
12160 <dd><p>Array variable names.
12161 </p>
12162 </dd>
12163 <dt><code>binding</code></dt>
12164 <dd><p>Readline key binding names (see <a href="#Bindable-Readline-Commands">Bindable Readline Commands</a>).
12165 </p>
12166 </dd>
12167 <dt><code>builtin</code></dt>
12168 <dd><p>Names of shell builtin commands. May also be specified as <samp>-b</samp>.
12169 </p>
12170 </dd>
12171 <dt><code>command</code></dt>
12172 <dd><p>Command names. May also be specified as <samp>-c</samp>.
12173 </p>
12174 </dd>
12175 <dt><code>directory</code></dt>
12176 <dd><p>Directory names. May also be specified as <samp>-d</samp>.
12177 </p>
12178 </dd>
12179 <dt><code>disabled</code></dt>
12180 <dd><p>Names of disabled shell builtins.
12181 </p>
12182 </dd>
12183 <dt><code>enabled</code></dt>
12184 <dd><p>Names of enabled shell builtins.
12185 </p>
12186 </dd>
12187 <dt><code>export</code></dt>
12188 <dd><p>Names of exported shell variables. May also be specified as <samp>-e</samp>.
12189 </p>
12190 </dd>
12191 <dt><code>file</code></dt>
12192 <dd><p>File names. May also be specified as <samp>-f</samp>.
12193 </p>
12194 </dd>
12195 <dt><code>function</code></dt>
12196 <dd><p>Names of shell functions.
12197 </p>
12198 </dd>
12199 <dt><code>group</code></dt>
12200 <dd><p>Group names. May also be specified as <samp>-g</samp>.
12201 </p>
12202 </dd>
12203 <dt><code>helptopic</code></dt>
12204 <dd><p>Help topics as accepted by the <code>help</code> builtin (see <a href="#Bash-Builtins">Bash Builtins</a>).
12205 </p>
12206 </dd>
12207 <dt><code>hostname</code></dt>
12208 <dd><p>Hostnames, as taken from the file specified by the
12209 <code>HOSTFILE</code> shell variable (see <a href="#Bash-Variables">Bash Variables</a>).
12210 </p>
12211 </dd>
12212 <dt><code>job</code></dt>
12213 <dd><p>Job names, if job control is active. May also be specified as <samp>-j</samp>.
12214 </p>
12215 </dd>
12216 <dt><code>keyword</code></dt>
12217 <dd><p>Shell reserved words. May also be specified as <samp>-k</samp>.
12218 </p>
12219 </dd>
12220 <dt><code>running</code></dt>
12221 <dd><p>Names of running jobs, if job control is active.
12222 </p>
12223 </dd>
12224 <dt><code>service</code></dt>
12225 <dd><p>Service names. May also be specified as <samp>-s</samp>.
12226 </p>
12227 </dd>
12228 <dt><code>setopt</code></dt>
12229 <dd><p>Valid arguments for the <samp>-o</samp> option to the <code>set</code> builtin
12230 (see <a href="#The-Set-Builtin">The Set Builtin</a>).
12231 </p>
12232 </dd>
12233 <dt><code>shopt</code></dt>
12234 <dd><p>Shell option names as accepted by the <code>shopt</code> builtin
12235 (see <a href="#Bash-Builtins">Bash Builtins</a>).
12236 </p>
12237 </dd>
12238 <dt><code>signal</code></dt>
12239 <dd><p>Signal names.
12240 </p>
12241 </dd>
12242 <dt><code>stopped</code></dt>
12243 <dd><p>Names of stopped jobs, if job control is active.
12244 </p>
12245 </dd>
12246 <dt><code>user</code></dt>
12247 <dd><p>User names. May also be specified as <samp>-u</samp>.
12248 </p>
12249 </dd>
12250 <dt><code>variable</code></dt>
12251 <dd><p>Names of all shell variables. May also be specified as <samp>-v</samp>.
12252 </p></dd>
12253 </dl>
12254
12255 </dd>
12256 <dt><code>-C <var>command</var></code></dt>
12257 <dd><p><var>command</var> is executed in a subshell environment, and its output is
12258 used as the possible completions.
12259 </p>
12260 </dd>
12261 <dt><code>-F <var>function</var></code></dt>
12262 <dd><p>The shell function <var>function</var> is executed in the current shell
12263 environment.
12264 When it is executed, $1 is the name of the command whose arguments are
12265 being completed, $2 is the word being completed, and $3 is the word
12266 preceding the word being completed, as described above
12267 (see <a href="#Programmable-Completion">Programmable Completion</a>).
12268 When it finishes, the possible completions are retrieved from the value
12269 of the <code>COMPREPLY</code> array variable.
12270 </p>
12271 </dd>
12272 <dt><code>-G <var>globpat</var></code></dt>
12273 <dd><p>The filename expansion pattern <var>globpat</var> is expanded to generate
12274 the possible completions.
12275 </p>
12276 </dd>
12277 <dt><code>-P <var>prefix</var></code></dt>
12278 <dd><p><var>prefix</var> is added at the beginning of each possible completion
12279 after all other options have been applied.
12280 </p>
12281 </dd>
12282 <dt><code>-S <var>suffix</var></code></dt>
12283 <dd><p><var>suffix</var> is appended to each possible completion
12284 after all other options have been applied.
12285 </p>
12286 </dd>
12287 <dt><code>-W <var>wordlist</var></code></dt>
12288 <dd><p>The <var>wordlist</var> is split using the characters in the
12289 <code>IFS</code> special variable as delimiters, and each resultant word
12290 is expanded.
12291 The possible completions are the members of the resultant list which
12292 match the word being completed.
12293 </p>
12294 </dd>
12295 <dt><code>-X <var>filterpat</var></code></dt>
12296 <dd><p><var>filterpat</var> is a pattern as used for filename expansion.
12297 It is applied to the list of possible completions generated by the
12298 preceding options and arguments, and each completion matching
12299 <var>filterpat</var> is removed from the list.
12300 A leading &lsquo;<samp>!</samp>&rsquo; in <var>filterpat</var> negates the pattern; in this
12301 case, any completion not matching <var>filterpat</var> is removed.
12302 </p></dd>
12303 </dl>
12304
12305 <p>The return value is true unless an invalid option is supplied, an option
12306 other than <samp>-p</samp> or <samp>-r</samp> is supplied without a <var>name</var>
12307 argument, an attempt is made to remove a completion specification for
12308 a <var>name</var> for which no specification exists, or
12309 an error occurs adding a completion specification.
12310 </p>
12311 </dd>
12312 <dt><code>compopt</code></dt>
12313 <dd><a name="index-compopt"></a>
12314 <div class="example">
12315 <pre class="example"><code>compopt</code> [-o <var>option</var>] [-DEI] [+o <var>option</var>] [<var>name</var>]
12316 </pre></div>
12317 <p>Modify completion options for each <var>name</var> according to the
12318 <var>option</var>s, or for the currently-executing completion if no <var>name</var>s
12319 are supplied.
12320 If no <var>option</var>s are given, display the completion options for each
12321 <var>name</var> or the current completion.
12322 The possible values of <var>option</var> are those valid for the <code>complete</code>
12323 builtin described above.
12324 The <samp>-D</samp> option indicates that other supplied options should
12325 apply to the &ldquo;default&rdquo; command completion; that is, completion attempted
12326 on a command for which no completion has previously been defined.
12327 The <samp>-E</samp> option indicates that other supplied options should
12328 apply to &ldquo;empty&rdquo; command completion; that is, completion attempted on a
12329 blank line.
12330 The <samp>-I</samp> option indicates that other supplied options should
12331 apply to completion on the inital non-assignment word on the line, or after a
12332 command delimiter such as &lsquo;<samp>;</samp>&rsquo; or &lsquo;<samp>|</samp>&rsquo;, which is usually command
12333 name completion.
12334 </p>
12335 <p>If multiple options are supplied, the <samp>-D</samp> option takes precedence
12336 over <samp>-E</samp>, and both take precedence over <samp>-I</samp>
12337 </p>
12338 <p>The return value is true unless an invalid option is supplied, an attempt
12339 is made to modify the options for a <var>name</var> for which no completion
12340 specification exists, or an output error occurs.
12341 </p>
12342 </dd>
12343 </dl>
12344
12345 <hr>
12346 <a name="A-Programmable-Completion-Example"></a>
12347 <div class="header">
12348 <p>
12349 Previous: <a href="#Programmable-Completion-Builtins" accesskey="p" rel="prev">Programmable Completion Builtins</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
12350 </div>
12351 <a name="A-Programmable-Completion-Example-1"></a>
12352 <h3 class="section">8.8 A Programmable Completion Example</h3>
12353
12354 <p>The most common way to obtain additional completion functionality beyond
12355 the default actions <code>complete</code> and <code>compgen</code> provide is to use
12356 a shell function and bind it to a particular command using <code>complete -F</code>.
12357 </p>
12358 <p>The following function provides completions for the <code>cd</code> builtin.
12359 It is a reasonably good example of what shell functions must do when
12360 used for completion. This function uses the word passed as <code>$2</code>
12361 to determine the directory name to complete. You can also use the
12362 <code>COMP_WORDS</code> array variable; the current word is indexed by the
12363 <code>COMP_CWORD</code> variable.
12364 </p>
12365 <p>The function relies on the <code>complete</code> and <code>compgen</code> builtins
12366 to do much of the work, adding only the things that the Bash <code>cd</code>
12367 does beyond accepting basic directory names:
12368 tilde expansion (see <a href="#Tilde-Expansion">Tilde Expansion</a>),
12369 searching directories in <var>$CDPATH</var>, which is described above
12370 (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>),
12371 and basic support for the <code>cdable_vars</code> shell option
12372 (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>).
12373 <code>_comp_cd</code> modifies the value of <var>IFS</var> so that it contains only
12374 a newline to accommodate file names containing spaces and tabs &ndash;
12375 <code>compgen</code> prints the possible completions it generates one per line.
12376 </p>
12377 <p>Possible completions go into the <var>COMPREPLY</var> array variable, one
12378 completion per array element. The programmable completion system retrieves
12379 the completions from there when the function returns.
12380 </p>
12381 <div class="example">
12382 <pre class="example"># A completion function for the cd builtin
12383 # based on the cd completion function from the bash_completion package
12384 _comp_cd()
12385 {
12386 local IFS=$' \t\n' # normalize IFS
12387 local cur _skipdot _cdpath
12388 local i j k
12389
12390 # Tilde expansion, which also expands tilde to full pathname
12391 case &quot;$2&quot; in
12392 \~*) eval cur=&quot;$2&quot; ;;
12393 *) cur=$2 ;;
12394 esac
12395
12396 # no cdpath or absolute pathname -- straight directory completion
12397 if [[ -z &quot;${CDPATH:-}&quot; ]] || [[ &quot;$cur&quot; == @(./*|../*|/*) ]]; then
12398 # compgen prints paths one per line; could also use while loop
12399 IFS=$'\n'
12400 COMPREPLY=( $(compgen -d -- &quot;$cur&quot;) )
12401 IFS=$' \t\n'
12402 # CDPATH+directories in the current directory if not in CDPATH
12403 else
12404 IFS=$'\n'
12405 _skipdot=false
12406 # preprocess CDPATH to convert null directory names to .
12407 _cdpath=${CDPATH/#:/.:}
12408 _cdpath=${_cdpath//::/:.:}
12409 _cdpath=${_cdpath/%:/:.}
12410 for i in ${_cdpath//:/$'\n'}; do
12411 if [[ $i -ef . ]]; then _skipdot=true; fi
12412 k=&quot;${#COMPREPLY[@]}&quot;
12413 for j in $( compgen -d -- &quot;$i/$cur&quot; ); do
12414 COMPREPLY[k++]=${j#$i/} # cut off directory
12415 done
12416 done
12417 $_skipdot || COMPREPLY+=( $(compgen -d -- &quot;$cur&quot;) )
12418 IFS=$' \t\n'
12419 fi
12420
12421 # variable names if appropriate shell option set and no completions
12422 if shopt -q cdable_vars &amp;&amp; [[ ${#COMPREPLY[@]} -eq 0 ]]; then
12423 COMPREPLY=( $(compgen -v -- &quot;$cur&quot;) )
12424 fi
12425
12426 return 0
12427 }
12428 </pre></div>
12429
12430 <p>We install the completion function using the <samp>-F</samp> option to
12431 <code>complete</code>:
12432 </p>
12433 <div class="example">
12434 <pre class="example"># Tell readline to quote appropriate and append slashes to directories;
12435 # use the bash default completion for other arguments
12436 complete -o filenames -o nospace -o bashdefault -F _comp_cd cd
12437 </pre></div>
12438
12439 <p>Since we&rsquo;d like Bash and Readline to take care of some
12440 of the other details for us, we use several other options to tell Bash
12441 and Readline what to do. The <samp>-o filenames</samp> option tells Readline
12442 that the possible completions should be treated as filenames, and quoted
12443 appropriately. That option will also cause Readline to append a slash to
12444 filenames it can determine are directories (which is why we might want to
12445 extend <code>_comp_cd</code> to append a slash if we&rsquo;re using directories found
12446 via <var>CDPATH</var>: Readline can&rsquo;t tell those completions are directories).
12447 The <samp>-o nospace</samp> option tells Readline to not append a space
12448 character to the directory name, in case we want to append to it.
12449 The <samp>-o bashdefault</samp> option brings in the rest of the &quot;Bash default&quot;
12450 completions &ndash; possible completion that Bash adds to the default Readline
12451 set. These include things like command name completion, variable completion
12452 for words beginning with &lsquo;<samp>{</samp>&rsquo;, completions containing pathname
12453 expansion patterns (see <a href="#Filename-Expansion">Filename Expansion</a>), and so on.
12454 </p>
12455 <p>Once installed using <code>complete</code>, <code>_comp_cd</code> will be called every
12456 time we attempt word completion for a <code>cd</code> command.
12457 </p>
12458 <p>Many more examples &ndash; an extensive collection of completions for most of
12459 the common GNU, Unix, and Linux commands &ndash; are available as part of the
12460 bash_completion project. This is installed by default on many GNU/Linux
12461 distributions. Originally written by Ian Macdonald, the project now lives
12462 at <a href="http://bash-completion.alioth.debian.org/">http://bash-completion.alioth.debian.org/</a>. There are ports for
12463 other systems such as Solaris and Mac OS X.
12464 </p>
12465 <p>An older version of the bash_completion package is distributed with bash
12466 in the <samp>examples/complete</samp> subdirectory.
12467 </p>
12468 <a name="index-History_002c-how-to-use"></a>
12469
12470 <hr>
12471 <a name="Using-History-Interactively"></a>
12472 <div class="header">
12473 <p>
12474 Next: <a href="#Installing-Bash" accesskey="n" rel="next">Installing Bash</a>, Previous: <a href="#Command-Line-Editing" accesskey="p" rel="prev">Command Line Editing</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
12475 </div>
12476 <a name="Using-History-Interactively-1"></a>
12477 <h2 class="chapter">9 Using History Interactively</h2>
12478
12479
12480 <p>This chapter describes how to use the <small>GNU</small> History Library
12481 interactively, from a user&rsquo;s standpoint.
12482 It should be considered a user&rsquo;s guide.
12483 For information on using the <small>GNU</small> History Library in other programs,
12484 see the <small>GNU</small> Readline Library Manual.
12485 </p>
12486 <table class="menu" border="0" cellspacing="0">
12487 <tr><td align="left" valign="top">&bull; <a href="#Bash-History-Facilities" accesskey="1">Bash History Facilities</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How Bash lets you manipulate your command
12488 history.
12489 </td></tr>
12490 <tr><td align="left" valign="top">&bull; <a href="#Bash-History-Builtins" accesskey="2">Bash History Builtins</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The Bash builtin commands that manipulate
12491 the command history.
12492 </td></tr>
12493 <tr><td align="left" valign="top">&bull; <a href="#History-Interaction" accesskey="3">History Interaction</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What it feels like using History as a user.
12494 </td></tr>
12495 </table>
12496
12497 <hr>
12498 <a name="Bash-History-Facilities"></a>
12499 <div class="header">
12500 <p>
12501 Next: <a href="#Bash-History-Builtins" accesskey="n" rel="next">Bash History Builtins</a>, Up: <a href="#Using-History-Interactively" accesskey="u" rel="up">Using History Interactively</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
12502 </div>
12503 <a name="Bash-History-Facilities-1"></a>
12504 <h3 class="section">9.1 Bash History Facilities</h3>
12505 <a name="index-command-history"></a>
12506 <a name="index-history-list"></a>
12507
12508 <p>When the <samp>-o history</samp> option to the <code>set</code> builtin
12509 is enabled (see <a href="#The-Set-Builtin">The Set Builtin</a>),
12510 the shell provides access to the <em>command history</em>,
12511 the list of commands previously typed.
12512 The value of the <code>HISTSIZE</code> shell variable is used as the
12513 number of commands to save in a history list.
12514 The text of the last <code>$HISTSIZE</code>
12515 commands (default 500) is saved.
12516 The shell stores each command in the history list prior to
12517 parameter and variable expansion
12518 but after history expansion is performed, subject to the
12519 values of the shell variables
12520 <code>HISTIGNORE</code> and <code>HISTCONTROL</code>.
12521 </p>
12522 <p>When the shell starts up, the history is initialized from the
12523 file named by the <code>HISTFILE</code> variable (default <samp>~/.bash_history</samp>).
12524 The file named by the value of <code>HISTFILE</code> is truncated, if
12525 necessary, to contain no more than the number of lines specified by
12526 the value of the <code>HISTFILESIZE</code> variable.
12527 When a shell with history enabled exits, the last
12528 <code>$HISTSIZE</code> lines are copied from the history list to the file
12529 named by <code>$HISTFILE</code>.
12530 If the <code>histappend</code> shell option is set (see <a href="#Bash-Builtins">Bash Builtins</a>),
12531 the lines are appended to the history file,
12532 otherwise the history file is overwritten.
12533 If <code>HISTFILE</code>
12534 is unset, or if the history file is unwritable, the history is not saved.
12535 After saving the history, the history file is truncated
12536 to contain no more than <code>$HISTFILESIZE</code> lines.
12537 If <code>HISTFILESIZE</code> is unset, or set to null, a non-numeric value, or
12538 a numeric value less than zero, the history file is not truncated.
12539 </p>
12540 <p>If the <code>HISTTIMEFORMAT</code> is set, the time stamp information
12541 associated with each history entry is written to the history file,
12542 marked with the history comment character.
12543 When the history file is read, lines beginning with the history
12544 comment character followed immediately by a digit are interpreted
12545 as timestamps for the following history entry.
12546 </p>
12547 <p>The builtin command <code>fc</code> may be used to list or edit and re-execute
12548 a portion of the history list.
12549 The <code>history</code> builtin may be used to display or modify the history
12550 list and manipulate the history file.
12551 When using command-line editing, search commands
12552 are available in each editing mode that provide access to the
12553 history list (see <a href="#Commands-For-History">Commands For History</a>).
12554 </p>
12555 <p>The shell allows control over which commands are saved on the history
12556 list. The <code>HISTCONTROL</code> and <code>HISTIGNORE</code>
12557 variables may be set to cause the shell to save only a subset of the
12558 commands entered.
12559 The <code>cmdhist</code>
12560 shell option, if enabled, causes the shell to attempt to save each
12561 line of a multi-line command in the same history entry, adding
12562 semicolons where necessary to preserve syntactic correctness.
12563 The <code>lithist</code>
12564 shell option causes the shell to save the command with embedded newlines
12565 instead of semicolons.
12566 The <code>shopt</code> builtin is used to set these options.
12567 See <a href="#The-Shopt-Builtin">The Shopt Builtin</a>, for a description of <code>shopt</code>.
12568 </p>
12569 <hr>
12570 <a name="Bash-History-Builtins"></a>
12571 <div class="header">
12572 <p>
12573 Next: <a href="#History-Interaction" accesskey="n" rel="next">History Interaction</a>, Previous: <a href="#Bash-History-Facilities" accesskey="p" rel="prev">Bash History Facilities</a>, Up: <a href="#Using-History-Interactively" accesskey="u" rel="up">Using History Interactively</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
12574 </div>
12575 <a name="Bash-History-Builtins-1"></a>
12576 <h3 class="section">9.2 Bash History Builtins</h3>
12577 <a name="index-history-builtins"></a>
12578
12579 <p>Bash provides two builtin commands which manipulate the
12580 history list and history file.
12581 </p>
12582 <dl compact="compact">
12583 <dt><code>fc</code></dt>
12584 <dd><a name="index-fc"></a>
12585 <div class="example">
12586 <pre class="example"><code>fc [-e <var>ename</var>] [-lnr] [<var>first</var>] [<var>last</var>]</code>
12587 <code>fc -s [<var>pat</var>=<var>rep</var>] [<var>command</var>]</code>
12588 </pre></div>
12589
12590 <p>The first form selects a range of commands from <var>first</var> to
12591 <var>last</var> from the history list and displays or edits and re-executes
12592 them.
12593 Both <var>first</var> and
12594 <var>last</var> may be specified as a string (to locate the most recent
12595 command beginning with that string) or as a number (an index into the
12596 history list, where a negative number is used as an offset from the
12597 current command number). If <var>last</var> is not specified, it is set to
12598 <var>first</var>. If <var>first</var> is not specified, it is set to the previous
12599 command for editing and -16 for listing. If the <samp>-l</samp> flag is
12600 given, the commands are listed on standard output. The <samp>-n</samp> flag
12601 suppresses the command numbers when listing. The <samp>-r</samp> flag
12602 reverses the order of the listing. Otherwise, the editor given by
12603 <var>ename</var> is invoked on a file containing those commands. If
12604 <var>ename</var> is not given, the value of the following variable expansion
12605 is used: <code>${FCEDIT:-${EDITOR:-vi}}</code>. This says to use the
12606 value of the <code>FCEDIT</code> variable if set, or the value of the
12607 <code>EDITOR</code> variable if that is set, or <code>vi</code> if neither is set.
12608 When editing is complete, the edited commands are echoed and executed.
12609 </p>
12610 <p>In the second form, <var>command</var> is re-executed after each instance
12611 of <var>pat</var> in the selected command is replaced by <var>rep</var>.
12612 <var>command</var> is intepreted the same as <var>first</var> above.
12613 </p>
12614 <p>A useful alias to use with the <code>fc</code> command is <code>r='fc -s'</code>, so
12615 that typing &lsquo;<samp>r cc</samp>&rsquo; runs the last command beginning with <code>cc</code>
12616 and typing &lsquo;<samp>r</samp>&rsquo; re-executes the last command (see <a href="#Aliases">Aliases</a>).
12617 </p>
12618 </dd>
12619 <dt><code>history</code></dt>
12620 <dd><a name="index-history"></a>
12621 <div class="example">
12622 <pre class="example">history [<var>n</var>]
12623 history -c
12624 history -d <var>offset</var>
12625 history -d <var>start</var>-<var>end</var>
12626 history [-anrw] [<var>filename</var>]
12627 history -ps <var>arg</var>
12628 </pre></div>
12629
12630 <p>With no options, display the history list with line numbers.
12631 Lines prefixed with a &lsquo;<samp>*</samp>&rsquo; have been modified.
12632 An argument of <var>n</var> lists only the last <var>n</var> lines.
12633 If the shell variable <code>HISTTIMEFORMAT</code> is set and not null,
12634 it is used as a format string for <var>strftime</var> to display
12635 the time stamp associated with each displayed history entry.
12636 No intervening blank is printed between the formatted time stamp
12637 and the history line.
12638 </p>
12639 <p>Options, if supplied, have the following meanings:
12640 </p>
12641 <dl compact="compact">
12642 <dt><code>-c</code></dt>
12643 <dd><p>Clear the history list. This may be combined
12644 with the other options to replace the history list completely.
12645 </p>
12646 </dd>
12647 <dt><code>-d <var>offset</var></code></dt>
12648 <dd><p>Delete the history entry at position <var>offset</var>.
12649 If <var>offset</var> is positive, it should be specified as it appears when
12650 the history is displayed.
12651 If <var>offset</var> is negative, it is interpreted as relative to one greater
12652 than the last history position, so negative indices count back from the
12653 end of the history, and an index of &lsquo;<samp>-1</samp>&rsquo; refers to the current
12654 <code>history -d</code> command.
12655 </p>
12656 </dd>
12657 <dt><code>-d <var>start</var>-<var>end</var></code></dt>
12658 <dd><p>Delete the history entries between positions <var>start</var> and <var>end</var>,
12659 inclusive. Positive and negative values for <var>start</var> and <var>end</var>
12660 are interpreted as described above.
12661 </p>
12662 </dd>
12663 <dt><code>-a</code></dt>
12664 <dd><p>Append the new history lines to the history file.
12665 These are history lines entered since the beginning of the current
12666 Bash session, but not already appended to the history file.
12667 </p>
12668 </dd>
12669 <dt><code>-n</code></dt>
12670 <dd><p>Append the history lines not already read from the history file
12671 to the current history list. These are lines appended to the history
12672 file since the beginning of the current Bash session.
12673 </p>
12674 </dd>
12675 <dt><code>-r</code></dt>
12676 <dd><p>Read the history file and append its contents to
12677 the history list.
12678 </p>
12679 </dd>
12680 <dt><code>-w</code></dt>
12681 <dd><p>Write out the current history list to the history file.
12682 </p>
12683 </dd>
12684 <dt><code>-p</code></dt>
12685 <dd><p>Perform history substitution on the <var>arg</var>s and display the result
12686 on the standard output, without storing the results in the history list.
12687 </p>
12688 </dd>
12689 <dt><code>-s</code></dt>
12690 <dd><p>The <var>arg</var>s are added to the end of
12691 the history list as a single entry.
12692 </p>
12693 </dd>
12694 </dl>
12695
12696 <p>When any of the <samp>-w</samp>, <samp>-r</samp>, <samp>-a</samp>, or <samp>-n</samp> options is
12697 used, if <var>filename</var>
12698 is given, then it is used as the history file. If not, then
12699 the value of the <code>HISTFILE</code> variable is used.
12700 </p>
12701 </dd>
12702 </dl>
12703
12704 <hr>
12705 <a name="History-Interaction"></a>
12706 <div class="header">
12707 <p>
12708 Previous: <a href="#Bash-History-Builtins" accesskey="p" rel="prev">Bash History Builtins</a>, Up: <a href="#Using-History-Interactively" accesskey="u" rel="up">Using History Interactively</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
12709 </div>
12710 <a name="History-Expansion"></a>
12711 <h3 class="section">9.3 History Expansion</h3>
12712 <a name="index-history-expansion"></a>
12713
12714 <p>The History library provides a history expansion feature that is similar
12715 to the history expansion provided by <code>csh</code>. This section
12716 describes the syntax used to manipulate the history information.
12717 </p>
12718 <p>History expansions introduce words from the history list into
12719 the input stream, making it easy to repeat commands, insert the
12720 arguments to a previous command into the current input line, or
12721 fix errors in previous commands quickly.
12722 </p>
12723 <p>History expansion is performed immediately after a complete line
12724 is read, before the shell breaks it into words, and is performed
12725 on each line individually. Bash attempts to inform the history
12726 expansion functions about quoting still in effect from previous lines.
12727 </p>
12728 <p>History expansion takes place in two parts. The first is to determine
12729 which line from the history list should be used during substitution.
12730 The second is to select portions of that line for inclusion into the
12731 current one. The line selected from the history is called the
12732 <em>event</em>, and the portions of that line that are acted upon are
12733 called <em>words</em>. Various <em>modifiers</em> are available to manipulate
12734 the selected words. The line is broken into words in the same fashion
12735 that Bash does, so that several words
12736 surrounded by quotes are considered one word.
12737 History expansions are introduced by the appearance of the
12738 history expansion character, which is &lsquo;<samp>!</samp>&rsquo; by default.
12739 </p>
12740 <p>History expansion implements shell-like quoting conventions:
12741 a backslash can be used to remove the special handling for the next character;
12742 single quotes enclose verbatim sequences of characters, and can be used to
12743 inhibit history expansion;
12744 and characters enclosed within double quotes may be subject to history
12745 expansion, since backslash can escape the history expansion character,
12746 but single quotes may not, since they are not treated specially within
12747 double quotes.
12748 </p>
12749 <p>When using the shell, only &lsquo;<samp>\</samp>&rsquo; and &lsquo;<samp>'</samp>&rsquo; may be used to escape the
12750 history expansion character, but the history expansion character is
12751 also treated as quoted if it immediately precedes the closing double quote
12752 in a double-quoted string.
12753 </p>
12754 <p>Several shell options settable with the <code>shopt</code>
12755 builtin (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>) may be used to tailor
12756 the behavior of history expansion. If the
12757 <code>histverify</code> shell option is enabled, and Readline
12758 is being used, history substitutions are not immediately passed to
12759 the shell parser.
12760 Instead, the expanded line is reloaded into the Readline
12761 editing buffer for further modification.
12762 If Readline is being used, and the <code>histreedit</code>
12763 shell option is enabled, a failed history expansion will be
12764 reloaded into the Readline editing buffer for correction.
12765 The <samp>-p</samp> option to the <code>history</code> builtin command
12766 may be used to see what a history expansion will do before using it.
12767 The <samp>-s</samp> option to the <code>history</code> builtin may be used to
12768 add commands to the end of the history list without actually executing
12769 them, so that they are available for subsequent recall.
12770 This is most useful in conjunction with Readline.
12771 </p>
12772 <p>The shell allows control of the various characters used by the
12773 history expansion mechanism with the <code>histchars</code> variable,
12774 as explained above (see <a href="#Bash-Variables">Bash Variables</a>). The shell uses
12775 the history comment character to mark history timestamps when
12776 writing the history file.
12777 </p>
12778 <table class="menu" border="0" cellspacing="0">
12779 <tr><td align="left" valign="top">&bull; <a href="#Event-Designators" accesskey="1">Event Designators</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to specify which history line to use.
12780 </td></tr>
12781 <tr><td align="left" valign="top">&bull; <a href="#Word-Designators" accesskey="2">Word Designators</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Specifying which words are of interest.
12782 </td></tr>
12783 <tr><td align="left" valign="top">&bull; <a href="#Modifiers" accesskey="3">Modifiers</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Modifying the results of substitution.
12784 </td></tr>
12785 </table>
12786
12787 <hr>
12788 <a name="Event-Designators"></a>
12789 <div class="header">
12790 <p>
12791 Next: <a href="#Word-Designators" accesskey="n" rel="next">Word Designators</a>, Up: <a href="#History-Interaction" accesskey="u" rel="up">History Interaction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
12792 </div>
12793 <a name="Event-Designators-1"></a>
12794 <h4 class="subsection">9.3.1 Event Designators</h4>
12795 <a name="index-event-designators"></a>
12796
12797 <p>An event designator is a reference to a command line entry in the
12798 history list.
12799 Unless the reference is absolute, events are relative to the current
12800 position in the history list.
12801 <a name="index-history-events"></a>
12802 </p>
12803 <dl compact="compact">
12804 <dt><code>!</code></dt>
12805 <dd><p>Start a history substitution, except when followed by a space, tab,
12806 the end of the line, &lsquo;<samp>=</samp>&rsquo; or &lsquo;<samp>(</samp>&rsquo; (when the
12807 <code>extglob</code> shell option is enabled using the <code>shopt</code> builtin).
12808 </p>
12809 </dd>
12810 <dt><code>!<var>n</var></code></dt>
12811 <dd><p>Refer to command line <var>n</var>.
12812 </p>
12813 </dd>
12814 <dt><code>!-<var>n</var></code></dt>
12815 <dd><p>Refer to the command <var>n</var> lines back.
12816 </p>
12817 </dd>
12818 <dt><code>!!</code></dt>
12819 <dd><p>Refer to the previous command. This is a synonym for &lsquo;<samp>!-1</samp>&rsquo;.
12820 </p>
12821 </dd>
12822 <dt><code>!<var>string</var></code></dt>
12823 <dd><p>Refer to the most recent command
12824 preceding the current position in the history list
12825 starting with <var>string</var>.
12826 </p>
12827 </dd>
12828 <dt><code>!?<var>string</var>[?]</code></dt>
12829 <dd><p>Refer to the most recent command
12830 preceding the current position in the history list
12831 containing <var>string</var>.
12832 The trailing
12833 &lsquo;<samp>?</samp>&rsquo; may be omitted if the <var>string</var> is followed immediately by
12834 a newline.
12835 </p>
12836 </dd>
12837 <dt><code>^<var>string1</var>^<var>string2</var>^</code></dt>
12838 <dd><p>Quick Substitution. Repeat the last command, replacing <var>string1</var>
12839 with <var>string2</var>. Equivalent to
12840 <code>!!:s/<var>string1</var>/<var>string2</var>/</code>.
12841 </p>
12842 </dd>
12843 <dt><code>!#</code></dt>
12844 <dd><p>The entire command line typed so far.
12845 </p>
12846 </dd>
12847 </dl>
12848
12849 <hr>
12850 <a name="Word-Designators"></a>
12851 <div class="header">
12852 <p>
12853 Next: <a href="#Modifiers" accesskey="n" rel="next">Modifiers</a>, Previous: <a href="#Event-Designators" accesskey="p" rel="prev">Event Designators</a>, Up: <a href="#History-Interaction" accesskey="u" rel="up">History Interaction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
12854 </div>
12855 <a name="Word-Designators-1"></a>
12856 <h4 class="subsection">9.3.2 Word Designators</h4>
12857
12858 <p>Word designators are used to select desired words from the event.
12859 A &lsquo;<samp>:</samp>&rsquo; separates the event specification from the word designator. It
12860 may be omitted if the word designator begins with a &lsquo;<samp>^</samp>&rsquo;, &lsquo;<samp>$</samp>&rsquo;,
12861 &lsquo;<samp>*</samp>&rsquo;, &lsquo;<samp>-</samp>&rsquo;, or &lsquo;<samp>%</samp>&rsquo;. Words are numbered from the beginning
12862 of the line, with the first word being denoted by 0 (zero). Words are
12863 inserted into the current line separated by single spaces.
12864 </p>
12865 <p>For example,
12866 </p>
12867 <dl compact="compact">
12868 <dt><code>!!</code></dt>
12869 <dd><p>designates the preceding command. When you type this, the preceding
12870 command is repeated in toto.
12871 </p>
12872 </dd>
12873 <dt><code>!!:$</code></dt>
12874 <dd><p>designates the last argument of the preceding command. This may be
12875 shortened to <code>!$</code>.
12876 </p>
12877 </dd>
12878 <dt><code>!fi:2</code></dt>
12879 <dd><p>designates the second argument of the most recent command starting with
12880 the letters <code>fi</code>.
12881 </p></dd>
12882 </dl>
12883
12884 <p>Here are the word designators:
12885 </p>
12886 <dl compact="compact">
12887 <dt><code>0 (zero)</code></dt>
12888 <dd><p>The <code>0</code>th word. For many applications, this is the command word.
12889 </p>
12890 </dd>
12891 <dt><code><var>n</var></code></dt>
12892 <dd><p>The <var>n</var>th word.
12893 </p>
12894 </dd>
12895 <dt><code>^</code></dt>
12896 <dd><p>The first argument; that is, word 1.
12897 </p>
12898 </dd>
12899 <dt><code>$</code></dt>
12900 <dd><p>The last argument.
12901 </p>
12902 </dd>
12903 <dt><code>%</code></dt>
12904 <dd><p>The word matched by the most recent &lsquo;<samp>?<var>string</var>?</samp>&rsquo; search.
12905 </p>
12906 </dd>
12907 <dt><code><var>x</var>-<var>y</var></code></dt>
12908 <dd><p>A range of words; &lsquo;<samp>-<var>y</var></samp>&rsquo; abbreviates &lsquo;<samp>0-<var>y</var></samp>&rsquo;.
12909 </p>
12910 </dd>
12911 <dt><code>*</code></dt>
12912 <dd><p>All of the words, except the <code>0</code>th. This is a synonym for &lsquo;<samp>1-$</samp>&rsquo;.
12913 It is not an error to use &lsquo;<samp>*</samp>&rsquo; if there is just one word in the event;
12914 the empty string is returned in that case.
12915 </p>
12916 </dd>
12917 <dt><code><var>x</var>*</code></dt>
12918 <dd><p>Abbreviates &lsquo;<samp><var>x</var>-$</samp>&rsquo;
12919 </p>
12920 </dd>
12921 <dt><code><var>x</var>-</code></dt>
12922 <dd><p>Abbreviates &lsquo;<samp><var>x</var>-$</samp>&rsquo; like &lsquo;<samp><var>x</var>*</samp>&rsquo;, but omits the last word.
12923 </p>
12924 </dd>
12925 </dl>
12926
12927 <p>If a word designator is supplied without an event specification, the
12928 previous command is used as the event.
12929 </p>
12930 <hr>
12931 <a name="Modifiers"></a>
12932 <div class="header">
12933 <p>
12934 Previous: <a href="#Word-Designators" accesskey="p" rel="prev">Word Designators</a>, Up: <a href="#History-Interaction" accesskey="u" rel="up">History Interaction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
12935 </div>
12936 <a name="Modifiers-1"></a>
12937 <h4 class="subsection">9.3.3 Modifiers</h4>
12938
12939 <p>After the optional word designator, you can add a sequence of one or more
12940 of the following modifiers, each preceded by a &lsquo;<samp>:</samp>&rsquo;.
12941 </p>
12942 <dl compact="compact">
12943 <dt><code>h</code></dt>
12944 <dd><p>Remove a trailing pathname component, leaving only the head.
12945 </p>
12946 </dd>
12947 <dt><code>t</code></dt>
12948 <dd><p>Remove all leading pathname components, leaving the tail.
12949 </p>
12950 </dd>
12951 <dt><code>r</code></dt>
12952 <dd><p>Remove a trailing suffix of the form &lsquo;<samp>.<var>suffix</var></samp>&rsquo;, leaving
12953 the basename.
12954 </p>
12955 </dd>
12956 <dt><code>e</code></dt>
12957 <dd><p>Remove all but the trailing suffix.
12958 </p>
12959 </dd>
12960 <dt><code>p</code></dt>
12961 <dd><p>Print the new command but do not execute it.
12962 </p>
12963 </dd>
12964 <dt><code>q</code></dt>
12965 <dd><p>Quote the substituted words, escaping further substitutions.
12966 </p>
12967 </dd>
12968 <dt><code>x</code></dt>
12969 <dd><p>Quote the substituted words as with &lsquo;<samp>q</samp>&rsquo;,
12970 but break into words at spaces, tabs, and newlines.
12971 </p>
12972 </dd>
12973 <dt><code>s/<var>old</var>/<var>new</var>/</code></dt>
12974 <dd><p>Substitute <var>new</var> for the first occurrence of <var>old</var> in the
12975 event line. Any delimiter may be used in place of &lsquo;<samp>/</samp>&rsquo;.
12976 The delimiter may be quoted in <var>old</var> and <var>new</var>
12977 with a single backslash. If &lsquo;<samp>&amp;</samp>&rsquo; appears in <var>new</var>,
12978 it is replaced by <var>old</var>. A single backslash will quote
12979 the &lsquo;<samp>&amp;</samp>&rsquo;. The final delimiter is optional if it is the last
12980 character on the input line.
12981 </p>
12982 </dd>
12983 <dt><code>&amp;</code></dt>
12984 <dd><p>Repeat the previous substitution.
12985 </p>
12986 </dd>
12987 <dt><code>g</code></dt>
12988 <dt><code>a</code></dt>
12989 <dd><p>Cause changes to be applied over the entire event line. Used in
12990 conjunction with &lsquo;<samp>s</samp>&rsquo;, as in <code>gs/<var>old</var>/<var>new</var>/</code>,
12991 or with &lsquo;<samp>&amp;</samp>&rsquo;.
12992 </p>
12993 </dd>
12994 <dt><code>G</code></dt>
12995 <dd><p>Apply the following &lsquo;<samp>s</samp>&rsquo; modifier once to each word in the event.
12996 </p>
12997 </dd>
12998 </dl>
12999
13000 <hr>
13001 <a name="Installing-Bash"></a>
13002 <div class="header">
13003 <p>
13004 Next: <a href="#Reporting-Bugs" accesskey="n" rel="next">Reporting Bugs</a>, Previous: <a href="#Using-History-Interactively" accesskey="p" rel="prev">Using History Interactively</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
13005 </div>
13006 <a name="Installing-Bash-1"></a>
13007 <h2 class="chapter">10 Installing Bash</h2>
13008
13009 <p>This chapter provides basic instructions for installing Bash on
13010 the various supported platforms. The distribution supports the
13011 <small>GNU</small> operating systems, nearly every version of Unix, and several
13012 non-Unix systems such as BeOS and Interix.
13013 Other independent ports exist for
13014 <small>MS-DOS</small>, <small>OS/2</small>, and Windows platforms.
13015 </p>
13016 <table class="menu" border="0" cellspacing="0">
13017 <tr><td align="left" valign="top">&bull; <a href="#Basic-Installation" accesskey="1">Basic Installation</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Installation instructions.
13018 </td></tr>
13019 <tr><td align="left" valign="top">&bull; <a href="#Compilers-and-Options" accesskey="2">Compilers and Options</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to set special options for various
13020 systems.
13021 </td></tr>
13022 <tr><td align="left" valign="top">&bull; <a href="#Compiling-For-Multiple-Architectures" accesskey="3">Compiling For Multiple Architectures</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to compile Bash for more
13023 than one kind of system from
13024 the same source tree.
13025 </td></tr>
13026 <tr><td align="left" valign="top">&bull; <a href="#Installation-Names" accesskey="4">Installation Names</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to set the various paths used by the installation.
13027 </td></tr>
13028 <tr><td align="left" valign="top">&bull; <a href="#Specifying-the-System-Type" accesskey="5">Specifying the System Type</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to configure Bash for a particular system.
13029 </td></tr>
13030 <tr><td align="left" valign="top">&bull; <a href="#Sharing-Defaults" accesskey="6">Sharing Defaults</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to share default configuration values among GNU
13031 programs.
13032 </td></tr>
13033 <tr><td align="left" valign="top">&bull; <a href="#Operation-Controls" accesskey="7">Operation Controls</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Options recognized by the configuration program.
13034 </td></tr>
13035 <tr><td align="left" valign="top">&bull; <a href="#Optional-Features" accesskey="8">Optional Features</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to enable and disable optional features when
13036 building Bash.
13037 </td></tr>
13038 </table>
13039
13040 <hr>
13041 <a name="Basic-Installation"></a>
13042 <div class="header">
13043 <p>
13044 Next: <a href="#Compilers-and-Options" accesskey="n" rel="next">Compilers and Options</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
13045 </div>
13046 <a name="Basic-Installation-1"></a>
13047 <h3 class="section">10.1 Basic Installation</h3>
13048 <a name="index-installation"></a>
13049 <a name="index-configuration"></a>
13050 <a name="index-Bash-installation"></a>
13051 <a name="index-Bash-configuration"></a>
13052
13053 <p>These are installation instructions for Bash.
13054 </p>
13055 <p>The simplest way to compile Bash is:
13056 </p>
13057 <ol>
13058 <li> <code>cd</code> to the directory containing the source code and type
13059 &lsquo;<samp>./configure</samp>&rsquo; to configure Bash for your system. If you&rsquo;re
13060 using <code>csh</code> on an old version of System V, you might need to
13061 type &lsquo;<samp>sh ./configure</samp>&rsquo; instead to prevent <code>csh</code> from trying
13062 to execute <code>configure</code> itself.
13063
13064 <p>Running <code>configure</code> takes some time.
13065 While running, it prints messages telling which features it is
13066 checking for.
13067 </p>
13068 </li><li> Type &lsquo;<samp>make</samp>&rsquo; to compile Bash and build the <code>bashbug</code> bug
13069 reporting script.
13070
13071 </li><li> Optionally, type &lsquo;<samp>make tests</samp>&rsquo; to run the Bash test suite.
13072
13073 </li><li> Type &lsquo;<samp>make install</samp>&rsquo; to install <code>bash</code> and <code>bashbug</code>.
13074 This will also install the manual pages and Info file.
13075
13076 </li></ol>
13077
13078 <p>The <code>configure</code> shell script attempts to guess correct
13079 values for various system-dependent variables used during
13080 compilation. It uses those values to create a <samp>Makefile</samp> in
13081 each directory of the package (the top directory, the
13082 <samp>builtins</samp>, <samp>doc</samp>, and <samp>support</samp> directories,
13083 each directory under <samp>lib</samp>, and several others). It also creates a
13084 <samp>config.h</samp> file containing system-dependent definitions.
13085 Finally, it creates a shell script named <code>config.status</code> that you
13086 can run in the future to recreate the current configuration, a
13087 file <samp>config.cache</samp> that saves the results of its tests to
13088 speed up reconfiguring, and a file <samp>config.log</samp> containing
13089 compiler output (useful mainly for debugging <code>configure</code>).
13090 If at some point
13091 <samp>config.cache</samp> contains results you don&rsquo;t want to keep, you
13092 may remove or edit it.
13093 </p>
13094 <p>To find out more about the options and arguments that the
13095 <code>configure</code> script understands, type
13096 </p>
13097 <div class="example">
13098 <pre class="example">bash-4.2$ ./configure --help
13099 </pre></div>
13100
13101 <p>at the Bash prompt in your Bash source directory.
13102 </p>
13103 <p>If you want to build Bash in a directory separate from the source
13104 directory &ndash; to build for multiple architectures, for example &ndash;
13105 just use the full path to the configure script. The following commands
13106 will build bash in a directory under <samp>/usr/local/build</samp> from
13107 the source code in <samp>/usr/local/src/bash-4.4</samp>:
13108 </p>
13109 <div class="example">
13110 <pre class="example">mkdir /usr/local/build/bash-4.4
13111 cd /usr/local/build/bash-4.4
13112 bash /usr/local/src/bash-4.4/configure
13113 make
13114 </pre></div>
13115
13116 <p>See <a href="#Compiling-For-Multiple-Architectures">Compiling For Multiple Architectures</a> for more information
13117 about building in a directory separate from the source.
13118 </p>
13119 <p>If you need to do unusual things to compile Bash, please
13120 try to figure out how <code>configure</code> could check whether or not
13121 to do them, and mail diffs or instructions to
13122 <a href="mailto:bash-maintainers@gnu.org">bash-maintainers@gnu.org</a> so they can be
13123 considered for the next release.
13124 </p>
13125 <p>The file <samp>configure.ac</samp> is used to create <code>configure</code>
13126 by a program called Autoconf. You only need
13127 <samp>configure.ac</samp> if you want to change it or regenerate
13128 <code>configure</code> using a newer version of Autoconf. If
13129 you do this, make sure you are using Autoconf version 2.50 or
13130 newer.
13131 </p>
13132 <p>You can remove the program binaries and object files from the
13133 source code directory by typing &lsquo;<samp>make clean</samp>&rsquo;. To also remove the
13134 files that <code>configure</code> created (so you can compile Bash for
13135 a different kind of computer), type &lsquo;<samp>make distclean</samp>&rsquo;.
13136 </p>
13137 <hr>
13138 <a name="Compilers-and-Options"></a>
13139 <div class="header">
13140 <p>
13141 Next: <a href="#Compiling-For-Multiple-Architectures" accesskey="n" rel="next">Compiling For Multiple Architectures</a>, Previous: <a href="#Basic-Installation" accesskey="p" rel="prev">Basic Installation</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
13142 </div>
13143 <a name="Compilers-and-Options-1"></a>
13144 <h3 class="section">10.2 Compilers and Options</h3>
13145
13146 <p>Some systems require unusual options for compilation or linking
13147 that the <code>configure</code> script does not know about. You can
13148 give <code>configure</code> initial values for variables by setting
13149 them in the environment. Using a Bourne-compatible shell, you
13150 can do that on the command line like this:
13151 </p>
13152 <div class="example">
13153 <pre class="example">CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
13154 </pre></div>
13155
13156 <p>On systems that have the <code>env</code> program, you can do it like this:
13157 </p>
13158 <div class="example">
13159 <pre class="example">env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
13160 </pre></div>
13161
13162 <p>The configuration process uses GCC to build Bash if it
13163 is available.
13164 </p>
13165 <hr>
13166 <a name="Compiling-For-Multiple-Architectures"></a>
13167 <div class="header">
13168 <p>
13169 Next: <a href="#Installation-Names" accesskey="n" rel="next">Installation Names</a>, Previous: <a href="#Compilers-and-Options" accesskey="p" rel="prev">Compilers and Options</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
13170 </div>
13171 <a name="Compiling-For-Multiple-Architectures-1"></a>
13172 <h3 class="section">10.3 Compiling For Multiple Architectures</h3>
13173
13174 <p>You can compile Bash for more than one kind of computer at the
13175 same time, by placing the object files for each architecture in their
13176 own directory. To do this, you must use a version of <code>make</code> that
13177 supports the <code>VPATH</code> variable, such as GNU <code>make</code>.
13178 <code>cd</code> to the
13179 directory where you want the object files and executables to go and run
13180 the <code>configure</code> script from the source directory
13181 (see <a href="#Basic-Installation">Basic Installation</a>).
13182 You may need to
13183 supply the <samp>--srcdir=PATH</samp> argument to tell <code>configure</code> where the
13184 source files are. <code>configure</code> automatically checks for the
13185 source code in the directory that <code>configure</code> is in and in &lsquo;..&rsquo;.
13186 </p>
13187 <p>If you have to use a <code>make</code> that does not supports the <code>VPATH</code>
13188 variable, you can compile Bash for one architecture at a
13189 time in the source code directory. After you have installed
13190 Bash for one architecture, use &lsquo;<samp>make distclean</samp>&rsquo; before
13191 reconfiguring for another architecture.
13192 </p>
13193 <p>Alternatively, if your system supports symbolic links, you can use the
13194 <samp>support/mkclone</samp> script to create a build tree which has
13195 symbolic links back to each file in the source directory. Here&rsquo;s an
13196 example that creates a build directory in the current directory from a
13197 source directory <samp>/usr/gnu/src/bash-2.0</samp>:
13198 </p>
13199 <div class="example">
13200 <pre class="example">bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 .
13201 </pre></div>
13202
13203 <p>The <code>mkclone</code> script requires Bash, so you must have already built
13204 Bash for at least one architecture before you can create build
13205 directories for other architectures.
13206 </p>
13207 <hr>
13208 <a name="Installation-Names"></a>
13209 <div class="header">
13210 <p>
13211 Next: <a href="#Specifying-the-System-Type" accesskey="n" rel="next">Specifying the System Type</a>, Previous: <a href="#Compiling-For-Multiple-Architectures" accesskey="p" rel="prev">Compiling For Multiple Architectures</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
13212 </div>
13213 <a name="Installation-Names-1"></a>
13214 <h3 class="section">10.4 Installation Names</h3>
13215
13216 <p>By default, &lsquo;<samp>make install</samp>&rsquo; will install into
13217 <samp>/usr/local/bin</samp>, <samp>/usr/local/man</samp>, etc. You can
13218 specify an installation prefix other than <samp>/usr/local</samp> by
13219 giving <code>configure</code> the option <samp>--prefix=<var>PATH</var></samp>,
13220 or by specifying a value for the <code>DESTDIR</code> &lsquo;<samp>make</samp>&rsquo;
13221 variable when running &lsquo;<samp>make install</samp>&rsquo;.
13222 </p>
13223 <p>You can specify separate installation prefixes for
13224 architecture-specific files and architecture-independent files.
13225 If you give <code>configure</code> the option
13226 <samp>--exec-prefix=<var>PATH</var></samp>, &lsquo;<samp>make install</samp>&rsquo; will use
13227 <var>PATH</var> as the prefix for installing programs and libraries.
13228 Documentation and other data files will still use the regular prefix.
13229 </p>
13230 <hr>
13231 <a name="Specifying-the-System-Type"></a>
13232 <div class="header">
13233 <p>
13234 Next: <a href="#Sharing-Defaults" accesskey="n" rel="next">Sharing Defaults</a>, Previous: <a href="#Installation-Names" accesskey="p" rel="prev">Installation Names</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
13235 </div>
13236 <a name="Specifying-the-System-Type-1"></a>
13237 <h3 class="section">10.5 Specifying the System Type</h3>
13238
13239 <p>There may be some features <code>configure</code> can not figure out
13240 automatically, but need to determine by the type of host Bash
13241 will run on. Usually <code>configure</code> can figure that
13242 out, but if it prints a message saying it can not guess the host
13243 type, give it the <samp>--host=TYPE</samp> option. &lsquo;<samp>TYPE</samp>&rsquo; can
13244 either be a short name for the system type, such as &lsquo;<samp>sun4</samp>&rsquo;,
13245 or a canonical name with three fields: &lsquo;<samp>CPU-COMPANY-SYSTEM</samp>&rsquo;
13246 (e.g., &lsquo;<samp>i386-unknown-freebsd4.2</samp>&rsquo;).
13247 </p>
13248 <p>See the file <samp>support/config.sub</samp> for the possible
13249 values of each field.
13250 </p>
13251 <hr>
13252 <a name="Sharing-Defaults"></a>
13253 <div class="header">
13254 <p>
13255 Next: <a href="#Operation-Controls" accesskey="n" rel="next">Operation Controls</a>, Previous: <a href="#Specifying-the-System-Type" accesskey="p" rel="prev">Specifying the System Type</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
13256 </div>
13257 <a name="Sharing-Defaults-1"></a>
13258 <h3 class="section">10.6 Sharing Defaults</h3>
13259
13260 <p>If you want to set default values for <code>configure</code> scripts to
13261 share, you can create a site shell script called
13262 <code>config.site</code> that gives default values for variables like
13263 <code>CC</code>, <code>cache_file</code>, and <code>prefix</code>. <code>configure</code>
13264 looks for <samp>PREFIX/share/config.site</samp> if it exists, then
13265 <samp>PREFIX/etc/config.site</samp> if it exists. Or, you can set the
13266 <code>CONFIG_SITE</code> environment variable to the location of the site
13267 script. A warning: the Bash <code>configure</code> looks for a site script,
13268 but not all <code>configure</code> scripts do.
13269 </p>
13270 <hr>
13271 <a name="Operation-Controls"></a>
13272 <div class="header">
13273 <p>
13274 Next: <a href="#Optional-Features" accesskey="n" rel="next">Optional Features</a>, Previous: <a href="#Sharing-Defaults" accesskey="p" rel="prev">Sharing Defaults</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
13275 </div>
13276 <a name="Operation-Controls-1"></a>
13277 <h3 class="section">10.7 Operation Controls</h3>
13278
13279 <p><code>configure</code> recognizes the following options to control how it
13280 operates.
13281 </p>
13282 <dl compact="compact">
13283 <dt><code>--cache-file=<var>file</var></code></dt>
13284 <dd><p>Use and save the results of the tests in
13285 <var>file</var> instead of <samp>./config.cache</samp>. Set <var>file</var> to
13286 <samp>/dev/null</samp> to disable caching, for debugging
13287 <code>configure</code>.
13288 </p>
13289 </dd>
13290 <dt><code>--help</code></dt>
13291 <dd><p>Print a summary of the options to <code>configure</code>, and exit.
13292 </p>
13293 </dd>
13294 <dt><code>--quiet</code></dt>
13295 <dt><code>--silent</code></dt>
13296 <dt><code>-q</code></dt>
13297 <dd><p>Do not print messages saying which checks are being made.
13298 </p>
13299 </dd>
13300 <dt><code>--srcdir=<var>dir</var></code></dt>
13301 <dd><p>Look for the Bash source code in directory <var>dir</var>. Usually
13302 <code>configure</code> can determine that directory automatically.
13303 </p>
13304 </dd>
13305 <dt><code>--version</code></dt>
13306 <dd><p>Print the version of Autoconf used to generate the <code>configure</code>
13307 script, and exit.
13308 </p></dd>
13309 </dl>
13310
13311 <p><code>configure</code> also accepts some other, not widely used, boilerplate
13312 options. &lsquo;<samp>configure --help</samp>&rsquo; prints the complete list.
13313 </p>
13314 <hr>
13315 <a name="Optional-Features"></a>
13316 <div class="header">
13317 <p>
13318 Previous: <a href="#Operation-Controls" accesskey="p" rel="prev">Operation Controls</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
13319 </div>
13320 <a name="Optional-Features-1"></a>
13321 <h3 class="section">10.8 Optional Features</h3>
13322
13323 <p>The Bash <code>configure</code> has a number of <samp>--enable-<var>feature</var></samp>
13324 options, where <var>feature</var> indicates an optional part of Bash.
13325 There are also several <samp>--with-<var>package</var></samp> options,
13326 where <var>package</var> is something like &lsquo;<samp>bash-malloc</samp>&rsquo; or &lsquo;<samp>purify</samp>&rsquo;.
13327 To turn off the default use of a package, use
13328 <samp>--without-<var>package</var></samp>. To configure Bash without a feature
13329 that is enabled by default, use <samp>--disable-<var>feature</var></samp>.
13330 </p>
13331 <p>Here is a complete list of the <samp>--enable-</samp> and
13332 <samp>--with-</samp> options that the Bash <code>configure</code> recognizes.
13333 </p>
13334 <dl compact="compact">
13335 <dt><code>--with-afs</code></dt>
13336 <dd><p>Define if you are using the Andrew File System from Transarc.
13337 </p>
13338 </dd>
13339 <dt><code>--with-bash-malloc</code></dt>
13340 <dd><p>Use the Bash version of
13341 <code>malloc</code> in the directory <samp>lib/malloc</samp>. This is not the same
13342 <code>malloc</code> that appears in <small>GNU</small> libc, but an older version
13343 originally derived from the 4.2 <small>BSD</small> <code>malloc</code>. This <code>malloc</code>
13344 is very fast, but wastes some space on each allocation.
13345 This option is enabled by default.
13346 The <samp>NOTES</samp> file contains a list of systems for
13347 which this should be turned off, and <code>configure</code> disables this
13348 option automatically for a number of systems.
13349 </p>
13350 </dd>
13351 <dt><code>--with-curses</code></dt>
13352 <dd><p>Use the curses library instead of the termcap library. This should
13353 be supplied if your system has an inadequate or incomplete termcap
13354 database.
13355 </p>
13356 </dd>
13357 <dt><code>--with-gnu-malloc</code></dt>
13358 <dd><p>A synonym for <code>--with-bash-malloc</code>.
13359 </p>
13360 </dd>
13361 <dt><code>--with-installed-readline[=<var>PREFIX</var>]</code></dt>
13362 <dd><p>Define this to make Bash link with a locally-installed version of Readline
13363 rather than the version in <samp>lib/readline</samp>. This works only with
13364 Readline 5.0 and later versions. If <var>PREFIX</var> is <code>yes</code> or not
13365 supplied, <code>configure</code> uses the values of the make variables
13366 <code>includedir</code> and <code>libdir</code>, which are subdirectories of <code>prefix</code>
13367 by default, to find the installed version of Readline if it is not in
13368 the standard system include and library directories.
13369 If <var>PREFIX</var> is <code>no</code>, Bash links with the version in
13370 <samp>lib/readline</samp>.
13371 If <var>PREFIX</var> is set to any other value, <code>configure</code> treats it as
13372 a directory pathname and looks for
13373 the installed version of Readline in subdirectories of that directory
13374 (include files in <var>PREFIX</var>/<code>include</code> and the library in
13375 <var>PREFIX</var>/<code>lib</code>).
13376 </p>
13377 </dd>
13378 <dt><code>--with-purify</code></dt>
13379 <dd><p>Define this to use the Purify memory allocation checker from Rational
13380 Software.
13381 </p>
13382 </dd>
13383 <dt><code>--enable-minimal-config</code></dt>
13384 <dd><p>This produces a shell with minimal features, close to the historical
13385 Bourne shell.
13386 </p></dd>
13387 </dl>
13388
13389 <p>There are several <samp>--enable-</samp> options that alter how Bash is
13390 compiled and linked, rather than changing run-time features.
13391 </p>
13392 <dl compact="compact">
13393 <dt><code>--enable-largefile</code></dt>
13394 <dd><p>Enable support for <a href="http://www.unix.org/version2/whatsnew/lfs20mar.html">large files</a> if the operating system requires special compiler options
13395 to build programs which can access large files. This is enabled by
13396 default, if the operating system provides large file support.
13397 </p>
13398 </dd>
13399 <dt><code>--enable-profiling</code></dt>
13400 <dd><p>This builds a Bash binary that produces profiling information to be
13401 processed by <code>gprof</code> each time it is executed.
13402 </p>
13403 </dd>
13404 <dt><code>--enable-static-link</code></dt>
13405 <dd><p>This causes Bash to be linked statically, if <code>gcc</code> is being used.
13406 This could be used to build a version to use as root&rsquo;s shell.
13407 </p></dd>
13408 </dl>
13409
13410 <p>The &lsquo;<samp>minimal-config</samp>&rsquo; option can be used to disable all of
13411 the following options, but it is processed first, so individual
13412 options may be enabled using &lsquo;<samp>enable-<var>feature</var></samp>&rsquo;.
13413 </p>
13414 <p>All of the following options except for &lsquo;<samp>disabled-builtins</samp>&rsquo;,
13415 &lsquo;<samp>direxpand-default</samp>&rsquo;, and
13416 &lsquo;<samp>xpg-echo-default</samp>&rsquo; are
13417 enabled by default, unless the operating system does not provide the
13418 necessary support.
13419 </p>
13420 <dl compact="compact">
13421 <dt><code>--enable-alias</code></dt>
13422 <dd><p>Allow alias expansion and include the <code>alias</code> and <code>unalias</code>
13423 builtins (see <a href="#Aliases">Aliases</a>).
13424 </p>
13425 </dd>
13426 <dt><code>--enable-arith-for-command</code></dt>
13427 <dd><p>Include support for the alternate form of the <code>for</code> command
13428 that behaves like the C language <code>for</code> statement
13429 (see <a href="#Looping-Constructs">Looping Constructs</a>).
13430 </p>
13431 </dd>
13432 <dt><code>--enable-array-variables</code></dt>
13433 <dd><p>Include support for one-dimensional array shell variables
13434 (see <a href="#Arrays">Arrays</a>).
13435 </p>
13436 </dd>
13437 <dt><code>--enable-bang-history</code></dt>
13438 <dd><p>Include support for <code>csh</code>-like history substitution
13439 (see <a href="#History-Interaction">History Interaction</a>).
13440 </p>
13441 </dd>
13442 <dt><code>--enable-brace-expansion</code></dt>
13443 <dd><p>Include <code>csh</code>-like brace expansion
13444 ( <code>b{a,b}c</code> &rarr; <code>bac bbc</code> ).
13445 See <a href="#Brace-Expansion">Brace Expansion</a>, for a complete description.
13446 </p>
13447 </dd>
13448 <dt><code>--enable-casemod-attributes</code></dt>
13449 <dd><p>Include support for case-modifying attributes in the <code>declare</code> builtin
13450 and assignment statements. Variables with the <var>uppercase</var> attribute,
13451 for example, will have their values converted to uppercase upon assignment.
13452 </p>
13453 </dd>
13454 <dt><code>--enable-casemod-expansion</code></dt>
13455 <dd><p>Include support for case-modifying word expansions.
13456 </p>
13457 </dd>
13458 <dt><code>--enable-command-timing</code></dt>
13459 <dd><p>Include support for recognizing <code>time</code> as a reserved word and for
13460 displaying timing statistics for the pipeline following <code>time</code>
13461 (see <a href="#Pipelines">Pipelines</a>).
13462 This allows pipelines as well as shell builtins and functions to be timed.
13463 </p>
13464 </dd>
13465 <dt><code>--enable-cond-command</code></dt>
13466 <dd><p>Include support for the <code>[[</code> conditional command.
13467 (see <a href="#Conditional-Constructs">Conditional Constructs</a>).
13468 </p>
13469 </dd>
13470 <dt><code>--enable-cond-regexp</code></dt>
13471 <dd><p>Include support for matching <small>POSIX</small> regular expressions using the
13472 &lsquo;<samp>=~</samp>&rsquo; binary operator in the <code>[[</code> conditional command.
13473 (see <a href="#Conditional-Constructs">Conditional Constructs</a>).
13474 </p>
13475 </dd>
13476 <dt><code>--enable-coprocesses</code></dt>
13477 <dd><p>Include support for coprocesses and the <code>coproc</code> reserved word
13478 (see <a href="#Pipelines">Pipelines</a>).
13479 </p>
13480 </dd>
13481 <dt><code>--enable-debugger</code></dt>
13482 <dd><p>Include support for the bash debugger (distributed separately).
13483 </p>
13484 </dd>
13485 <dt><code>--enable-dev-fd-stat-broken</code></dt>
13486 <dd><p>If calling <code>stat</code> on /dev/fd/<var>N</var> returns different results than
13487 calling <code>fstat</code> on file descriptor <var>N</var>, supply this option to
13488 enable a workaround.
13489 This has implications for conditional commands that test file attributes.
13490 </p>
13491 </dd>
13492 <dt><code>--enable-direxpand-default</code></dt>
13493 <dd><p>Cause the <code>direxpand</code> shell option (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>)
13494 to be enabled by default when the shell starts.
13495 It is normally disabled by default.
13496 </p>
13497 </dd>
13498 <dt><code>--enable-directory-stack</code></dt>
13499 <dd><p>Include support for a <code>csh</code>-like directory stack and the
13500 <code>pushd</code>, <code>popd</code>, and <code>dirs</code> builtins
13501 (see <a href="#The-Directory-Stack">The Directory Stack</a>).
13502 </p>
13503 </dd>
13504 <dt><code>--enable-disabled-builtins</code></dt>
13505 <dd><p>Allow builtin commands to be invoked via &lsquo;<samp>builtin xxx</samp>&rsquo;
13506 even after <code>xxx</code> has been disabled using &lsquo;<samp>enable -n xxx</samp>&rsquo;.
13507 See <a href="#Bash-Builtins">Bash Builtins</a>, for details of the <code>builtin</code> and
13508 <code>enable</code> builtin commands.
13509 </p>
13510 </dd>
13511 <dt><code>--enable-dparen-arithmetic</code></dt>
13512 <dd><p>Include support for the <code>((&hellip;))</code> command
13513 (see <a href="#Conditional-Constructs">Conditional Constructs</a>).
13514 </p>
13515 </dd>
13516 <dt><code>--enable-extended-glob</code></dt>
13517 <dd><p>Include support for the extended pattern matching features described
13518 above under <a href="#Pattern-Matching">Pattern Matching</a>.
13519 </p>
13520 </dd>
13521 <dt><code>--enable-extended-glob-default</code></dt>
13522 <dd><p>Set the default value of the <var>extglob</var> shell option described
13523 above under <a href="#The-Shopt-Builtin">The Shopt Builtin</a> to be enabled.
13524 </p>
13525 </dd>
13526 <dt><code>--enable-function-import</code></dt>
13527 <dd><p>Include support for importing function definitions exported by another
13528 instance of the shell from the environment. This option is enabled by
13529 default.
13530 </p>
13531 </dd>
13532 <dt><code>--enable-glob-asciirange-default</code></dt>
13533 <dd><p>Set the default value of the <var>globasciiranges</var> shell option described
13534 above under <a href="#The-Shopt-Builtin">The Shopt Builtin</a> to be enabled.
13535 This controls the behavior of character ranges when used in pattern matching
13536 bracket expressions.
13537 </p>
13538 </dd>
13539 <dt><code>--enable-help-builtin</code></dt>
13540 <dd><p>Include the <code>help</code> builtin, which displays help on shell builtins and
13541 variables (see <a href="#Bash-Builtins">Bash Builtins</a>).
13542 </p>
13543 </dd>
13544 <dt><code>--enable-history</code></dt>
13545 <dd><p>Include command history and the <code>fc</code> and <code>history</code>
13546 builtin commands (see <a href="#Bash-History-Facilities">Bash History Facilities</a>).
13547 </p>
13548 </dd>
13549 <dt><code>--enable-job-control</code></dt>
13550 <dd><p>This enables the job control features (see <a href="#Job-Control">Job Control</a>),
13551 if the operating system supports them.
13552 </p>
13553 </dd>
13554 <dt><code>--enable-multibyte</code></dt>
13555 <dd><p>This enables support for multibyte characters if the operating
13556 system provides the necessary support.
13557 </p>
13558 </dd>
13559 <dt><code>--enable-net-redirections</code></dt>
13560 <dd><p>This enables the special handling of filenames of the form
13561 <code>/dev/tcp/<var>host</var>/<var>port</var></code> and
13562 <code>/dev/udp/<var>host</var>/<var>port</var></code>
13563 when used in redirections (see <a href="#Redirections">Redirections</a>).
13564 </p>
13565 </dd>
13566 <dt><code>--enable-process-substitution</code></dt>
13567 <dd><p>This enables process substitution (see <a href="#Process-Substitution">Process Substitution</a>) if
13568 the operating system provides the necessary support.
13569 </p>
13570 </dd>
13571 <dt><code>--enable-progcomp</code></dt>
13572 <dd><p>Enable the programmable completion facilities
13573 (see <a href="#Programmable-Completion">Programmable Completion</a>).
13574 If Readline is not enabled, this option has no effect.
13575 </p>
13576 </dd>
13577 <dt><code>--enable-prompt-string-decoding</code></dt>
13578 <dd><p>Turn on the interpretation of a number of backslash-escaped characters
13579 in the <code>$PS0</code>, <code>$PS1</code>, <code>$PS2</code>, and <code>$PS4</code> prompt
13580 strings. See <a href="#Controlling-the-Prompt">Controlling the Prompt</a>, for a complete list of prompt
13581 string escape sequences.
13582 </p>
13583 </dd>
13584 <dt><code>--enable-readline</code></dt>
13585 <dd><p>Include support for command-line editing and history with the Bash
13586 version of the Readline library (see <a href="#Command-Line-Editing">Command Line Editing</a>).
13587 </p>
13588 </dd>
13589 <dt><code>--enable-restricted</code></dt>
13590 <dd><p>Include support for a <em>restricted shell</em>. If this is enabled, Bash,
13591 when called as <code>rbash</code>, enters a restricted mode. See
13592 <a href="#The-Restricted-Shell">The Restricted Shell</a>, for a description of restricted mode.
13593 </p>
13594 </dd>
13595 <dt><code>--enable-select</code></dt>
13596 <dd><p>Include the <code>select</code> compound command, which allows the generation of
13597 simple menus (see <a href="#Conditional-Constructs">Conditional Constructs</a>).
13598 </p>
13599 </dd>
13600 <dt><code>--enable-separate-helpfiles</code></dt>
13601 <dd><p>Use external files for the documentation displayed by the <code>help</code> builtin
13602 instead of storing the text internally.
13603 </p>
13604 </dd>
13605 <dt><code>--enable-single-help-strings</code></dt>
13606 <dd><p>Store the text displayed by the <code>help</code> builtin as a single string for
13607 each help topic. This aids in translating the text to different languages.
13608 You may need to disable this if your compiler cannot handle very long string
13609 literals.
13610 </p>
13611 </dd>
13612 <dt><code>--enable-strict-posix-default</code></dt>
13613 <dd><p>Make Bash <small>POSIX</small>-conformant by default (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>).
13614 </p>
13615 </dd>
13616 <dt><code>--enable-usg-echo-default</code></dt>
13617 <dd><p>A synonym for <code>--enable-xpg-echo-default</code>.
13618 </p>
13619 </dd>
13620 <dt><code>--enable-xpg-echo-default</code></dt>
13621 <dd><p>Make the <code>echo</code> builtin expand backslash-escaped characters by default,
13622 without requiring the <samp>-e</samp> option.
13623 This sets the default value of the <code>xpg_echo</code> shell option to <code>on</code>,
13624 which makes the Bash <code>echo</code> behave more like the version specified in
13625 the Single Unix Specification, version 3.
13626 See <a href="#Bash-Builtins">Bash Builtins</a>, for a description of the escape sequences that
13627 <code>echo</code> recognizes.
13628 </p></dd>
13629 </dl>
13630
13631 <p>The file <samp>config-top.h</samp> contains C Preprocessor
13632 &lsquo;<samp>#define</samp>&rsquo; statements for options which are not settable from
13633 <code>configure</code>.
13634 Some of these are not meant to be changed; beware of the consequences if
13635 you do.
13636 Read the comments associated with each definition for more
13637 information about its effect.
13638 </p>
13639 <hr>
13640 <a name="Reporting-Bugs"></a>
13641 <div class="header">
13642 <p>
13643 Next: <a href="#Major-Differences-From-The-Bourne-Shell" accesskey="n" rel="next">Major Differences From The Bourne Shell</a>, Previous: <a href="#Installing-Bash" accesskey="p" rel="prev">Installing Bash</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
13644 </div>
13645 <a name="Reporting-Bugs-1"></a>
13646 <h2 class="appendix">Appendix A Reporting Bugs</h2>
13647
13648 <p>Please report all bugs you find in Bash.
13649 But first, you should
13650 make sure that it really is a bug, and that it appears in the latest
13651 version of Bash.
13652 The latest version of Bash is always available for FTP from
13653 <a href="ftp://ftp.gnu.org/pub/gnu/bash/">ftp://ftp.gnu.org/pub/gnu/bash/</a>.
13654 </p>
13655 <p>Once you have determined that a bug actually exists, use the
13656 <code>bashbug</code> command to submit a bug report.
13657 If you have a fix, you are encouraged to mail that as well!
13658 Suggestions and &lsquo;philosophical&rsquo; bug reports may be mailed
13659 to <a href="mailto:bug-bash@gnu.org">bug-bash@gnu.org</a> or posted to the Usenet
13660 newsgroup <code>gnu.bash.bug</code>.
13661 </p>
13662 <p>All bug reports should include:
13663 </p><ul>
13664 <li> The version number of Bash.
13665 </li><li> The hardware and operating system.
13666 </li><li> The compiler used to compile Bash.
13667 </li><li> A description of the bug behaviour.
13668 </li><li> A short script or &lsquo;recipe&rsquo; which exercises the bug and may be used
13669 to reproduce it.
13670 </li></ul>
13671
13672 <p><code>bashbug</code> inserts the first three items automatically into
13673 the template it provides for filing a bug report.
13674 </p>
13675 <p>Please send all reports concerning this manual to
13676 <a href="mailto:bug-bash@gnu.org">bug-bash@gnu.org</a>.
13677 </p>
13678 <hr>
13679 <a name="Major-Differences-From-The-Bourne-Shell"></a>
13680 <div class="header">
13681 <p>
13682 Next: <a href="#GNU-Free-Documentation-License" accesskey="n" rel="next">GNU Free Documentation License</a>, Previous: <a href="#Reporting-Bugs" accesskey="p" rel="prev">Reporting Bugs</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
13683 </div>
13684 <a name="Major-Differences-From-The-Bourne-Shell-1"></a>
13685 <h2 class="appendix">Appendix B Major Differences From The Bourne Shell</h2>
13686
13687 <p>Bash implements essentially the same grammar, parameter and
13688 variable expansion, redirection, and quoting as the Bourne Shell.
13689 Bash uses the <small>POSIX</small> standard as the specification of
13690 how these features are to be implemented. There are some
13691 differences between the traditional Bourne shell and Bash; this
13692 section quickly details the differences of significance. A
13693 number of these differences are explained in greater depth in
13694 previous sections.
13695 This section uses the version of <code>sh</code> included in SVR4.2 (the
13696 last version of the historical Bourne shell) as the baseline reference.
13697 </p>
13698 <ul>
13699 <li> Bash is <small>POSIX</small>-conformant, even where the <small>POSIX</small> specification
13700 differs from traditional <code>sh</code> behavior (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>).
13701
13702 </li><li> Bash has multi-character invocation options (see <a href="#Invoking-Bash">Invoking Bash</a>).
13703
13704 </li><li> Bash has command-line editing (see <a href="#Command-Line-Editing">Command Line Editing</a>) and
13705 the <code>bind</code> builtin.
13706
13707 </li><li> Bash provides a programmable word completion mechanism
13708 (see <a href="#Programmable-Completion">Programmable Completion</a>), and builtin commands
13709 <code>complete</code>, <code>compgen</code>, and <code>compopt</code>, to
13710 manipulate it.
13711
13712 </li><li> Bash has command history (see <a href="#Bash-History-Facilities">Bash History Facilities</a>) and the
13713 <code>history</code> and <code>fc</code> builtins to manipulate it.
13714 The Bash history list maintains timestamp information and uses the
13715 value of the <code>HISTTIMEFORMAT</code> variable to display it.
13716
13717 </li><li> Bash implements <code>csh</code>-like history expansion
13718 (see <a href="#History-Interaction">History Interaction</a>).
13719
13720 </li><li> Bash has one-dimensional array variables (see <a href="#Arrays">Arrays</a>), and the
13721 appropriate variable expansions and assignment syntax to use them.
13722 Several of the Bash builtins take options to act on arrays.
13723 Bash provides a number of built-in array variables.
13724
13725 </li><li> The <code>$'&hellip;'</code> quoting syntax, which expands ANSI-C
13726 backslash-escaped characters in the text between the single quotes,
13727 is supported (see <a href="#ANSI_002dC-Quoting">ANSI-C Quoting</a>).
13728
13729 </li><li> Bash supports the <code>$&quot;&hellip;&quot;</code> quoting syntax to do
13730 locale-specific translation of the characters between the double
13731 quotes. The <samp>-D</samp>, <samp>--dump-strings</samp>, and <samp>--dump-po-strings</samp>
13732 invocation options list the translatable strings found in a script
13733 (see <a href="#Locale-Translation">Locale Translation</a>).
13734
13735 </li><li> Bash implements the <code>!</code> keyword to negate the return value of
13736 a pipeline (see <a href="#Pipelines">Pipelines</a>).
13737 Very useful when an <code>if</code> statement needs to act only if a test fails.
13738 The Bash &lsquo;<samp>-o pipefail</samp>&rsquo; option to <code>set</code> will cause a pipeline to
13739 return a failure status if any command fails.
13740
13741 </li><li> Bash has the <code>time</code> reserved word and command timing (see <a href="#Pipelines">Pipelines</a>).
13742 The display of the timing statistics may be controlled with the
13743 <code>TIMEFORMAT</code> variable.
13744
13745 </li><li> Bash implements the <code>for (( <var>expr1</var> ; <var>expr2</var> ; <var>expr3</var> ))</code>
13746 arithmetic for command, similar to the C language (see <a href="#Looping-Constructs">Looping Constructs</a>).
13747
13748 </li><li> Bash includes the <code>select</code> compound command, which allows the
13749 generation of simple menus (see <a href="#Conditional-Constructs">Conditional Constructs</a>).
13750
13751 </li><li> Bash includes the <code>[[</code> compound command, which makes conditional
13752 testing part of the shell grammar (see <a href="#Conditional-Constructs">Conditional Constructs</a>), including
13753 optional regular expression matching.
13754
13755 </li><li> Bash provides optional case-insensitive matching for the <code>case</code> and
13756 <code>[[</code> constructs.
13757
13758 </li><li> Bash includes brace expansion (see <a href="#Brace-Expansion">Brace Expansion</a>) and tilde
13759 expansion (see <a href="#Tilde-Expansion">Tilde Expansion</a>).
13760
13761 </li><li> Bash implements command aliases and the <code>alias</code> and <code>unalias</code>
13762 builtins (see <a href="#Aliases">Aliases</a>).
13763
13764 </li><li> Bash provides shell arithmetic, the <code>((</code> compound command
13765 (see <a href="#Conditional-Constructs">Conditional Constructs</a>),
13766 and arithmetic expansion (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>).
13767
13768 </li><li> Variables present in the shell&rsquo;s initial environment are automatically
13769 exported to child processes. The Bourne shell does not normally do
13770 this unless the variables are explicitly marked using the <code>export</code>
13771 command.
13772
13773 </li><li> Bash supports the &lsquo;<samp>+=</samp>&rsquo; assignment operator, which appends to the value
13774 of the variable named on the left hand side.
13775
13776 </li><li> Bash includes the <small>POSIX</small> pattern removal &lsquo;<samp>%</samp>&rsquo;, &lsquo;<samp>#</samp>&rsquo;, &lsquo;<samp>%%</samp>&rsquo;
13777 and &lsquo;<samp>##</samp>&rsquo; expansions to remove leading or trailing substrings from
13778 variable values (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
13779
13780 </li><li> The expansion <code>${#xx}</code>, which returns the length of <code>${xx}</code>,
13781 is supported (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
13782
13783 </li><li> The expansion <code>${var:</code><var>offset</var><code>[:</code><var>length</var><code>]}</code>,
13784 which expands to the substring of <code>var</code>&rsquo;s value of length
13785 <var>length</var>, beginning at <var>offset</var>, is present
13786 (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
13787
13788 </li><li> The expansion
13789 <code>${var/[/]</code><var>pattern</var><code>[/</code><var>replacement</var><code>]}</code>,
13790 which matches <var>pattern</var> and replaces it with <var>replacement</var> in
13791 the value of <code>var</code>, is available (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
13792
13793 </li><li> The expansion <code>${!<var>prefix</var>*}</code> expansion, which expands to
13794 the names of all shell variables whose names begin with <var>prefix</var>,
13795 is available (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
13796
13797 </li><li> Bash has <var>indirect</var> variable expansion using <code>${!word}</code>
13798 (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
13799
13800 </li><li> Bash can expand positional parameters beyond <code>$9</code> using
13801 <code>${<var>num</var>}</code>.
13802
13803 </li><li> The <small>POSIX</small> <code>$()</code> form of command substitution
13804 is implemented (see <a href="#Command-Substitution">Command Substitution</a>),
13805 and preferred to the Bourne shell&rsquo;s <code>``</code> (which
13806 is also implemented for backwards compatibility).
13807
13808 </li><li> Bash has process substitution (see <a href="#Process-Substitution">Process Substitution</a>).
13809
13810 </li><li> Bash automatically assigns variables that provide information about the
13811 current user (<code>UID</code>, <code>EUID</code>, and <code>GROUPS</code>), the current host
13812 (<code>HOSTTYPE</code>, <code>OSTYPE</code>, <code>MACHTYPE</code>, and <code>HOSTNAME</code>),
13813 and the instance of Bash that is running (<code>BASH</code>,
13814 <code>BASH_VERSION</code>, and <code>BASH_VERSINFO</code>). See <a href="#Bash-Variables">Bash Variables</a>,
13815 for details.
13816
13817 </li><li> The <code>IFS</code> variable is used to split only the results of expansion,
13818 not all words (see <a href="#Word-Splitting">Word Splitting</a>).
13819 This closes a longstanding shell security hole.
13820
13821 </li><li> The filename expansion bracket expression code uses &lsquo;<samp>!</samp>&rsquo; and &lsquo;<samp>^</samp>&rsquo;
13822 to negate the set of characters between the brackets.
13823 The Bourne shell uses only &lsquo;<samp>!</samp>&rsquo;.
13824
13825 </li><li> Bash implements the full set of <small>POSIX</small> filename expansion operators,
13826 including <var>character classes</var>, <var>equivalence classes</var>, and
13827 <var>collating symbols</var> (see <a href="#Filename-Expansion">Filename Expansion</a>).
13828
13829 </li><li> Bash implements extended pattern matching features when the <code>extglob</code>
13830 shell option is enabled (see <a href="#Pattern-Matching">Pattern Matching</a>).
13831
13832 </li><li> It is possible to have a variable and a function with the same name;
13833 <code>sh</code> does not separate the two name spaces.
13834
13835 </li><li> Bash functions are permitted to have local variables using the
13836 <code>local</code> builtin, and thus useful recursive functions may be written
13837 (see <a href="#Bash-Builtins">Bash Builtins</a>).
13838
13839 </li><li> Variable assignments preceding commands affect only that command, even
13840 builtins and functions (see <a href="#Environment">Environment</a>).
13841 In <code>sh</code>, all variable assignments
13842 preceding commands are global unless the command is executed from the
13843 file system.
13844
13845 </li><li> Bash performs filename expansion on filenames specified as operands
13846 to input and output redirection operators (see <a href="#Redirections">Redirections</a>).
13847
13848 </li><li> Bash contains the &lsquo;<samp>&lt;&gt;</samp>&rsquo; redirection operator, allowing a file to be
13849 opened for both reading and writing, and the &lsquo;<samp>&amp;&gt;</samp>&rsquo; redirection
13850 operator, for directing standard output and standard error to the same
13851 file (see <a href="#Redirections">Redirections</a>).
13852
13853 </li><li> Bash includes the &lsquo;<samp>&lt;&lt;&lt;</samp>&rsquo; redirection operator, allowing a string to
13854 be used as the standard input to a command.
13855
13856 </li><li> Bash implements the &lsquo;<samp>[n]&lt;&amp;<var>word</var></samp>&rsquo; and &lsquo;<samp>[n]&gt;&amp;<var>word</var></samp>&rsquo;
13857 redirection operators, which move one file descriptor to another.
13858
13859 </li><li> Bash treats a number of filenames specially when they are
13860 used in redirection operators (see <a href="#Redirections">Redirections</a>).
13861
13862 </li><li> Bash can open network connections to arbitrary machines and services
13863 with the redirection operators (see <a href="#Redirections">Redirections</a>).
13864
13865 </li><li> The <code>noclobber</code> option is available to avoid overwriting existing
13866 files with output redirection (see <a href="#The-Set-Builtin">The Set Builtin</a>).
13867 The &lsquo;<samp>&gt;|</samp>&rsquo; redirection operator may be used to override <code>noclobber</code>.
13868
13869 </li><li> The Bash <code>cd</code> and <code>pwd</code> builtins (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>)
13870 each take <samp>-L</samp> and <samp>-P</samp> options to switch between logical and
13871 physical modes.
13872
13873 </li><li> Bash allows a function to override a builtin with the same name, and provides
13874 access to that builtin&rsquo;s functionality within the function via the
13875 <code>builtin</code> and <code>command</code> builtins (see <a href="#Bash-Builtins">Bash Builtins</a>).
13876
13877 </li><li> The <code>command</code> builtin allows selective disabling of functions
13878 when command lookup is performed (see <a href="#Bash-Builtins">Bash Builtins</a>).
13879
13880 </li><li> Individual builtins may be enabled or disabled using the <code>enable</code>
13881 builtin (see <a href="#Bash-Builtins">Bash Builtins</a>).
13882
13883 </li><li> The Bash <code>exec</code> builtin takes additional options that allow users
13884 to control the contents of the environment passed to the executed
13885 command, and what the zeroth argument to the command is to be
13886 (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
13887
13888 </li><li> Shell functions may be exported to children via the environment
13889 using <code>export -f</code> (see <a href="#Shell-Functions">Shell Functions</a>).
13890
13891 </li><li> The Bash <code>export</code>, <code>readonly</code>, and <code>declare</code> builtins can
13892 take a <samp>-f</samp> option to act on shell functions, a <samp>-p</samp> option to
13893 display variables with various attributes set in a format that can be
13894 used as shell input, a <samp>-n</samp> option to remove various variable
13895 attributes, and &lsquo;<samp>name=value</samp>&rsquo; arguments to set variable attributes
13896 and values simultaneously.
13897
13898 </li><li> The Bash <code>hash</code> builtin allows a name to be associated with
13899 an arbitrary filename, even when that filename cannot be found by
13900 searching the <code>$PATH</code>, using &lsquo;<samp>hash -p</samp>&rsquo;
13901 (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
13902
13903 </li><li> Bash includes a <code>help</code> builtin for quick reference to shell
13904 facilities (see <a href="#Bash-Builtins">Bash Builtins</a>).
13905
13906 </li><li> The <code>printf</code> builtin is available to display formatted output
13907 (see <a href="#Bash-Builtins">Bash Builtins</a>).
13908
13909 </li><li> The Bash <code>read</code> builtin (see <a href="#Bash-Builtins">Bash Builtins</a>)
13910 will read a line ending in &lsquo;<samp>\</samp>&rsquo; with
13911 the <samp>-r</samp> option, and will use the <code>REPLY</code> variable as a
13912 default if no non-option arguments are supplied.
13913 The Bash <code>read</code> builtin
13914 also accepts a prompt string with the <samp>-p</samp> option and will use
13915 Readline to obtain the line when given the <samp>-e</samp> option.
13916 The <code>read</code> builtin also has additional options to control input:
13917 the <samp>-s</samp> option will turn off echoing of input characters as
13918 they are read, the <samp>-t</samp> option will allow <code>read</code> to time out
13919 if input does not arrive within a specified number of seconds, the
13920 <samp>-n</samp> option will allow reading only a specified number of
13921 characters rather than a full line, and the <samp>-d</samp> option will read
13922 until a particular character rather than newline.
13923
13924 </li><li> The <code>return</code> builtin may be used to abort execution of scripts
13925 executed with the <code>.</code> or <code>source</code> builtins
13926 (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
13927
13928 </li><li> Bash includes the <code>shopt</code> builtin, for finer control of shell
13929 optional capabilities (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), and allows these options
13930 to be set and unset at shell invocation (see <a href="#Invoking-Bash">Invoking Bash</a>).
13931
13932 </li><li> Bash has much more optional behavior controllable with the <code>set</code>
13933 builtin (see <a href="#The-Set-Builtin">The Set Builtin</a>).
13934
13935 </li><li> The &lsquo;<samp>-x</samp>&rsquo; (<samp>xtrace</samp>) option displays commands other than
13936 simple commands when performing an execution trace
13937 (see <a href="#The-Set-Builtin">The Set Builtin</a>).
13938
13939 </li><li> The <code>test</code> builtin (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>)
13940 is slightly different, as it implements the <small>POSIX</small> algorithm,
13941 which specifies the behavior based on the number of arguments.
13942
13943 </li><li> Bash includes the <code>caller</code> builtin, which displays the context of
13944 any active subroutine call (a shell function or a script executed with
13945 the <code>.</code> or <code>source</code> builtins). This supports the bash
13946 debugger.
13947
13948 </li><li> The <code>trap</code> builtin (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>) allows a
13949 <code>DEBUG</code> pseudo-signal specification, similar to <code>EXIT</code>.
13950 Commands specified with a <code>DEBUG</code> trap are executed before every
13951 simple command, <code>for</code> command, <code>case</code> command,
13952 <code>select</code> command, every arithmetic <code>for</code> command, and before
13953 the first command executes in a shell function.
13954 The <code>DEBUG</code> trap is not inherited by shell functions unless the
13955 function has been given the <code>trace</code> attribute or the
13956 <code>functrace</code> option has been enabled using the <code>shopt</code> builtin.
13957 The <code>extdebug</code> shell option has additional effects on the
13958 <code>DEBUG</code> trap.
13959
13960 <p>The <code>trap</code> builtin (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>) allows an
13961 <code>ERR</code> pseudo-signal specification, similar to <code>EXIT</code> and <code>DEBUG</code>.
13962 Commands specified with an <code>ERR</code> trap are executed after a simple
13963 command fails, with a few exceptions.
13964 The <code>ERR</code> trap is not inherited by shell functions unless the
13965 <code>-o errtrace</code> option to the <code>set</code> builtin is enabled.
13966 </p>
13967 <p>The <code>trap</code> builtin (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>) allows a
13968 <code>RETURN</code> pseudo-signal specification, similar to
13969 <code>EXIT</code> and <code>DEBUG</code>.
13970 Commands specified with an <code>RETURN</code> trap are executed before
13971 execution resumes after a shell function or a shell script executed with
13972 <code>.</code> or <code>source</code> returns.
13973 The <code>RETURN</code> trap is not inherited by shell functions unless the
13974 function has been given the <code>trace</code> attribute or the
13975 <code>functrace</code> option has been enabled using the <code>shopt</code> builtin.
13976 </p>
13977 </li><li> The Bash <code>type</code> builtin is more extensive and gives more information
13978 about the names it finds (see <a href="#Bash-Builtins">Bash Builtins</a>).
13979
13980 </li><li> The Bash <code>umask</code> builtin permits a <samp>-p</samp> option to cause
13981 the output to be displayed in the form of a <code>umask</code> command
13982 that may be reused as input (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
13983
13984 </li><li> Bash implements a <code>csh</code>-like directory stack, and provides the
13985 <code>pushd</code>, <code>popd</code>, and <code>dirs</code> builtins to manipulate it
13986 (see <a href="#The-Directory-Stack">The Directory Stack</a>).
13987 Bash also makes the directory stack visible as the value of the
13988 <code>DIRSTACK</code> shell variable.
13989
13990 </li><li> Bash interprets special backslash-escaped characters in the prompt
13991 strings when interactive (see <a href="#Controlling-the-Prompt">Controlling the Prompt</a>).
13992
13993 </li><li> The Bash restricted mode is more useful (see <a href="#The-Restricted-Shell">The Restricted Shell</a>);
13994 the SVR4.2 shell restricted mode is too limited.
13995
13996 </li><li> The <code>disown</code> builtin can remove a job from the internal shell
13997 job table (see <a href="#Job-Control-Builtins">Job Control Builtins</a>) or suppress the sending
13998 of <code>SIGHUP</code> to a job when the shell exits as the result of a
13999 <code>SIGHUP</code>.
14000
14001 </li><li> Bash includes a number of features to support a separate debugger for
14002 shell scripts.
14003
14004 </li><li> The SVR4.2 shell has two privilege-related builtins
14005 (<code>mldmode</code> and <code>priv</code>) not present in Bash.
14006
14007 </li><li> Bash does not have the <code>stop</code> or <code>newgrp</code> builtins.
14008
14009 </li><li> Bash does not use the <code>SHACCT</code> variable or perform shell accounting.
14010
14011 </li><li> The SVR4.2 <code>sh</code> uses a <code>TIMEOUT</code> variable like Bash uses
14012 <code>TMOUT</code>.
14013
14014 </li></ul>
14015
14016 <p>More features unique to Bash may be found in <a href="#Bash-Features">Bash Features</a>.
14017 </p>
14018
14019 <a name="Implementation-Differences-From-The-SVR4_002e2-Shell"></a>
14020 <h3 class="appendixsec">B.1 Implementation Differences From The SVR4.2 Shell</h3>
14021
14022 <p>Since Bash is a completely new implementation, it does not suffer from
14023 many of the limitations of the SVR4.2 shell. For instance:
14024 </p>
14025 <ul>
14026 <li> Bash does not fork a subshell when redirecting into or out of
14027 a shell control structure such as an <code>if</code> or <code>while</code>
14028 statement.
14029
14030 </li><li> Bash does not allow unbalanced quotes. The SVR4.2 shell will silently
14031 insert a needed closing quote at <code>EOF</code> under certain circumstances.
14032 This can be the cause of some hard-to-find errors.
14033
14034 </li><li> The SVR4.2 shell uses a baroque memory management scheme based on
14035 trapping <code>SIGSEGV</code>. If the shell is started from a process with
14036 <code>SIGSEGV</code> blocked (e.g., by using the <code>system()</code> C library
14037 function call), it misbehaves badly.
14038
14039 </li><li> In a questionable attempt at security, the SVR4.2 shell,
14040 when invoked without the <samp>-p</samp> option, will alter its real
14041 and effective <small>UID</small> and <small>GID</small> if they are less than some
14042 magic threshold value, commonly 100.
14043 This can lead to unexpected results.
14044
14045 </li><li> The SVR4.2 shell does not allow users to trap <code>SIGSEGV</code>,
14046 <code>SIGALRM</code>, or <code>SIGCHLD</code>.
14047
14048 </li><li> The SVR4.2 shell does not allow the <code>IFS</code>, <code>MAILCHECK</code>,
14049 <code>PATH</code>, <code>PS1</code>, or <code>PS2</code> variables to be unset.
14050
14051 </li><li> The SVR4.2 shell treats &lsquo;<samp>^</samp>&rsquo; as the undocumented equivalent of
14052 &lsquo;<samp>|</samp>&rsquo;.
14053
14054 </li><li> Bash allows multiple option arguments when it is invoked (<code>-x -v</code>);
14055 the SVR4.2 shell allows only one option argument (<code>-xv</code>). In
14056 fact, some versions of the shell dump core if the second argument begins
14057 with a &lsquo;<samp>-</samp>&rsquo;.
14058
14059 </li><li> The SVR4.2 shell exits a script if any builtin fails; Bash exits
14060 a script only if one of the <small>POSIX</small> special builtins fails, and
14061 only for certain failures, as enumerated in the <small>POSIX</small> standard.
14062
14063 </li><li> The SVR4.2 shell behaves differently when invoked as <code>jsh</code>
14064 (it turns on job control).
14065 </li></ul>
14066
14067 <hr>
14068 <a name="GNU-Free-Documentation-License"></a>
14069 <div class="header">
14070 <p>
14071 Next: <a href="#Indexes" accesskey="n" rel="next">Indexes</a>, Previous: <a href="#Major-Differences-From-The-Bourne-Shell" accesskey="p" rel="prev">Major Differences From The Bourne Shell</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
14072 </div>
14073 <a name="GNU-Free-Documentation-License-1"></a>
14074 <h2 class="appendix">Appendix C GNU Free Documentation License</h2>
14075
14076 <div align="center">Version 1.3, 3 November 2008
14077 </div>
14078
14079 <div class="display">
14080 <pre class="display">Copyright &copy; 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
14081 <a href="http://fsf.org/">http://fsf.org/</a>
14082
14083 Everyone is permitted to copy and distribute verbatim copies
14084 of this license document, but changing it is not allowed.
14085 </pre></div>
14086
14087 <ol start="0">
14088 <li> PREAMBLE
14089
14090 <p>The purpose of this License is to make a manual, textbook, or other
14091 functional and useful document <em>free</em> in the sense of freedom: to
14092 assure everyone the effective freedom to copy and redistribute it,
14093 with or without modifying it, either commercially or noncommercially.
14094 Secondarily, this License preserves for the author and publisher a way
14095 to get credit for their work, while not being considered responsible
14096 for modifications made by others.
14097 </p>
14098 <p>This License is a kind of &ldquo;copyleft&rdquo;, which means that derivative
14099 works of the document must themselves be free in the same sense. It
14100 complements the GNU General Public License, which is a copyleft
14101 license designed for free software.
14102 </p>
14103 <p>We have designed this License in order to use it for manuals for free
14104 software, because free software needs free documentation: a free
14105 program should come with manuals providing the same freedoms that the
14106 software does. But this License is not limited to software manuals;
14107 it can be used for any textual work, regardless of subject matter or
14108 whether it is published as a printed book. We recommend this License
14109 principally for works whose purpose is instruction or reference.
14110 </p>
14111 </li><li> APPLICABILITY AND DEFINITIONS
14112
14113 <p>This License applies to any manual or other work, in any medium, that
14114 contains a notice placed by the copyright holder saying it can be
14115 distributed under the terms of this License. Such a notice grants a
14116 world-wide, royalty-free license, unlimited in duration, to use that
14117 work under the conditions stated herein. The &ldquo;Document&rdquo;, below,
14118 refers to any such manual or work. Any member of the public is a
14119 licensee, and is addressed as &ldquo;you&rdquo;. You accept the license if you
14120 copy, modify or distribute the work in a way requiring permission
14121 under copyright law.
14122 </p>
14123 <p>A &ldquo;Modified Version&rdquo; of the Document means any work containing the
14124 Document or a portion of it, either copied verbatim, or with
14125 modifications and/or translated into another language.
14126 </p>
14127 <p>A &ldquo;Secondary Section&rdquo; is a named appendix or a front-matter section
14128 of the Document that deals exclusively with the relationship of the
14129 publishers or authors of the Document to the Document&rsquo;s overall
14130 subject (or to related matters) and contains nothing that could fall
14131 directly within that overall subject. (Thus, if the Document is in
14132 part a textbook of mathematics, a Secondary Section may not explain
14133 any mathematics.) The relationship could be a matter of historical
14134 connection with the subject or with related matters, or of legal,
14135 commercial, philosophical, ethical or political position regarding
14136 them.
14137 </p>
14138 <p>The &ldquo;Invariant Sections&rdquo; are certain Secondary Sections whose titles
14139 are designated, as being those of Invariant Sections, in the notice
14140 that says that the Document is released under this License. If a
14141 section does not fit the above definition of Secondary then it is not
14142 allowed to be designated as Invariant. The Document may contain zero
14143 Invariant Sections. If the Document does not identify any Invariant
14144 Sections then there are none.
14145 </p>
14146 <p>The &ldquo;Cover Texts&rdquo; are certain short passages of text that are listed,
14147 as Front-Cover Texts or Back-Cover Texts, in the notice that says that
14148 the Document is released under this License. A Front-Cover Text may
14149 be at most 5 words, and a Back-Cover Text may be at most 25 words.
14150 </p>
14151 <p>A &ldquo;Transparent&rdquo; copy of the Document means a machine-readable copy,
14152 represented in a format whose specification is available to the
14153 general public, that is suitable for revising the document
14154 straightforwardly with generic text editors or (for images composed of
14155 pixels) generic paint programs or (for drawings) some widely available
14156 drawing editor, and that is suitable for input to text formatters or
14157 for automatic translation to a variety of formats suitable for input
14158 to text formatters. A copy made in an otherwise Transparent file
14159 format whose markup, or absence of markup, has been arranged to thwart
14160 or discourage subsequent modification by readers is not Transparent.
14161 An image format is not Transparent if used for any substantial amount
14162 of text. A copy that is not &ldquo;Transparent&rdquo; is called &ldquo;Opaque&rdquo;.
14163 </p>
14164 <p>Examples of suitable formats for Transparent copies include plain
14165 <small>ASCII</small> without markup, Texinfo input format, LaTeX input
14166 format, <acronym>SGML</acronym> or <acronym>XML</acronym> using a publicly available
14167 <acronym>DTD</acronym>, and standard-conforming simple <acronym>HTML</acronym>,
14168 PostScript or <acronym>PDF</acronym> designed for human modification. Examples
14169 of transparent image formats include <acronym>PNG</acronym>, <acronym>XCF</acronym> and
14170 <acronym>JPG</acronym>. Opaque formats include proprietary formats that can be
14171 read and edited only by proprietary word processors, <acronym>SGML</acronym> or
14172 <acronym>XML</acronym> for which the <acronym>DTD</acronym> and/or processing tools are
14173 not generally available, and the machine-generated <acronym>HTML</acronym>,
14174 PostScript or <acronym>PDF</acronym> produced by some word processors for
14175 output purposes only.
14176 </p>
14177 <p>The &ldquo;Title Page&rdquo; means, for a printed book, the title page itself,
14178 plus such following pages as are needed to hold, legibly, the material
14179 this License requires to appear in the title page. For works in
14180 formats which do not have any title page as such, &ldquo;Title Page&rdquo; means
14181 the text near the most prominent appearance of the work&rsquo;s title,
14182 preceding the beginning of the body of the text.
14183 </p>
14184 <p>The &ldquo;publisher&rdquo; means any person or entity that distributes copies
14185 of the Document to the public.
14186 </p>
14187 <p>A section &ldquo;Entitled XYZ&rdquo; means a named subunit of the Document whose
14188 title either is precisely XYZ or contains XYZ in parentheses following
14189 text that translates XYZ in another language. (Here XYZ stands for a
14190 specific section name mentioned below, such as &ldquo;Acknowledgements&rdquo;,
14191 &ldquo;Dedications&rdquo;, &ldquo;Endorsements&rdquo;, or &ldquo;History&rdquo;.) To &ldquo;Preserve the Title&rdquo;
14192 of such a section when you modify the Document means that it remains a
14193 section &ldquo;Entitled XYZ&rdquo; according to this definition.
14194 </p>
14195 <p>The Document may include Warranty Disclaimers next to the notice which
14196 states that this License applies to the Document. These Warranty
14197 Disclaimers are considered to be included by reference in this
14198 License, but only as regards disclaiming warranties: any other
14199 implication that these Warranty Disclaimers may have is void and has
14200 no effect on the meaning of this License.
14201 </p>
14202 </li><li> VERBATIM COPYING
14203
14204 <p>You may copy and distribute the Document in any medium, either
14205 commercially or noncommercially, provided that this License, the
14206 copyright notices, and the license notice saying this License applies
14207 to the Document are reproduced in all copies, and that you add no other
14208 conditions whatsoever to those of this License. You may not use
14209 technical measures to obstruct or control the reading or further
14210 copying of the copies you make or distribute. However, you may accept
14211 compensation in exchange for copies. If you distribute a large enough
14212 number of copies you must also follow the conditions in section 3.
14213 </p>
14214 <p>You may also lend copies, under the same conditions stated above, and
14215 you may publicly display copies.
14216 </p>
14217 </li><li> COPYING IN QUANTITY
14218
14219 <p>If you publish printed copies (or copies in media that commonly have
14220 printed covers) of the Document, numbering more than 100, and the
14221 Document&rsquo;s license notice requires Cover Texts, you must enclose the
14222 copies in covers that carry, clearly and legibly, all these Cover
14223 Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
14224 the back cover. Both covers must also clearly and legibly identify
14225 you as the publisher of these copies. The front cover must present
14226 the full title with all words of the title equally prominent and
14227 visible. You may add other material on the covers in addition.
14228 Copying with changes limited to the covers, as long as they preserve
14229 the title of the Document and satisfy these conditions, can be treated
14230 as verbatim copying in other respects.
14231 </p>
14232 <p>If the required texts for either cover are too voluminous to fit
14233 legibly, you should put the first ones listed (as many as fit
14234 reasonably) on the actual cover, and continue the rest onto adjacent
14235 pages.
14236 </p>
14237 <p>If you publish or distribute Opaque copies of the Document numbering
14238 more than 100, you must either include a machine-readable Transparent
14239 copy along with each Opaque copy, or state in or with each Opaque copy
14240 a computer-network location from which the general network-using
14241 public has access to download using public-standard network protocols
14242 a complete Transparent copy of the Document, free of added material.
14243 If you use the latter option, you must take reasonably prudent steps,
14244 when you begin distribution of Opaque copies in quantity, to ensure
14245 that this Transparent copy will remain thus accessible at the stated
14246 location until at least one year after the last time you distribute an
14247 Opaque copy (directly or through your agents or retailers) of that
14248 edition to the public.
14249 </p>
14250 <p>It is requested, but not required, that you contact the authors of the
14251 Document well before redistributing any large number of copies, to give
14252 them a chance to provide you with an updated version of the Document.
14253 </p>
14254 </li><li> MODIFICATIONS
14255
14256 <p>You may copy and distribute a Modified Version of the Document under
14257 the conditions of sections 2 and 3 above, provided that you release
14258 the Modified Version under precisely this License, with the Modified
14259 Version filling the role of the Document, thus licensing distribution
14260 and modification of the Modified Version to whoever possesses a copy
14261 of it. In addition, you must do these things in the Modified Version:
14262 </p>
14263 <ol type="A" start="1">
14264 <li> Use in the Title Page (and on the covers, if any) a title distinct
14265 from that of the Document, and from those of previous versions
14266 (which should, if there were any, be listed in the History section
14267 of the Document). You may use the same title as a previous version
14268 if the original publisher of that version gives permission.
14269
14270 </li><li> List on the Title Page, as authors, one or more persons or entities
14271 responsible for authorship of the modifications in the Modified
14272 Version, together with at least five of the principal authors of the
14273 Document (all of its principal authors, if it has fewer than five),
14274 unless they release you from this requirement.
14275
14276 </li><li> State on the Title page the name of the publisher of the
14277 Modified Version, as the publisher.
14278
14279 </li><li> Preserve all the copyright notices of the Document.
14280
14281 </li><li> Add an appropriate copyright notice for your modifications
14282 adjacent to the other copyright notices.
14283
14284 </li><li> Include, immediately after the copyright notices, a license notice
14285 giving the public permission to use the Modified Version under the
14286 terms of this License, in the form shown in the Addendum below.
14287
14288 </li><li> Preserve in that license notice the full lists of Invariant Sections
14289 and required Cover Texts given in the Document&rsquo;s license notice.
14290
14291 </li><li> Include an unaltered copy of this License.
14292
14293 </li><li> Preserve the section Entitled &ldquo;History&rdquo;, Preserve its Title, and add
14294 to it an item stating at least the title, year, new authors, and
14295 publisher of the Modified Version as given on the Title Page. If
14296 there is no section Entitled &ldquo;History&rdquo; in the Document, create one
14297 stating the title, year, authors, and publisher of the Document as
14298 given on its Title Page, then add an item describing the Modified
14299 Version as stated in the previous sentence.
14300
14301 </li><li> Preserve the network location, if any, given in the Document for
14302 public access to a Transparent copy of the Document, and likewise
14303 the network locations given in the Document for previous versions
14304 it was based on. These may be placed in the &ldquo;History&rdquo; section.
14305 You may omit a network location for a work that was published at
14306 least four years before the Document itself, or if the original
14307 publisher of the version it refers to gives permission.
14308
14309 </li><li> For any section Entitled &ldquo;Acknowledgements&rdquo; or &ldquo;Dedications&rdquo;, Preserve
14310 the Title of the section, and preserve in the section all the
14311 substance and tone of each of the contributor acknowledgements and/or
14312 dedications given therein.
14313
14314 </li><li> Preserve all the Invariant Sections of the Document,
14315 unaltered in their text and in their titles. Section numbers
14316 or the equivalent are not considered part of the section titles.
14317
14318 </li><li> Delete any section Entitled &ldquo;Endorsements&rdquo;. Such a section
14319 may not be included in the Modified Version.
14320
14321 </li><li> Do not retitle any existing section to be Entitled &ldquo;Endorsements&rdquo; or
14322 to conflict in title with any Invariant Section.
14323
14324 </li><li> Preserve any Warranty Disclaimers.
14325 </li></ol>
14326
14327 <p>If the Modified Version includes new front-matter sections or
14328 appendices that qualify as Secondary Sections and contain no material
14329 copied from the Document, you may at your option designate some or all
14330 of these sections as invariant. To do this, add their titles to the
14331 list of Invariant Sections in the Modified Version&rsquo;s license notice.
14332 These titles must be distinct from any other section titles.
14333 </p>
14334 <p>You may add a section Entitled &ldquo;Endorsements&rdquo;, provided it contains
14335 nothing but endorsements of your Modified Version by various
14336 parties&mdash;for example, statements of peer review or that the text has
14337 been approved by an organization as the authoritative definition of a
14338 standard.
14339 </p>
14340 <p>You may add a passage of up to five words as a Front-Cover Text, and a
14341 passage of up to 25 words as a Back-Cover Text, to the end of the list
14342 of Cover Texts in the Modified Version. Only one passage of
14343 Front-Cover Text and one of Back-Cover Text may be added by (or
14344 through arrangements made by) any one entity. If the Document already
14345 includes a cover text for the same cover, previously added by you or
14346 by arrangement made by the same entity you are acting on behalf of,
14347 you may not add another; but you may replace the old one, on explicit
14348 permission from the previous publisher that added the old one.
14349 </p>
14350 <p>The author(s) and publisher(s) of the Document do not by this License
14351 give permission to use their names for publicity for or to assert or
14352 imply endorsement of any Modified Version.
14353 </p>
14354 </li><li> COMBINING DOCUMENTS
14355
14356 <p>You may combine the Document with other documents released under this
14357 License, under the terms defined in section 4 above for modified
14358 versions, provided that you include in the combination all of the
14359 Invariant Sections of all of the original documents, unmodified, and
14360 list them all as Invariant Sections of your combined work in its
14361 license notice, and that you preserve all their Warranty Disclaimers.
14362 </p>
14363 <p>The combined work need only contain one copy of this License, and
14364 multiple identical Invariant Sections may be replaced with a single
14365 copy. If there are multiple Invariant Sections with the same name but
14366 different contents, make the title of each such section unique by
14367 adding at the end of it, in parentheses, the name of the original
14368 author or publisher of that section if known, or else a unique number.
14369 Make the same adjustment to the section titles in the list of
14370 Invariant Sections in the license notice of the combined work.
14371 </p>
14372 <p>In the combination, you must combine any sections Entitled &ldquo;History&rdquo;
14373 in the various original documents, forming one section Entitled
14374 &ldquo;History&rdquo;; likewise combine any sections Entitled &ldquo;Acknowledgements&rdquo;,
14375 and any sections Entitled &ldquo;Dedications&rdquo;. You must delete all
14376 sections Entitled &ldquo;Endorsements.&rdquo;
14377 </p>
14378 </li><li> COLLECTIONS OF DOCUMENTS
14379
14380 <p>You may make a collection consisting of the Document and other documents
14381 released under this License, and replace the individual copies of this
14382 License in the various documents with a single copy that is included in
14383 the collection, provided that you follow the rules of this License for
14384 verbatim copying of each of the documents in all other respects.
14385 </p>
14386 <p>You may extract a single document from such a collection, and distribute
14387 it individually under this License, provided you insert a copy of this
14388 License into the extracted document, and follow this License in all
14389 other respects regarding verbatim copying of that document.
14390 </p>
14391 </li><li> AGGREGATION WITH INDEPENDENT WORKS
14392
14393 <p>A compilation of the Document or its derivatives with other separate
14394 and independent documents or works, in or on a volume of a storage or
14395 distribution medium, is called an &ldquo;aggregate&rdquo; if the copyright
14396 resulting from the compilation is not used to limit the legal rights
14397 of the compilation&rsquo;s users beyond what the individual works permit.
14398 When the Document is included in an aggregate, this License does not
14399 apply to the other works in the aggregate which are not themselves
14400 derivative works of the Document.
14401 </p>
14402 <p>If the Cover Text requirement of section 3 is applicable to these
14403 copies of the Document, then if the Document is less than one half of
14404 the entire aggregate, the Document&rsquo;s Cover Texts may be placed on
14405 covers that bracket the Document within the aggregate, or the
14406 electronic equivalent of covers if the Document is in electronic form.
14407 Otherwise they must appear on printed covers that bracket the whole
14408 aggregate.
14409 </p>
14410 </li><li> TRANSLATION
14411
14412 <p>Translation is considered a kind of modification, so you may
14413 distribute translations of the Document under the terms of section 4.
14414 Replacing Invariant Sections with translations requires special
14415 permission from their copyright holders, but you may include
14416 translations of some or all Invariant Sections in addition to the
14417 original versions of these Invariant Sections. You may include a
14418 translation of this License, and all the license notices in the
14419 Document, and any Warranty Disclaimers, provided that you also include
14420 the original English version of this License and the original versions
14421 of those notices and disclaimers. In case of a disagreement between
14422 the translation and the original version of this License or a notice
14423 or disclaimer, the original version will prevail.
14424 </p>
14425 <p>If a section in the Document is Entitled &ldquo;Acknowledgements&rdquo;,
14426 &ldquo;Dedications&rdquo;, or &ldquo;History&rdquo;, the requirement (section 4) to Preserve
14427 its Title (section 1) will typically require changing the actual
14428 title.
14429 </p>
14430 </li><li> TERMINATION
14431
14432 <p>You may not copy, modify, sublicense, or distribute the Document
14433 except as expressly provided under this License. Any attempt
14434 otherwise to copy, modify, sublicense, or distribute it is void, and
14435 will automatically terminate your rights under this License.
14436 </p>
14437 <p>However, if you cease all violation of this License, then your license
14438 from a particular copyright holder is reinstated (a) provisionally,
14439 unless and until the copyright holder explicitly and finally
14440 terminates your license, and (b) permanently, if the copyright holder
14441 fails to notify you of the violation by some reasonable means prior to
14442 60 days after the cessation.
14443 </p>
14444 <p>Moreover, your license from a particular copyright holder is
14445 reinstated permanently if the copyright holder notifies you of the
14446 violation by some reasonable means, this is the first time you have
14447 received notice of violation of this License (for any work) from that
14448 copyright holder, and you cure the violation prior to 30 days after
14449 your receipt of the notice.
14450 </p>
14451 <p>Termination of your rights under this section does not terminate the
14452 licenses of parties who have received copies or rights from you under
14453 this License. If your rights have been terminated and not permanently
14454 reinstated, receipt of a copy of some or all of the same material does
14455 not give you any rights to use it.
14456 </p>
14457 </li><li> FUTURE REVISIONS OF THIS LICENSE
14458
14459 <p>The Free Software Foundation may publish new, revised versions
14460 of the GNU Free Documentation License from time to time. Such new
14461 versions will be similar in spirit to the present version, but may
14462 differ in detail to address new problems or concerns. See
14463 <a href="http://www.gnu.org/copyleft/">http://www.gnu.org/copyleft/</a>.
14464 </p>
14465 <p>Each version of the License is given a distinguishing version number.
14466 If the Document specifies that a particular numbered version of this
14467 License &ldquo;or any later version&rdquo; applies to it, you have the option of
14468 following the terms and conditions either of that specified version or
14469 of any later version that has been published (not as a draft) by the
14470 Free Software Foundation. If the Document does not specify a version
14471 number of this License, you may choose any version ever published (not
14472 as a draft) by the Free Software Foundation. If the Document
14473 specifies that a proxy can decide which future versions of this
14474 License can be used, that proxy&rsquo;s public statement of acceptance of a
14475 version permanently authorizes you to choose that version for the
14476 Document.
14477 </p>
14478 </li><li> RELICENSING
14479
14480 <p>&ldquo;Massive Multiauthor Collaboration Site&rdquo; (or &ldquo;MMC Site&rdquo;) means any
14481 World Wide Web server that publishes copyrightable works and also
14482 provides prominent facilities for anybody to edit those works. A
14483 public wiki that anybody can edit is an example of such a server. A
14484 &ldquo;Massive Multiauthor Collaboration&rdquo; (or &ldquo;MMC&rdquo;) contained in the
14485 site means any set of copyrightable works thus published on the MMC
14486 site.
14487 </p>
14488 <p>&ldquo;CC-BY-SA&rdquo; means the Creative Commons Attribution-Share Alike 3.0
14489 license published by Creative Commons Corporation, a not-for-profit
14490 corporation with a principal place of business in San Francisco,
14491 California, as well as future copyleft versions of that license
14492 published by that same organization.
14493 </p>
14494 <p>&ldquo;Incorporate&rdquo; means to publish or republish a Document, in whole or
14495 in part, as part of another Document.
14496 </p>
14497 <p>An MMC is &ldquo;eligible for relicensing&rdquo; if it is licensed under this
14498 License, and if all works that were first published under this License
14499 somewhere other than this MMC, and subsequently incorporated in whole
14500 or in part into the MMC, (1) had no cover texts or invariant sections,
14501 and (2) were thus incorporated prior to November 1, 2008.
14502 </p>
14503 <p>The operator of an MMC Site may republish an MMC contained in the site
14504 under CC-BY-SA on the same site at any time before August 1, 2009,
14505 provided the MMC is eligible for relicensing.
14506 </p>
14507 </li></ol>
14508
14509 <a name="ADDENDUM_003a-How-to-use-this-License-for-your-documents"></a>
14510 <h3 class="heading">ADDENDUM: How to use this License for your documents</h3>
14511
14512 <p>To use this License in a document you have written, include a copy of
14513 the License in the document and put the following copyright and
14514 license notices just after the title page:
14515 </p>
14516 <div class="smallexample">
14517 <pre class="smallexample"> Copyright (C) <var>year</var> <var>your name</var>.
14518 Permission is granted to copy, distribute and/or modify this document
14519 under the terms of the GNU Free Documentation License, Version 1.3
14520 or any later version published by the Free Software Foundation;
14521 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
14522 Texts. A copy of the license is included in the section entitled ``GNU
14523 Free Documentation License''.
14524 </pre></div>
14525
14526 <p>If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
14527 replace the &ldquo;with&hellip;Texts.&rdquo; line with this:
14528 </p>
14529 <div class="smallexample">
14530 <pre class="smallexample"> with the Invariant Sections being <var>list their titles</var>, with
14531 the Front-Cover Texts being <var>list</var>, and with the Back-Cover Texts
14532 being <var>list</var>.
14533 </pre></div>
14534
14535 <p>If you have Invariant Sections without Cover Texts, or some other
14536 combination of the three, merge those two alternatives to suit the
14537 situation.
14538 </p>
14539 <p>If your document contains nontrivial examples of program code, we
14540 recommend releasing these examples in parallel under your choice of
14541 free software license, such as the GNU General Public License,
14542 to permit their use in free software.
14543 </p>
14544
14545
14546 <hr>
14547 <a name="Indexes"></a>
14548 <div class="header">
14549 <p>
14550 Previous: <a href="#GNU-Free-Documentation-License" accesskey="p" rel="prev">GNU Free Documentation License</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
14551 </div>
14552 <a name="Indexes-1"></a>
14553 <h2 class="appendix">Appendix D Indexes</h2>
14554
14555 <table class="menu" border="0" cellspacing="0">
14556 <tr><td align="left" valign="top">&bull; <a href="#Builtin-Index" accesskey="1">Builtin Index</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Index of Bash builtin commands.
14557 </td></tr>
14558 <tr><td align="left" valign="top">&bull; <a href="#Reserved-Word-Index" accesskey="2">Reserved Word Index</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Index of Bash reserved words.
14559 </td></tr>
14560 <tr><td align="left" valign="top">&bull; <a href="#Variable-Index" accesskey="3">Variable Index</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Quick reference helps you find the
14561 variable you want.
14562 </td></tr>
14563 <tr><td align="left" valign="top">&bull; <a href="#Function-Index" accesskey="4">Function Index</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Index of bindable Readline functions.
14564 </td></tr>
14565 <tr><td align="left" valign="top">&bull; <a href="#Concept-Index" accesskey="5">Concept Index</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">General index for concepts described in
14566 this manual.
14567 </td></tr>
14568 </table>
14569
14570 <hr>
14571 <a name="Builtin-Index"></a>
14572 <div class="header">
14573 <p>
14574 Next: <a href="#Reserved-Word-Index" accesskey="n" rel="next">Reserved Word Index</a>, Up: <a href="#Indexes" accesskey="u" rel="up">Indexes</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
14575 </div>
14576 <a name="Index-of-Shell-Builtin-Commands"></a>
14577 <h3 class="appendixsec">D.1 Index of Shell Builtin Commands</h3>
14578 <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Builtin-Index_bt_symbol-1"><b>.</b></a>
14579 &nbsp;
14580 <a class="summary-letter" href="#Builtin-Index_bt_symbol-2"><b>:</b></a>
14581 &nbsp;
14582 <a class="summary-letter" href="#Builtin-Index_bt_symbol-3"><b>[</b></a>
14583 &nbsp;
14584 <br>
14585 <a class="summary-letter" href="#Builtin-Index_bt_letter-A"><b>A</b></a>
14586 &nbsp;
14587 <a class="summary-letter" href="#Builtin-Index_bt_letter-B"><b>B</b></a>
14588 &nbsp;
14589 <a class="summary-letter" href="#Builtin-Index_bt_letter-C"><b>C</b></a>
14590 &nbsp;
14591 <a class="summary-letter" href="#Builtin-Index_bt_letter-D"><b>D</b></a>
14592 &nbsp;
14593 <a class="summary-letter" href="#Builtin-Index_bt_letter-E"><b>E</b></a>
14594 &nbsp;
14595 <a class="summary-letter" href="#Builtin-Index_bt_letter-F"><b>F</b></a>
14596 &nbsp;
14597 <a class="summary-letter" href="#Builtin-Index_bt_letter-G"><b>G</b></a>
14598 &nbsp;
14599 <a class="summary-letter" href="#Builtin-Index_bt_letter-H"><b>H</b></a>
14600 &nbsp;
14601 <a class="summary-letter" href="#Builtin-Index_bt_letter-J"><b>J</b></a>
14602 &nbsp;
14603 <a class="summary-letter" href="#Builtin-Index_bt_letter-K"><b>K</b></a>
14604 &nbsp;
14605 <a class="summary-letter" href="#Builtin-Index_bt_letter-L"><b>L</b></a>
14606 &nbsp;
14607 <a class="summary-letter" href="#Builtin-Index_bt_letter-M"><b>M</b></a>
14608 &nbsp;
14609 <a class="summary-letter" href="#Builtin-Index_bt_letter-P"><b>P</b></a>
14610 &nbsp;
14611 <a class="summary-letter" href="#Builtin-Index_bt_letter-R"><b>R</b></a>
14612 &nbsp;
14613 <a class="summary-letter" href="#Builtin-Index_bt_letter-S"><b>S</b></a>
14614 &nbsp;
14615 <a class="summary-letter" href="#Builtin-Index_bt_letter-T"><b>T</b></a>
14616 &nbsp;
14617 <a class="summary-letter" href="#Builtin-Index_bt_letter-U"><b>U</b></a>
14618 &nbsp;
14619 <a class="summary-letter" href="#Builtin-Index_bt_letter-W"><b>W</b></a>
14620 &nbsp;
14621 </td></tr></table>
14622 <table class="index-bt" border="0">
14623 <tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
14624 <tr><td colspan="4"> <hr></td></tr>
14625 <tr><th><a name="Builtin-Index_bt_symbol-1">.</a></th><td></td><td></td></tr>
14626 <tr><td></td><td valign="top"><a href="#index-_002e"><code>.</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14627 <tr><td colspan="4"> <hr></td></tr>
14628 <tr><th><a name="Builtin-Index_bt_symbol-2">:</a></th><td></td><td></td></tr>
14629 <tr><td></td><td valign="top"><a href="#index-_003a"><code>:</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14630 <tr><td colspan="4"> <hr></td></tr>
14631 <tr><th><a name="Builtin-Index_bt_symbol-3">[</a></th><td></td><td></td></tr>
14632 <tr><td></td><td valign="top"><a href="#index-_005b"><code>[</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14633 <tr><td colspan="4"> <hr></td></tr>
14634 <tr><th><a name="Builtin-Index_bt_letter-A">A</a></th><td></td><td></td></tr>
14635 <tr><td></td><td valign="top"><a href="#index-alias"><code>alias</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14636 <tr><td colspan="4"> <hr></td></tr>
14637 <tr><th><a name="Builtin-Index_bt_letter-B">B</a></th><td></td><td></td></tr>
14638 <tr><td></td><td valign="top"><a href="#index-bg"><code>bg</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Job-Control-Builtins">Job Control Builtins</a></td></tr>
14639 <tr><td></td><td valign="top"><a href="#index-bind"><code>bind</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14640 <tr><td></td><td valign="top"><a href="#index-break"><code>break</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14641 <tr><td></td><td valign="top"><a href="#index-builtin"><code>builtin</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14642 <tr><td colspan="4"> <hr></td></tr>
14643 <tr><th><a name="Builtin-Index_bt_letter-C">C</a></th><td></td><td></td></tr>
14644 <tr><td></td><td valign="top"><a href="#index-caller"><code>caller</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14645 <tr><td></td><td valign="top"><a href="#index-cd"><code>cd</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14646 <tr><td></td><td valign="top"><a href="#index-command"><code>command</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14647 <tr><td></td><td valign="top"><a href="#index-compgen"><code>compgen</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Programmable-Completion-Builtins">Programmable Completion Builtins</a></td></tr>
14648 <tr><td></td><td valign="top"><a href="#index-complete"><code>complete</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Programmable-Completion-Builtins">Programmable Completion Builtins</a></td></tr>
14649 <tr><td></td><td valign="top"><a href="#index-compopt"><code>compopt</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Programmable-Completion-Builtins">Programmable Completion Builtins</a></td></tr>
14650 <tr><td></td><td valign="top"><a href="#index-continue"><code>continue</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14651 <tr><td colspan="4"> <hr></td></tr>
14652 <tr><th><a name="Builtin-Index_bt_letter-D">D</a></th><td></td><td></td></tr>
14653 <tr><td></td><td valign="top"><a href="#index-declare"><code>declare</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14654 <tr><td></td><td valign="top"><a href="#index-dirs"><code>dirs</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Directory-Stack-Builtins">Directory Stack Builtins</a></td></tr>
14655 <tr><td></td><td valign="top"><a href="#index-disown"><code>disown</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Job-Control-Builtins">Job Control Builtins</a></td></tr>
14656 <tr><td colspan="4"> <hr></td></tr>
14657 <tr><th><a name="Builtin-Index_bt_letter-E">E</a></th><td></td><td></td></tr>
14658 <tr><td></td><td valign="top"><a href="#index-echo"><code>echo</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14659 <tr><td></td><td valign="top"><a href="#index-enable"><code>enable</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14660 <tr><td></td><td valign="top"><a href="#index-eval"><code>eval</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14661 <tr><td></td><td valign="top"><a href="#index-exec"><code>exec</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14662 <tr><td></td><td valign="top"><a href="#index-exit"><code>exit</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14663 <tr><td></td><td valign="top"><a href="#index-export"><code>export</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14664 <tr><td colspan="4"> <hr></td></tr>
14665 <tr><th><a name="Builtin-Index_bt_letter-F">F</a></th><td></td><td></td></tr>
14666 <tr><td></td><td valign="top"><a href="#index-fc"><code>fc</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-History-Builtins">Bash History Builtins</a></td></tr>
14667 <tr><td></td><td valign="top"><a href="#index-fg"><code>fg</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Job-Control-Builtins">Job Control Builtins</a></td></tr>
14668 <tr><td colspan="4"> <hr></td></tr>
14669 <tr><th><a name="Builtin-Index_bt_letter-G">G</a></th><td></td><td></td></tr>
14670 <tr><td></td><td valign="top"><a href="#index-getopts"><code>getopts</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14671 <tr><td colspan="4"> <hr></td></tr>
14672 <tr><th><a name="Builtin-Index_bt_letter-H">H</a></th><td></td><td></td></tr>
14673 <tr><td></td><td valign="top"><a href="#index-hash"><code>hash</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14674 <tr><td></td><td valign="top"><a href="#index-help"><code>help</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14675 <tr><td></td><td valign="top"><a href="#index-history"><code>history</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-History-Builtins">Bash History Builtins</a></td></tr>
14676 <tr><td colspan="4"> <hr></td></tr>
14677 <tr><th><a name="Builtin-Index_bt_letter-J">J</a></th><td></td><td></td></tr>
14678 <tr><td></td><td valign="top"><a href="#index-jobs"><code>jobs</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Job-Control-Builtins">Job Control Builtins</a></td></tr>
14679 <tr><td colspan="4"> <hr></td></tr>
14680 <tr><th><a name="Builtin-Index_bt_letter-K">K</a></th><td></td><td></td></tr>
14681 <tr><td></td><td valign="top"><a href="#index-kill"><code>kill</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Job-Control-Builtins">Job Control Builtins</a></td></tr>
14682 <tr><td colspan="4"> <hr></td></tr>
14683 <tr><th><a name="Builtin-Index_bt_letter-L">L</a></th><td></td><td></td></tr>
14684 <tr><td></td><td valign="top"><a href="#index-let"><code>let</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14685 <tr><td></td><td valign="top"><a href="#index-local"><code>local</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14686 <tr><td></td><td valign="top"><a href="#index-logout"><code>logout</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14687 <tr><td colspan="4"> <hr></td></tr>
14688 <tr><th><a name="Builtin-Index_bt_letter-M">M</a></th><td></td><td></td></tr>
14689 <tr><td></td><td valign="top"><a href="#index-mapfile"><code>mapfile</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14690 <tr><td colspan="4"> <hr></td></tr>
14691 <tr><th><a name="Builtin-Index_bt_letter-P">P</a></th><td></td><td></td></tr>
14692 <tr><td></td><td valign="top"><a href="#index-popd"><code>popd</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Directory-Stack-Builtins">Directory Stack Builtins</a></td></tr>
14693 <tr><td></td><td valign="top"><a href="#index-printf"><code>printf</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14694 <tr><td></td><td valign="top"><a href="#index-pushd"><code>pushd</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Directory-Stack-Builtins">Directory Stack Builtins</a></td></tr>
14695 <tr><td></td><td valign="top"><a href="#index-pwd"><code>pwd</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14696 <tr><td colspan="4"> <hr></td></tr>
14697 <tr><th><a name="Builtin-Index_bt_letter-R">R</a></th><td></td><td></td></tr>
14698 <tr><td></td><td valign="top"><a href="#index-read"><code>read</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14699 <tr><td></td><td valign="top"><a href="#index-readarray"><code>readarray</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14700 <tr><td></td><td valign="top"><a href="#index-readonly"><code>readonly</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14701 <tr><td></td><td valign="top"><a href="#index-return"><code>return</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14702 <tr><td colspan="4"> <hr></td></tr>
14703 <tr><th><a name="Builtin-Index_bt_letter-S">S</a></th><td></td><td></td></tr>
14704 <tr><td></td><td valign="top"><a href="#index-set"><code>set</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#The-Set-Builtin">The Set Builtin</a></td></tr>
14705 <tr><td></td><td valign="top"><a href="#index-shift"><code>shift</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14706 <tr><td></td><td valign="top"><a href="#index-shopt"><code>shopt</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#The-Shopt-Builtin">The Shopt Builtin</a></td></tr>
14707 <tr><td></td><td valign="top"><a href="#index-source"><code>source</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14708 <tr><td></td><td valign="top"><a href="#index-suspend"><code>suspend</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Job-Control-Builtins">Job Control Builtins</a></td></tr>
14709 <tr><td colspan="4"> <hr></td></tr>
14710 <tr><th><a name="Builtin-Index_bt_letter-T">T</a></th><td></td><td></td></tr>
14711 <tr><td></td><td valign="top"><a href="#index-test"><code>test</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14712 <tr><td></td><td valign="top"><a href="#index-times"><code>times</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14713 <tr><td></td><td valign="top"><a href="#index-trap"><code>trap</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14714 <tr><td></td><td valign="top"><a href="#index-type"><code>type</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14715 <tr><td></td><td valign="top"><a href="#index-typeset"><code>typeset</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14716 <tr><td colspan="4"> <hr></td></tr>
14717 <tr><th><a name="Builtin-Index_bt_letter-U">U</a></th><td></td><td></td></tr>
14718 <tr><td></td><td valign="top"><a href="#index-ulimit"><code>ulimit</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14719 <tr><td></td><td valign="top"><a href="#index-umask"><code>umask</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14720 <tr><td></td><td valign="top"><a href="#index-unalias"><code>unalias</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Builtins">Bash Builtins</a></td></tr>
14721 <tr><td></td><td valign="top"><a href="#index-unset"><code>unset</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a></td></tr>
14722 <tr><td colspan="4"> <hr></td></tr>
14723 <tr><th><a name="Builtin-Index_bt_letter-W">W</a></th><td></td><td></td></tr>
14724 <tr><td></td><td valign="top"><a href="#index-wait"><code>wait</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Job-Control-Builtins">Job Control Builtins</a></td></tr>
14725 <tr><td colspan="4"> <hr></td></tr>
14726 </table>
14727 <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Builtin-Index_bt_symbol-1"><b>.</b></a>
14728 &nbsp;
14729 <a class="summary-letter" href="#Builtin-Index_bt_symbol-2"><b>:</b></a>
14730 &nbsp;
14731 <a class="summary-letter" href="#Builtin-Index_bt_symbol-3"><b>[</b></a>
14732 &nbsp;
14733 <br>
14734 <a class="summary-letter" href="#Builtin-Index_bt_letter-A"><b>A</b></a>
14735 &nbsp;
14736 <a class="summary-letter" href="#Builtin-Index_bt_letter-B"><b>B</b></a>
14737 &nbsp;
14738 <a class="summary-letter" href="#Builtin-Index_bt_letter-C"><b>C</b></a>
14739 &nbsp;
14740 <a class="summary-letter" href="#Builtin-Index_bt_letter-D"><b>D</b></a>
14741 &nbsp;
14742 <a class="summary-letter" href="#Builtin-Index_bt_letter-E"><b>E</b></a>
14743 &nbsp;
14744 <a class="summary-letter" href="#Builtin-Index_bt_letter-F"><b>F</b></a>
14745 &nbsp;
14746 <a class="summary-letter" href="#Builtin-Index_bt_letter-G"><b>G</b></a>
14747 &nbsp;
14748 <a class="summary-letter" href="#Builtin-Index_bt_letter-H"><b>H</b></a>
14749 &nbsp;
14750 <a class="summary-letter" href="#Builtin-Index_bt_letter-J"><b>J</b></a>
14751 &nbsp;
14752 <a class="summary-letter" href="#Builtin-Index_bt_letter-K"><b>K</b></a>
14753 &nbsp;
14754 <a class="summary-letter" href="#Builtin-Index_bt_letter-L"><b>L</b></a>
14755 &nbsp;
14756 <a class="summary-letter" href="#Builtin-Index_bt_letter-M"><b>M</b></a>
14757 &nbsp;
14758 <a class="summary-letter" href="#Builtin-Index_bt_letter-P"><b>P</b></a>
14759 &nbsp;
14760 <a class="summary-letter" href="#Builtin-Index_bt_letter-R"><b>R</b></a>
14761 &nbsp;
14762 <a class="summary-letter" href="#Builtin-Index_bt_letter-S"><b>S</b></a>
14763 &nbsp;
14764 <a class="summary-letter" href="#Builtin-Index_bt_letter-T"><b>T</b></a>
14765 &nbsp;
14766 <a class="summary-letter" href="#Builtin-Index_bt_letter-U"><b>U</b></a>
14767 &nbsp;
14768 <a class="summary-letter" href="#Builtin-Index_bt_letter-W"><b>W</b></a>
14769 &nbsp;
14770 </td></tr></table>
14771
14772 <hr>
14773 <a name="Reserved-Word-Index"></a>
14774 <div class="header">
14775 <p>
14776 Next: <a href="#Variable-Index" accesskey="n" rel="next">Variable Index</a>, Previous: <a href="#Builtin-Index" accesskey="p" rel="prev">Builtin Index</a>, Up: <a href="#Indexes" accesskey="u" rel="up">Indexes</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
14777 </div>
14778 <a name="Index-of-Shell-Reserved-Words"></a>
14779 <h3 class="appendixsec">D.2 Index of Shell Reserved Words</h3>
14780 <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-1"><b>!</b></a>
14781 &nbsp;
14782 <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-2"><b>[</b></a>
14783 &nbsp;
14784 <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-3"><b>]</b></a>
14785 &nbsp;
14786 <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-4"><b>{</b></a>
14787 &nbsp;
14788 <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-5"><b>}</b></a>
14789 &nbsp;
14790 <br>
14791 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-C"><b>C</b></a>
14792 &nbsp;
14793 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-D"><b>D</b></a>
14794 &nbsp;
14795 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-E"><b>E</b></a>
14796 &nbsp;
14797 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-F"><b>F</b></a>
14798 &nbsp;
14799 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-I"><b>I</b></a>
14800 &nbsp;
14801 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-S"><b>S</b></a>
14802 &nbsp;
14803 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-T"><b>T</b></a>
14804 &nbsp;
14805 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-U"><b>U</b></a>
14806 &nbsp;
14807 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-W"><b>W</b></a>
14808 &nbsp;
14809 </td></tr></table>
14810 <table class="index-rw" border="0">
14811 <tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
14812 <tr><td colspan="4"> <hr></td></tr>
14813 <tr><th><a name="Reserved-Word-Index_rw_symbol-1">!</a></th><td></td><td></td></tr>
14814 <tr><td></td><td valign="top"><a href="#index-_0021"><code>!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pipelines">Pipelines</a></td></tr>
14815 <tr><td colspan="4"> <hr></td></tr>
14816 <tr><th><a name="Reserved-Word-Index_rw_symbol-2">[</a></th><td></td><td></td></tr>
14817 <tr><td></td><td valign="top"><a href="#index-_005b_005b"><code>[[</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Conditional-Constructs">Conditional Constructs</a></td></tr>
14818 <tr><td colspan="4"> <hr></td></tr>
14819 <tr><th><a name="Reserved-Word-Index_rw_symbol-3">]</a></th><td></td><td></td></tr>
14820 <tr><td></td><td valign="top"><a href="#index-_005d_005d"><code>]]</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Conditional-Constructs">Conditional Constructs</a></td></tr>
14821 <tr><td colspan="4"> <hr></td></tr>
14822 <tr><th><a name="Reserved-Word-Index_rw_symbol-4">{</a></th><td></td><td></td></tr>
14823 <tr><td></td><td valign="top"><a href="#index-_007b"><code>{</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-Grouping">Command Grouping</a></td></tr>
14824 <tr><td colspan="4"> <hr></td></tr>
14825 <tr><th><a name="Reserved-Word-Index_rw_symbol-5">}</a></th><td></td><td></td></tr>
14826 <tr><td></td><td valign="top"><a href="#index-_007d"><code>}</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-Grouping">Command Grouping</a></td></tr>
14827 <tr><td colspan="4"> <hr></td></tr>
14828 <tr><th><a name="Reserved-Word-Index_rw_letter-C">C</a></th><td></td><td></td></tr>
14829 <tr><td></td><td valign="top"><a href="#index-case"><code>case</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Conditional-Constructs">Conditional Constructs</a></td></tr>
14830 <tr><td colspan="4"> <hr></td></tr>
14831 <tr><th><a name="Reserved-Word-Index_rw_letter-D">D</a></th><td></td><td></td></tr>
14832 <tr><td></td><td valign="top"><a href="#index-do"><code>do</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Looping-Constructs">Looping Constructs</a></td></tr>
14833 <tr><td></td><td valign="top"><a href="#index-done"><code>done</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Looping-Constructs">Looping Constructs</a></td></tr>
14834 <tr><td colspan="4"> <hr></td></tr>
14835 <tr><th><a name="Reserved-Word-Index_rw_letter-E">E</a></th><td></td><td></td></tr>
14836 <tr><td></td><td valign="top"><a href="#index-elif"><code>elif</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Conditional-Constructs">Conditional Constructs</a></td></tr>
14837 <tr><td></td><td valign="top"><a href="#index-else"><code>else</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Conditional-Constructs">Conditional Constructs</a></td></tr>
14838 <tr><td></td><td valign="top"><a href="#index-esac"><code>esac</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Conditional-Constructs">Conditional Constructs</a></td></tr>
14839 <tr><td colspan="4"> <hr></td></tr>
14840 <tr><th><a name="Reserved-Word-Index_rw_letter-F">F</a></th><td></td><td></td></tr>
14841 <tr><td></td><td valign="top"><a href="#index-fi"><code>fi</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Conditional-Constructs">Conditional Constructs</a></td></tr>
14842 <tr><td></td><td valign="top"><a href="#index-for"><code>for</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Looping-Constructs">Looping Constructs</a></td></tr>
14843 <tr><td></td><td valign="top"><a href="#index-function"><code>function</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Functions">Shell Functions</a></td></tr>
14844 <tr><td colspan="4"> <hr></td></tr>
14845 <tr><th><a name="Reserved-Word-Index_rw_letter-I">I</a></th><td></td><td></td></tr>
14846 <tr><td></td><td valign="top"><a href="#index-if"><code>if</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Conditional-Constructs">Conditional Constructs</a></td></tr>
14847 <tr><td></td><td valign="top"><a href="#index-in"><code>in</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Conditional-Constructs">Conditional Constructs</a></td></tr>
14848 <tr><td colspan="4"> <hr></td></tr>
14849 <tr><th><a name="Reserved-Word-Index_rw_letter-S">S</a></th><td></td><td></td></tr>
14850 <tr><td></td><td valign="top"><a href="#index-select"><code>select</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Conditional-Constructs">Conditional Constructs</a></td></tr>
14851 <tr><td colspan="4"> <hr></td></tr>
14852 <tr><th><a name="Reserved-Word-Index_rw_letter-T">T</a></th><td></td><td></td></tr>
14853 <tr><td></td><td valign="top"><a href="#index-then"><code>then</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Conditional-Constructs">Conditional Constructs</a></td></tr>
14854 <tr><td></td><td valign="top"><a href="#index-time"><code>time</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pipelines">Pipelines</a></td></tr>
14855 <tr><td colspan="4"> <hr></td></tr>
14856 <tr><th><a name="Reserved-Word-Index_rw_letter-U">U</a></th><td></td><td></td></tr>
14857 <tr><td></td><td valign="top"><a href="#index-until"><code>until</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Looping-Constructs">Looping Constructs</a></td></tr>
14858 <tr><td colspan="4"> <hr></td></tr>
14859 <tr><th><a name="Reserved-Word-Index_rw_letter-W">W</a></th><td></td><td></td></tr>
14860 <tr><td></td><td valign="top"><a href="#index-while"><code>while</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Looping-Constructs">Looping Constructs</a></td></tr>
14861 <tr><td colspan="4"> <hr></td></tr>
14862 </table>
14863 <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-1"><b>!</b></a>
14864 &nbsp;
14865 <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-2"><b>[</b></a>
14866 &nbsp;
14867 <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-3"><b>]</b></a>
14868 &nbsp;
14869 <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-4"><b>{</b></a>
14870 &nbsp;
14871 <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-5"><b>}</b></a>
14872 &nbsp;
14873 <br>
14874 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-C"><b>C</b></a>
14875 &nbsp;
14876 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-D"><b>D</b></a>
14877 &nbsp;
14878 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-E"><b>E</b></a>
14879 &nbsp;
14880 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-F"><b>F</b></a>
14881 &nbsp;
14882 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-I"><b>I</b></a>
14883 &nbsp;
14884 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-S"><b>S</b></a>
14885 &nbsp;
14886 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-T"><b>T</b></a>
14887 &nbsp;
14888 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-U"><b>U</b></a>
14889 &nbsp;
14890 <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-W"><b>W</b></a>
14891 &nbsp;
14892 </td></tr></table>
14893
14894 <hr>
14895 <a name="Variable-Index"></a>
14896 <div class="header">
14897 <p>
14898 Next: <a href="#Function-Index" accesskey="n" rel="next">Function Index</a>, Previous: <a href="#Reserved-Word-Index" accesskey="p" rel="prev">Reserved Word Index</a>, Up: <a href="#Indexes" accesskey="u" rel="up">Indexes</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
14899 </div>
14900 <a name="Parameter-and-Variable-Index"></a>
14901 <h3 class="appendixsec">D.3 Parameter and Variable Index</h3>
14902 <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Variable-Index_vr_symbol-1"><b>!</b></a>
14903 &nbsp;
14904 <a class="summary-letter" href="#Variable-Index_vr_symbol-2"><b>#</b></a>
14905 &nbsp;
14906 <a class="summary-letter" href="#Variable-Index_vr_symbol-3"><b>$</b></a>
14907 &nbsp;
14908 <a class="summary-letter" href="#Variable-Index_vr_symbol-4"><b>*</b></a>
14909 &nbsp;
14910 <a class="summary-letter" href="#Variable-Index_vr_symbol-5"><b>-</b></a>
14911 &nbsp;
14912 <a class="summary-letter" href="#Variable-Index_vr_symbol-6"><b>0</b></a>
14913 &nbsp;
14914 <a class="summary-letter" href="#Variable-Index_vr_symbol-7"><b>?</b></a>
14915 &nbsp;
14916 <a class="summary-letter" href="#Variable-Index_vr_symbol-8"><b>@</b></a>
14917 &nbsp;
14918 <a class="summary-letter" href="#Variable-Index_vr_symbol-9"><b>_</b></a>
14919 &nbsp;
14920 <br>
14921 <a class="summary-letter" href="#Variable-Index_vr_letter-A"><b>A</b></a>
14922 &nbsp;
14923 <a class="summary-letter" href="#Variable-Index_vr_letter-B"><b>B</b></a>
14924 &nbsp;
14925 <a class="summary-letter" href="#Variable-Index_vr_letter-C"><b>C</b></a>
14926 &nbsp;
14927 <a class="summary-letter" href="#Variable-Index_vr_letter-D"><b>D</b></a>
14928 &nbsp;
14929 <a class="summary-letter" href="#Variable-Index_vr_letter-E"><b>E</b></a>
14930 &nbsp;
14931 <a class="summary-letter" href="#Variable-Index_vr_letter-F"><b>F</b></a>
14932 &nbsp;
14933 <a class="summary-letter" href="#Variable-Index_vr_letter-G"><b>G</b></a>
14934 &nbsp;
14935 <a class="summary-letter" href="#Variable-Index_vr_letter-H"><b>H</b></a>
14936 &nbsp;
14937 <a class="summary-letter" href="#Variable-Index_vr_letter-I"><b>I</b></a>
14938 &nbsp;
14939 <a class="summary-letter" href="#Variable-Index_vr_letter-K"><b>K</b></a>
14940 &nbsp;
14941 <a class="summary-letter" href="#Variable-Index_vr_letter-L"><b>L</b></a>
14942 &nbsp;
14943 <a class="summary-letter" href="#Variable-Index_vr_letter-M"><b>M</b></a>
14944 &nbsp;
14945 <a class="summary-letter" href="#Variable-Index_vr_letter-O"><b>O</b></a>
14946 &nbsp;
14947 <a class="summary-letter" href="#Variable-Index_vr_letter-P"><b>P</b></a>
14948 &nbsp;
14949 <a class="summary-letter" href="#Variable-Index_vr_letter-R"><b>R</b></a>
14950 &nbsp;
14951 <a class="summary-letter" href="#Variable-Index_vr_letter-S"><b>S</b></a>
14952 &nbsp;
14953 <a class="summary-letter" href="#Variable-Index_vr_letter-T"><b>T</b></a>
14954 &nbsp;
14955 <a class="summary-letter" href="#Variable-Index_vr_letter-U"><b>U</b></a>
14956 &nbsp;
14957 <a class="summary-letter" href="#Variable-Index_vr_letter-V"><b>V</b></a>
14958 &nbsp;
14959 </td></tr></table>
14960 <table class="index-vr" border="0">
14961 <tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
14962 <tr><td colspan="4"> <hr></td></tr>
14963 <tr><th><a name="Variable-Index_vr_symbol-1">!</a></th><td></td><td></td></tr>
14964 <tr><td></td><td valign="top"><a href="#index-_0021-1"><code>!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14965 <tr><td colspan="4"> <hr></td></tr>
14966 <tr><th><a name="Variable-Index_vr_symbol-2">#</a></th><td></td><td></td></tr>
14967 <tr><td></td><td valign="top"><a href="#index-_0023"><code>#</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14968 <tr><td colspan="4"> <hr></td></tr>
14969 <tr><th><a name="Variable-Index_vr_symbol-3">$</a></th><td></td><td></td></tr>
14970 <tr><td></td><td valign="top"><a href="#index-_0024"><code>$</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14971 <tr><td></td><td valign="top"><a href="#index-_0024_0021"><code>$!</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14972 <tr><td></td><td valign="top"><a href="#index-_0024_0023"><code>$#</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14973 <tr><td></td><td valign="top"><a href="#index-_0024_0024"><code>$$</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14974 <tr><td></td><td valign="top"><a href="#index-_0024_002a"><code>$*</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14975 <tr><td></td><td valign="top"><a href="#index-_0024_002d"><code>$-</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14976 <tr><td></td><td valign="top"><a href="#index-_00240"><code>$0</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14977 <tr><td></td><td valign="top"><a href="#index-_0024_003f"><code>$?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14978 <tr><td></td><td valign="top"><a href="#index-_0024_0040"><code>$@</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14979 <tr><td></td><td valign="top"><a href="#index-_0024_005f"><code>$_</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14980 <tr><td colspan="4"> <hr></td></tr>
14981 <tr><th><a name="Variable-Index_vr_symbol-4">*</a></th><td></td><td></td></tr>
14982 <tr><td></td><td valign="top"><a href="#index-_002a"><code>*</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14983 <tr><td colspan="4"> <hr></td></tr>
14984 <tr><th><a name="Variable-Index_vr_symbol-5">-</a></th><td></td><td></td></tr>
14985 <tr><td></td><td valign="top"><a href="#index-_002d"><code>-</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14986 <tr><td colspan="4"> <hr></td></tr>
14987 <tr><th><a name="Variable-Index_vr_symbol-6">0</a></th><td></td><td></td></tr>
14988 <tr><td></td><td valign="top"><a href="#index-0"><code>0</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14989 <tr><td colspan="4"> <hr></td></tr>
14990 <tr><th><a name="Variable-Index_vr_symbol-7">?</a></th><td></td><td></td></tr>
14991 <tr><td></td><td valign="top"><a href="#index-_003f"><code>?</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14992 <tr><td colspan="4"> <hr></td></tr>
14993 <tr><th><a name="Variable-Index_vr_symbol-8">@</a></th><td></td><td></td></tr>
14994 <tr><td></td><td valign="top"><a href="#index-_0040"><code>@</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14995 <tr><td colspan="4"> <hr></td></tr>
14996 <tr><th><a name="Variable-Index_vr_symbol-9">_</a></th><td></td><td></td></tr>
14997 <tr><td></td><td valign="top"><a href="#index-_005f"><code>_</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
14998 <tr><td colspan="4"> <hr></td></tr>
14999 <tr><th><a name="Variable-Index_vr_letter-A">A</a></th><td></td><td></td></tr>
15000 <tr><td></td><td valign="top"><a href="#index-auto_005fresume"><code>auto_resume</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Job-Control-Variables">Job Control Variables</a></td></tr>
15001 <tr><td colspan="4"> <hr></td></tr>
15002 <tr><th><a name="Variable-Index_vr_letter-B">B</a></th><td></td><td></td></tr>
15003 <tr><td></td><td valign="top"><a href="#index-BASH"><code>BASH</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15004 <tr><td></td><td valign="top"><a href="#index-BASHOPTS"><code>BASHOPTS</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15005 <tr><td></td><td valign="top"><a href="#index-BASHPID"><code>BASHPID</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15006 <tr><td></td><td valign="top"><a href="#index-BASH_005fALIASES"><code>BASH_ALIASES</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15007 <tr><td></td><td valign="top"><a href="#index-BASH_005fARGC"><code>BASH_ARGC</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15008 <tr><td></td><td valign="top"><a href="#index-BASH_005fARGV"><code>BASH_ARGV</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15009 <tr><td></td><td valign="top"><a href="#index-BASH_005fARGV0"><code>BASH_ARGV0</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15010 <tr><td></td><td valign="top"><a href="#index-BASH_005fCMDS"><code>BASH_CMDS</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15011 <tr><td></td><td valign="top"><a href="#index-BASH_005fCOMMAND"><code>BASH_COMMAND</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15012 <tr><td></td><td valign="top"><a href="#index-BASH_005fCOMPAT"><code>BASH_COMPAT</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15013 <tr><td></td><td valign="top"><a href="#index-BASH_005fENV"><code>BASH_ENV</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15014 <tr><td></td><td valign="top"><a href="#index-BASH_005fEXECUTION_005fSTRING"><code>BASH_EXECUTION_STRING</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15015 <tr><td></td><td valign="top"><a href="#index-BASH_005fLINENO"><code>BASH_LINENO</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15016 <tr><td></td><td valign="top"><a href="#index-BASH_005fLOADABLES_005fPATH"><code>BASH_LOADABLES_PATH</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15017 <tr><td></td><td valign="top"><a href="#index-BASH_005fREMATCH"><code>BASH_REMATCH</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15018 <tr><td></td><td valign="top"><a href="#index-BASH_005fSOURCE"><code>BASH_SOURCE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15019 <tr><td></td><td valign="top"><a href="#index-BASH_005fSUBSHELL"><code>BASH_SUBSHELL</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15020 <tr><td></td><td valign="top"><a href="#index-BASH_005fVERSINFO"><code>BASH_VERSINFO</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15021 <tr><td></td><td valign="top"><a href="#index-BASH_005fVERSION"><code>BASH_VERSION</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15022 <tr><td></td><td valign="top"><a href="#index-BASH_005fXTRACEFD"><code>BASH_XTRACEFD</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15023 <tr><td></td><td valign="top"><a href="#index-bell_002dstyle"><code>bell-style</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15024 <tr><td></td><td valign="top"><a href="#index-bind_002dtty_002dspecial_002dchars"><code>bind-tty-special-chars</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15025 <tr><td></td><td valign="top"><a href="#index-blink_002dmatching_002dparen"><code>blink-matching-paren</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15026 <tr><td colspan="4"> <hr></td></tr>
15027 <tr><th><a name="Variable-Index_vr_letter-C">C</a></th><td></td><td></td></tr>
15028 <tr><td></td><td valign="top"><a href="#index-CDPATH"><code>CDPATH</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Variables">Bourne Shell Variables</a></td></tr>
15029 <tr><td></td><td valign="top"><a href="#index-CHILD_005fMAX"><code>CHILD_MAX</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15030 <tr><td></td><td valign="top"><a href="#index-colored_002dcompletion_002dprefix"><code>colored-completion-prefix</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15031 <tr><td></td><td valign="top"><a href="#index-colored_002dstats"><code>colored-stats</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15032 <tr><td></td><td valign="top"><a href="#index-COLUMNS"><code>COLUMNS</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15033 <tr><td></td><td valign="top"><a href="#index-comment_002dbegin"><code>comment-begin</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15034 <tr><td></td><td valign="top"><a href="#index-completion_002ddisplay_002dwidth"><code>completion-display-width</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15035 <tr><td></td><td valign="top"><a href="#index-completion_002dignore_002dcase"><code>completion-ignore-case</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15036 <tr><td></td><td valign="top"><a href="#index-completion_002dmap_002dcase"><code>completion-map-case</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15037 <tr><td></td><td valign="top"><a href="#index-completion_002dprefix_002ddisplay_002dlength"><code>completion-prefix-display-length</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15038 <tr><td></td><td valign="top"><a href="#index-completion_002dquery_002ditems"><code>completion-query-items</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15039 <tr><td></td><td valign="top"><a href="#index-COMPREPLY"><code>COMPREPLY</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15040 <tr><td></td><td valign="top"><a href="#index-COMP_005fCWORD"><code>COMP_CWORD</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15041 <tr><td></td><td valign="top"><a href="#index-COMP_005fKEY"><code>COMP_KEY</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15042 <tr><td></td><td valign="top"><a href="#index-COMP_005fLINE"><code>COMP_LINE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15043 <tr><td></td><td valign="top"><a href="#index-COMP_005fPOINT"><code>COMP_POINT</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15044 <tr><td></td><td valign="top"><a href="#index-COMP_005fTYPE"><code>COMP_TYPE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15045 <tr><td></td><td valign="top"><a href="#index-COMP_005fWORDBREAKS"><code>COMP_WORDBREAKS</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15046 <tr><td></td><td valign="top"><a href="#index-COMP_005fWORDS"><code>COMP_WORDS</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15047 <tr><td></td><td valign="top"><a href="#index-convert_002dmeta"><code>convert-meta</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15048 <tr><td></td><td valign="top"><a href="#index-COPROC"><code>COPROC</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15049 <tr><td colspan="4"> <hr></td></tr>
15050 <tr><th><a name="Variable-Index_vr_letter-D">D</a></th><td></td><td></td></tr>
15051 <tr><td></td><td valign="top"><a href="#index-DIRSTACK"><code>DIRSTACK</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15052 <tr><td></td><td valign="top"><a href="#index-disable_002dcompletion"><code>disable-completion</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15053 <tr><td colspan="4"> <hr></td></tr>
15054 <tr><th><a name="Variable-Index_vr_letter-E">E</a></th><td></td><td></td></tr>
15055 <tr><td></td><td valign="top"><a href="#index-echo_002dcontrol_002dcharacters"><code>echo-control-characters</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15056 <tr><td></td><td valign="top"><a href="#index-editing_002dmode"><code>editing-mode</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15057 <tr><td></td><td valign="top"><a href="#index-EMACS"><code>EMACS</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15058 <tr><td></td><td valign="top"><a href="#index-emacs_002dmode_002dstring"><code>emacs-mode-string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15059 <tr><td></td><td valign="top"><a href="#index-enable_002dbracketed_002dpaste"><code>enable-bracketed-paste</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15060 <tr><td></td><td valign="top"><a href="#index-enable_002dkeypad"><code>enable-keypad</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15061 <tr><td></td><td valign="top"><a href="#index-ENV"><code>ENV</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15062 <tr><td></td><td valign="top"><a href="#index-EPOCHREALTIME"><code>EPOCHREALTIME</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15063 <tr><td></td><td valign="top"><a href="#index-EPOCHSECONDS"><code>EPOCHSECONDS</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15064 <tr><td></td><td valign="top"><a href="#index-EUID"><code>EUID</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15065 <tr><td></td><td valign="top"><a href="#index-EXECIGNORE"><code>EXECIGNORE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15066 <tr><td></td><td valign="top"><a href="#index-expand_002dtilde"><code>expand-tilde</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15067 <tr><td colspan="4"> <hr></td></tr>
15068 <tr><th><a name="Variable-Index_vr_letter-F">F</a></th><td></td><td></td></tr>
15069 <tr><td></td><td valign="top"><a href="#index-FCEDIT"><code>FCEDIT</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15070 <tr><td></td><td valign="top"><a href="#index-FIGNORE"><code>FIGNORE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15071 <tr><td></td><td valign="top"><a href="#index-FUNCNAME"><code>FUNCNAME</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15072 <tr><td></td><td valign="top"><a href="#index-FUNCNEST"><code>FUNCNEST</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15073 <tr><td colspan="4"> <hr></td></tr>
15074 <tr><th><a name="Variable-Index_vr_letter-G">G</a></th><td></td><td></td></tr>
15075 <tr><td></td><td valign="top"><a href="#index-GLOBIGNORE"><code>GLOBIGNORE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15076 <tr><td></td><td valign="top"><a href="#index-GROUPS"><code>GROUPS</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15077 <tr><td colspan="4"> <hr></td></tr>
15078 <tr><th><a name="Variable-Index_vr_letter-H">H</a></th><td></td><td></td></tr>
15079 <tr><td></td><td valign="top"><a href="#index-histchars"><code>histchars</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15080 <tr><td></td><td valign="top"><a href="#index-HISTCMD"><code>HISTCMD</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15081 <tr><td></td><td valign="top"><a href="#index-HISTCONTROL"><code>HISTCONTROL</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15082 <tr><td></td><td valign="top"><a href="#index-HISTFILE"><code>HISTFILE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15083 <tr><td></td><td valign="top"><a href="#index-HISTFILESIZE"><code>HISTFILESIZE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15084 <tr><td></td><td valign="top"><a href="#index-HISTIGNORE"><code>HISTIGNORE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15085 <tr><td></td><td valign="top"><a href="#index-history_002dpreserve_002dpoint"><code>history-preserve-point</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15086 <tr><td></td><td valign="top"><a href="#index-history_002dsize"><code>history-size</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15087 <tr><td></td><td valign="top"><a href="#index-HISTSIZE"><code>HISTSIZE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15088 <tr><td></td><td valign="top"><a href="#index-HISTTIMEFORMAT"><code>HISTTIMEFORMAT</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15089 <tr><td></td><td valign="top"><a href="#index-HOME"><code>HOME</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Variables">Bourne Shell Variables</a></td></tr>
15090 <tr><td></td><td valign="top"><a href="#index-horizontal_002dscroll_002dmode"><code>horizontal-scroll-mode</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15091 <tr><td></td><td valign="top"><a href="#index-HOSTFILE"><code>HOSTFILE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15092 <tr><td></td><td valign="top"><a href="#index-HOSTNAME"><code>HOSTNAME</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15093 <tr><td></td><td valign="top"><a href="#index-HOSTTYPE"><code>HOSTTYPE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15094 <tr><td colspan="4"> <hr></td></tr>
15095 <tr><th><a name="Variable-Index_vr_letter-I">I</a></th><td></td><td></td></tr>
15096 <tr><td></td><td valign="top"><a href="#index-IFS"><code>IFS</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Variables">Bourne Shell Variables</a></td></tr>
15097 <tr><td></td><td valign="top"><a href="#index-IGNOREEOF"><code>IGNOREEOF</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15098 <tr><td></td><td valign="top"><a href="#index-input_002dmeta"><code>input-meta</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15099 <tr><td></td><td valign="top"><a href="#index-INPUTRC"><code>INPUTRC</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15100 <tr><td></td><td valign="top"><a href="#index-INSIDE_005fEMACS"><code>INSIDE_EMACS</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15101 <tr><td></td><td valign="top"><a href="#index-isearch_002dterminators"><code>isearch-terminators</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15102 <tr><td colspan="4"> <hr></td></tr>
15103 <tr><th><a name="Variable-Index_vr_letter-K">K</a></th><td></td><td></td></tr>
15104 <tr><td></td><td valign="top"><a href="#index-keymap"><code>keymap</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15105 <tr><td colspan="4"> <hr></td></tr>
15106 <tr><th><a name="Variable-Index_vr_letter-L">L</a></th><td></td><td></td></tr>
15107 <tr><td></td><td valign="top"><a href="#index-LANG"><code>LANG</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15108 <tr><td></td><td valign="top"><a href="#index-LC_005fALL"><code>LC_ALL</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15109 <tr><td></td><td valign="top"><a href="#index-LC_005fCOLLATE"><code>LC_COLLATE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15110 <tr><td></td><td valign="top"><a href="#index-LC_005fCTYPE"><code>LC_CTYPE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15111 <tr><td></td><td valign="top"><a href="#index-LC_005fMESSAGES"><code>LC_MESSAGES</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Locale-Translation">Locale Translation</a></td></tr>
15112 <tr><td></td><td valign="top"><a href="#index-LC_005fMESSAGES-1"><code>LC_MESSAGES</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15113 <tr><td></td><td valign="top"><a href="#index-LC_005fNUMERIC"><code>LC_NUMERIC</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15114 <tr><td></td><td valign="top"><a href="#index-LC_005fTIME"><code>LC_TIME</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15115 <tr><td></td><td valign="top"><a href="#index-LINENO"><code>LINENO</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15116 <tr><td></td><td valign="top"><a href="#index-LINES"><code>LINES</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15117 <tr><td colspan="4"> <hr></td></tr>
15118 <tr><th><a name="Variable-Index_vr_letter-M">M</a></th><td></td><td></td></tr>
15119 <tr><td></td><td valign="top"><a href="#index-MACHTYPE"><code>MACHTYPE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15120 <tr><td></td><td valign="top"><a href="#index-MAIL"><code>MAIL</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Variables">Bourne Shell Variables</a></td></tr>
15121 <tr><td></td><td valign="top"><a href="#index-MAILCHECK"><code>MAILCHECK</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15122 <tr><td></td><td valign="top"><a href="#index-MAILPATH"><code>MAILPATH</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Variables">Bourne Shell Variables</a></td></tr>
15123 <tr><td></td><td valign="top"><a href="#index-MAPFILE"><code>MAPFILE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15124 <tr><td></td><td valign="top"><a href="#index-mark_002dmodified_002dlines"><code>mark-modified-lines</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15125 <tr><td></td><td valign="top"><a href="#index-mark_002dsymlinked_002ddirectories"><code>mark-symlinked-directories</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15126 <tr><td></td><td valign="top"><a href="#index-match_002dhidden_002dfiles"><code>match-hidden-files</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15127 <tr><td></td><td valign="top"><a href="#index-menu_002dcomplete_002ddisplay_002dprefix"><code>menu-complete-display-prefix</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15128 <tr><td></td><td valign="top"><a href="#index-meta_002dflag"><code>meta-flag</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15129 <tr><td colspan="4"> <hr></td></tr>
15130 <tr><th><a name="Variable-Index_vr_letter-O">O</a></th><td></td><td></td></tr>
15131 <tr><td></td><td valign="top"><a href="#index-OLDPWD"><code>OLDPWD</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15132 <tr><td></td><td valign="top"><a href="#index-OPTARG"><code>OPTARG</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Variables">Bourne Shell Variables</a></td></tr>
15133 <tr><td></td><td valign="top"><a href="#index-OPTERR"><code>OPTERR</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15134 <tr><td></td><td valign="top"><a href="#index-OPTIND"><code>OPTIND</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Variables">Bourne Shell Variables</a></td></tr>
15135 <tr><td></td><td valign="top"><a href="#index-OSTYPE"><code>OSTYPE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15136 <tr><td></td><td valign="top"><a href="#index-output_002dmeta"><code>output-meta</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15137 <tr><td colspan="4"> <hr></td></tr>
15138 <tr><th><a name="Variable-Index_vr_letter-P">P</a></th><td></td><td></td></tr>
15139 <tr><td></td><td valign="top"><a href="#index-page_002dcompletions"><code>page-completions</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15140 <tr><td></td><td valign="top"><a href="#index-PATH"><code>PATH</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Variables">Bourne Shell Variables</a></td></tr>
15141 <tr><td></td><td valign="top"><a href="#index-PIPESTATUS"><code>PIPESTATUS</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15142 <tr><td></td><td valign="top"><a href="#index-POSIXLY_005fCORRECT"><code>POSIXLY_CORRECT</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15143 <tr><td></td><td valign="top"><a href="#index-PPID"><code>PPID</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15144 <tr><td></td><td valign="top"><a href="#index-PROMPT_005fCOMMAND"><code>PROMPT_COMMAND</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15145 <tr><td></td><td valign="top"><a href="#index-PROMPT_005fDIRTRIM"><code>PROMPT_DIRTRIM</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15146 <tr><td></td><td valign="top"><a href="#index-PS0"><code>PS0</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15147 <tr><td></td><td valign="top"><a href="#index-PS1"><code>PS1</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Variables">Bourne Shell Variables</a></td></tr>
15148 <tr><td></td><td valign="top"><a href="#index-PS2"><code>PS2</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bourne-Shell-Variables">Bourne Shell Variables</a></td></tr>
15149 <tr><td></td><td valign="top"><a href="#index-PS3"><code>PS3</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15150 <tr><td></td><td valign="top"><a href="#index-PS4"><code>PS4</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15151 <tr><td></td><td valign="top"><a href="#index-PWD"><code>PWD</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15152 <tr><td colspan="4"> <hr></td></tr>
15153 <tr><th><a name="Variable-Index_vr_letter-R">R</a></th><td></td><td></td></tr>
15154 <tr><td></td><td valign="top"><a href="#index-RANDOM"><code>RANDOM</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15155 <tr><td></td><td valign="top"><a href="#index-READLINE_005fLINE"><code>READLINE_LINE</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15156 <tr><td></td><td valign="top"><a href="#index-READLINE_005fPOINT"><code>READLINE_POINT</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15157 <tr><td></td><td valign="top"><a href="#index-REPLY"><code>REPLY</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15158 <tr><td></td><td valign="top"><a href="#index-revert_002dall_002dat_002dnewline"><code>revert-all-at-newline</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15159 <tr><td colspan="4"> <hr></td></tr>
15160 <tr><th><a name="Variable-Index_vr_letter-S">S</a></th><td></td><td></td></tr>
15161 <tr><td></td><td valign="top"><a href="#index-SECONDS"><code>SECONDS</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15162 <tr><td></td><td valign="top"><a href="#index-SHELL"><code>SHELL</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15163 <tr><td></td><td valign="top"><a href="#index-SHELLOPTS"><code>SHELLOPTS</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15164 <tr><td></td><td valign="top"><a href="#index-SHLVL"><code>SHLVL</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15165 <tr><td></td><td valign="top"><a href="#index-show_002dall_002dif_002dambiguous"><code>show-all-if-ambiguous</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15166 <tr><td></td><td valign="top"><a href="#index-show_002dall_002dif_002dunmodified"><code>show-all-if-unmodified</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15167 <tr><td></td><td valign="top"><a href="#index-show_002dmode_002din_002dprompt"><code>show-mode-in-prompt</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15168 <tr><td></td><td valign="top"><a href="#index-skip_002dcompleted_002dtext"><code>skip-completed-text</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15169 <tr><td colspan="4"> <hr></td></tr>
15170 <tr><th><a name="Variable-Index_vr_letter-T">T</a></th><td></td><td></td></tr>
15171 <tr><td></td><td valign="top"><a href="#index-TEXTDOMAIN"><code>TEXTDOMAIN</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Locale-Translation">Locale Translation</a></td></tr>
15172 <tr><td></td><td valign="top"><a href="#index-TEXTDOMAINDIR"><code>TEXTDOMAINDIR</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Locale-Translation">Locale Translation</a></td></tr>
15173 <tr><td></td><td valign="top"><a href="#index-TIMEFORMAT"><code>TIMEFORMAT</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15174 <tr><td></td><td valign="top"><a href="#index-TMOUT"><code>TMOUT</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15175 <tr><td></td><td valign="top"><a href="#index-TMPDIR"><code>TMPDIR</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15176 <tr><td colspan="4"> <hr></td></tr>
15177 <tr><th><a name="Variable-Index_vr_letter-U">U</a></th><td></td><td></td></tr>
15178 <tr><td></td><td valign="top"><a href="#index-UID"><code>UID</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
15179 <tr><td colspan="4"> <hr></td></tr>
15180 <tr><th><a name="Variable-Index_vr_letter-V">V</a></th><td></td><td></td></tr>
15181 <tr><td></td><td valign="top"><a href="#index-vi_002dcmd_002dmode_002dstring"><code>vi-cmd-mode-string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15182 <tr><td></td><td valign="top"><a href="#index-vi_002dins_002dmode_002dstring"><code>vi-ins-mode-string</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15183 <tr><td></td><td valign="top"><a href="#index-visible_002dstats"><code>visible-stats</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15184 <tr><td colspan="4"> <hr></td></tr>
15185 </table>
15186 <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Variable-Index_vr_symbol-1"><b>!</b></a>
15187 &nbsp;
15188 <a class="summary-letter" href="#Variable-Index_vr_symbol-2"><b>#</b></a>
15189 &nbsp;
15190 <a class="summary-letter" href="#Variable-Index_vr_symbol-3"><b>$</b></a>
15191 &nbsp;
15192 <a class="summary-letter" href="#Variable-Index_vr_symbol-4"><b>*</b></a>
15193 &nbsp;
15194 <a class="summary-letter" href="#Variable-Index_vr_symbol-5"><b>-</b></a>
15195 &nbsp;
15196 <a class="summary-letter" href="#Variable-Index_vr_symbol-6"><b>0</b></a>
15197 &nbsp;
15198 <a class="summary-letter" href="#Variable-Index_vr_symbol-7"><b>?</b></a>
15199 &nbsp;
15200 <a class="summary-letter" href="#Variable-Index_vr_symbol-8"><b>@</b></a>
15201 &nbsp;
15202 <a class="summary-letter" href="#Variable-Index_vr_symbol-9"><b>_</b></a>
15203 &nbsp;
15204 <br>
15205 <a class="summary-letter" href="#Variable-Index_vr_letter-A"><b>A</b></a>
15206 &nbsp;
15207 <a class="summary-letter" href="#Variable-Index_vr_letter-B"><b>B</b></a>
15208 &nbsp;
15209 <a class="summary-letter" href="#Variable-Index_vr_letter-C"><b>C</b></a>
15210 &nbsp;
15211 <a class="summary-letter" href="#Variable-Index_vr_letter-D"><b>D</b></a>
15212 &nbsp;
15213 <a class="summary-letter" href="#Variable-Index_vr_letter-E"><b>E</b></a>
15214 &nbsp;
15215 <a class="summary-letter" href="#Variable-Index_vr_letter-F"><b>F</b></a>
15216 &nbsp;
15217 <a class="summary-letter" href="#Variable-Index_vr_letter-G"><b>G</b></a>
15218 &nbsp;
15219 <a class="summary-letter" href="#Variable-Index_vr_letter-H"><b>H</b></a>
15220 &nbsp;
15221 <a class="summary-letter" href="#Variable-Index_vr_letter-I"><b>I</b></a>
15222 &nbsp;
15223 <a class="summary-letter" href="#Variable-Index_vr_letter-K"><b>K</b></a>
15224 &nbsp;
15225 <a class="summary-letter" href="#Variable-Index_vr_letter-L"><b>L</b></a>
15226 &nbsp;
15227 <a class="summary-letter" href="#Variable-Index_vr_letter-M"><b>M</b></a>
15228 &nbsp;
15229 <a class="summary-letter" href="#Variable-Index_vr_letter-O"><b>O</b></a>
15230 &nbsp;
15231 <a class="summary-letter" href="#Variable-Index_vr_letter-P"><b>P</b></a>
15232 &nbsp;
15233 <a class="summary-letter" href="#Variable-Index_vr_letter-R"><b>R</b></a>
15234 &nbsp;
15235 <a class="summary-letter" href="#Variable-Index_vr_letter-S"><b>S</b></a>
15236 &nbsp;
15237 <a class="summary-letter" href="#Variable-Index_vr_letter-T"><b>T</b></a>
15238 &nbsp;
15239 <a class="summary-letter" href="#Variable-Index_vr_letter-U"><b>U</b></a>
15240 &nbsp;
15241 <a class="summary-letter" href="#Variable-Index_vr_letter-V"><b>V</b></a>
15242 &nbsp;
15243 </td></tr></table>
15244
15245 <hr>
15246 <a name="Function-Index"></a>
15247 <div class="header">
15248 <p>
15249 Next: <a href="#Concept-Index" accesskey="n" rel="next">Concept Index</a>, Previous: <a href="#Variable-Index" accesskey="p" rel="prev">Variable Index</a>, Up: <a href="#Indexes" accesskey="u" rel="up">Indexes</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
15250 </div>
15251 <a name="Function-Index-1"></a>
15252 <h3 class="appendixsec">D.4 Function Index</h3>
15253 <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Function-Index_fn_letter-A"><b>A</b></a>
15254 &nbsp;
15255 <a class="summary-letter" href="#Function-Index_fn_letter-B"><b>B</b></a>
15256 &nbsp;
15257 <a class="summary-letter" href="#Function-Index_fn_letter-C"><b>C</b></a>
15258 &nbsp;
15259 <a class="summary-letter" href="#Function-Index_fn_letter-D"><b>D</b></a>
15260 &nbsp;
15261 <a class="summary-letter" href="#Function-Index_fn_letter-E"><b>E</b></a>
15262 &nbsp;
15263 <a class="summary-letter" href="#Function-Index_fn_letter-F"><b>F</b></a>
15264 &nbsp;
15265 <a class="summary-letter" href="#Function-Index_fn_letter-G"><b>G</b></a>
15266 &nbsp;
15267 <a class="summary-letter" href="#Function-Index_fn_letter-H"><b>H</b></a>
15268 &nbsp;
15269 <a class="summary-letter" href="#Function-Index_fn_letter-I"><b>I</b></a>
15270 &nbsp;
15271 <a class="summary-letter" href="#Function-Index_fn_letter-K"><b>K</b></a>
15272 &nbsp;
15273 <a class="summary-letter" href="#Function-Index_fn_letter-M"><b>M</b></a>
15274 &nbsp;
15275 <a class="summary-letter" href="#Function-Index_fn_letter-N"><b>N</b></a>
15276 &nbsp;
15277 <a class="summary-letter" href="#Function-Index_fn_letter-O"><b>O</b></a>
15278 &nbsp;
15279 <a class="summary-letter" href="#Function-Index_fn_letter-P"><b>P</b></a>
15280 &nbsp;
15281 <a class="summary-letter" href="#Function-Index_fn_letter-Q"><b>Q</b></a>
15282 &nbsp;
15283 <a class="summary-letter" href="#Function-Index_fn_letter-R"><b>R</b></a>
15284 &nbsp;
15285 <a class="summary-letter" href="#Function-Index_fn_letter-S"><b>S</b></a>
15286 &nbsp;
15287 <a class="summary-letter" href="#Function-Index_fn_letter-T"><b>T</b></a>
15288 &nbsp;
15289 <a class="summary-letter" href="#Function-Index_fn_letter-U"><b>U</b></a>
15290 &nbsp;
15291 <a class="summary-letter" href="#Function-Index_fn_letter-Y"><b>Y</b></a>
15292 &nbsp;
15293 </td></tr></table>
15294 <table class="index-fn" border="0">
15295 <tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
15296 <tr><td colspan="4"> <hr></td></tr>
15297 <tr><th><a name="Function-Index_fn_letter-A">A</a></th><td></td><td></td></tr>
15298 <tr><td></td><td valign="top"><a href="#index-abort-_0028C_002dg_0029"><code>abort (C-g)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15299 <tr><td></td><td valign="top"><a href="#index-accept_002dline-_0028Newline-or-Return_0029"><code>accept-line (Newline or Return)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15300 <tr><td></td><td valign="top"><a href="#index-alias_002dexpand_002dline-_0028_0029"><code>alias-expand-line ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15301 <tr><td colspan="4"> <hr></td></tr>
15302 <tr><th><a name="Function-Index_fn_letter-B">B</a></th><td></td><td></td></tr>
15303 <tr><td></td><td valign="top"><a href="#index-backward_002dchar-_0028C_002db_0029"><code>backward-char (C-b)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Moving">Commands For Moving</a></td></tr>
15304 <tr><td></td><td valign="top"><a href="#index-backward_002ddelete_002dchar-_0028Rubout_0029"><code>backward-delete-char (Rubout)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Text">Commands For Text</a></td></tr>
15305 <tr><td></td><td valign="top"><a href="#index-backward_002dkill_002dline-_0028C_002dx-Rubout_0029"><code>backward-kill-line (C-x Rubout)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15306 <tr><td></td><td valign="top"><a href="#index-backward_002dkill_002dword-_0028M_002dDEL_0029"><code>backward-kill-word (M-<span class="key">DEL</span>)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15307 <tr><td></td><td valign="top"><a href="#index-backward_002dword-_0028M_002db_0029"><code>backward-word (M-b)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Moving">Commands For Moving</a></td></tr>
15308 <tr><td></td><td valign="top"><a href="#index-beginning_002dof_002dhistory-_0028M_002d_003c_0029"><code>beginning-of-history (M-&lt;)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15309 <tr><td></td><td valign="top"><a href="#index-beginning_002dof_002dline-_0028C_002da_0029"><code>beginning-of-line (C-a)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Moving">Commands For Moving</a></td></tr>
15310 <tr><td></td><td valign="top"><a href="#index-bracketed_002dpaste_002dbegin-_0028_0029"><code>bracketed-paste-begin ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Text">Commands For Text</a></td></tr>
15311 <tr><td colspan="4"> <hr></td></tr>
15312 <tr><th><a name="Function-Index_fn_letter-C">C</a></th><td></td><td></td></tr>
15313 <tr><td></td><td valign="top"><a href="#index-call_002dlast_002dkbd_002dmacro-_0028C_002dx-e_0029"><code>call-last-kbd-macro (C-x e)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Keyboard-Macros">Keyboard Macros</a></td></tr>
15314 <tr><td></td><td valign="top"><a href="#index-capitalize_002dword-_0028M_002dc_0029"><code>capitalize-word (M-c)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Text">Commands For Text</a></td></tr>
15315 <tr><td></td><td valign="top"><a href="#index-character_002dsearch-_0028C_002d_005d_0029"><code>character-search (C-])</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15316 <tr><td></td><td valign="top"><a href="#index-character_002dsearch_002dbackward-_0028M_002dC_002d_005d_0029"><code>character-search-backward (M-C-])</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15317 <tr><td></td><td valign="top"><a href="#index-clear_002dscreen-_0028C_002dl_0029"><code>clear-screen (C-l)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Moving">Commands For Moving</a></td></tr>
15318 <tr><td></td><td valign="top"><a href="#index-complete-_0028TAB_0029"><code>complete (<span class="key">TAB</span>)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15319 <tr><td></td><td valign="top"><a href="#index-complete_002dcommand-_0028M_002d_0021_0029"><code>complete-command (M-!)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15320 <tr><td></td><td valign="top"><a href="#index-complete_002dfilename-_0028M_002d_002f_0029"><code>complete-filename (M-/)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15321 <tr><td></td><td valign="top"><a href="#index-complete_002dhostname-_0028M_002d_0040_0029"><code>complete-hostname (M-@)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15322 <tr><td></td><td valign="top"><a href="#index-complete_002dinto_002dbraces-_0028M_002d_007b_0029"><code>complete-into-braces (M-{)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15323 <tr><td></td><td valign="top"><a href="#index-complete_002dusername-_0028M_002d_007e_0029"><code>complete-username (M-~)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15324 <tr><td></td><td valign="top"><a href="#index-complete_002dvariable-_0028M_002d_0024_0029"><code>complete-variable (M-$)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15325 <tr><td></td><td valign="top"><a href="#index-copy_002dbackward_002dword-_0028_0029"><code>copy-backward-word ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15326 <tr><td></td><td valign="top"><a href="#index-copy_002dforward_002dword-_0028_0029"><code>copy-forward-word ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15327 <tr><td></td><td valign="top"><a href="#index-copy_002dregion_002das_002dkill-_0028_0029"><code>copy-region-as-kill ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15328 <tr><td colspan="4"> <hr></td></tr>
15329 <tr><th><a name="Function-Index_fn_letter-D">D</a></th><td></td><td></td></tr>
15330 <tr><td></td><td valign="top"><a href="#index-dabbrev_002dexpand-_0028_0029"><code>dabbrev-expand ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15331 <tr><td></td><td valign="top"><a href="#index-delete_002dchar-_0028C_002dd_0029"><code>delete-char (C-d)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Text">Commands For Text</a></td></tr>
15332 <tr><td></td><td valign="top"><a href="#index-delete_002dchar_002dor_002dlist-_0028_0029"><code>delete-char-or-list ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15333 <tr><td></td><td valign="top"><a href="#index-delete_002dhorizontal_002dspace-_0028_0029"><code>delete-horizontal-space ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15334 <tr><td></td><td valign="top"><a href="#index-digit_002dargument-_0028M_002d0_002c-M_002d1_002c-_2026-M_002d_002d_0029"><code>digit-argument (<kbd>M-0</kbd>, <kbd>M-1</kbd>, &hellip; <kbd>M--</kbd>)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Numeric-Arguments">Numeric Arguments</a></td></tr>
15335 <tr><td></td><td valign="top"><a href="#index-display_002dshell_002dversion-_0028C_002dx-C_002dv_0029"><code>display-shell-version (C-x C-v)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15336 <tr><td></td><td valign="top"><a href="#index-do_002dlowercase_002dversion-_0028M_002dA_002c-M_002dB_002c-M_002dx_002c-_2026_0029"><code>do-lowercase-version (M-A, M-B, M-<var>x</var>, &hellip;)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15337 <tr><td></td><td valign="top"><a href="#index-downcase_002dword-_0028M_002dl_0029"><code>downcase-word (M-l)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Text">Commands For Text</a></td></tr>
15338 <tr><td></td><td valign="top"><a href="#index-dump_002dfunctions-_0028_0029"><code>dump-functions ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15339 <tr><td></td><td valign="top"><a href="#index-dump_002dmacros-_0028_0029"><code>dump-macros ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15340 <tr><td></td><td valign="top"><a href="#index-dump_002dvariables-_0028_0029"><code>dump-variables ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15341 <tr><td></td><td valign="top"><a href="#index-dynamic_002dcomplete_002dhistory-_0028M_002dTAB_0029"><code>dynamic-complete-history (M-<span class="key">TAB</span>)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15342 <tr><td colspan="4"> <hr></td></tr>
15343 <tr><th><a name="Function-Index_fn_letter-E">E</a></th><td></td><td></td></tr>
15344 <tr><td></td><td valign="top"><a href="#index-edit_002dand_002dexecute_002dcommand-_0028C_002dx-C_002de_0029"><code>edit-and-execute-command (C-x C-e)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15345 <tr><td></td><td valign="top"><a href="#index-end_002dkbd_002dmacro-_0028C_002dx-_0029_0029"><code>end-kbd-macro (C-x ))</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Keyboard-Macros">Keyboard Macros</a></td></tr>
15346 <tr><td></td><td valign="top"><a href="#index-end_002dof_002dfile-_0028usually-C_002dd_0029"><code><i>end-of-file</i> (usually C-d)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Text">Commands For Text</a></td></tr>
15347 <tr><td></td><td valign="top"><a href="#index-end_002dof_002dhistory-_0028M_002d_003e_0029"><code>end-of-history (M-&gt;)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15348 <tr><td></td><td valign="top"><a href="#index-end_002dof_002dline-_0028C_002de_0029"><code>end-of-line (C-e)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Moving">Commands For Moving</a></td></tr>
15349 <tr><td></td><td valign="top"><a href="#index-exchange_002dpoint_002dand_002dmark-_0028C_002dx-C_002dx_0029"><code>exchange-point-and-mark (C-x C-x)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15350 <tr><td colspan="4"> <hr></td></tr>
15351 <tr><th><a name="Function-Index_fn_letter-F">F</a></th><td></td><td></td></tr>
15352 <tr><td></td><td valign="top"><a href="#index-forward_002dbackward_002ddelete_002dchar-_0028_0029"><code>forward-backward-delete-char ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Text">Commands For Text</a></td></tr>
15353 <tr><td></td><td valign="top"><a href="#index-forward_002dchar-_0028C_002df_0029"><code>forward-char (C-f)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Moving">Commands For Moving</a></td></tr>
15354 <tr><td></td><td valign="top"><a href="#index-forward_002dsearch_002dhistory-_0028C_002ds_0029"><code>forward-search-history (C-s)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15355 <tr><td></td><td valign="top"><a href="#index-forward_002dword-_0028M_002df_0029"><code>forward-word (M-f)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Moving">Commands For Moving</a></td></tr>
15356 <tr><td colspan="4"> <hr></td></tr>
15357 <tr><th><a name="Function-Index_fn_letter-G">G</a></th><td></td><td></td></tr>
15358 <tr><td></td><td valign="top"><a href="#index-glob_002dcomplete_002dword-_0028M_002dg_0029"><code>glob-complete-word (M-g)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15359 <tr><td></td><td valign="top"><a href="#index-glob_002dexpand_002dword-_0028C_002dx-_002a_0029"><code>glob-expand-word (C-x *)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15360 <tr><td></td><td valign="top"><a href="#index-glob_002dlist_002dexpansions-_0028C_002dx-g_0029"><code>glob-list-expansions (C-x g)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15361 <tr><td colspan="4"> <hr></td></tr>
15362 <tr><th><a name="Function-Index_fn_letter-H">H</a></th><td></td><td></td></tr>
15363 <tr><td></td><td valign="top"><a href="#index-history_002dand_002dalias_002dexpand_002dline-_0028_0029"><code>history-and-alias-expand-line ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15364 <tr><td></td><td valign="top"><a href="#index-history_002dexpand_002dline-_0028M_002d_005e_0029"><code>history-expand-line (M-^)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15365 <tr><td></td><td valign="top"><a href="#index-history_002dsearch_002dbackward-_0028_0029"><code>history-search-backward ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15366 <tr><td></td><td valign="top"><a href="#index-history_002dsearch_002dforward-_0028_0029"><code>history-search-forward ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15367 <tr><td></td><td valign="top"><a href="#index-history_002dsubstring_002dsearch_002dbackward-_0028_0029"><code>history-substring-search-backward ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15368 <tr><td></td><td valign="top"><a href="#index-history_002dsubstring_002dsearch_002dforward-_0028_0029"><code>history-substring-search-forward ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15369 <tr><td colspan="4"> <hr></td></tr>
15370 <tr><th><a name="Function-Index_fn_letter-I">I</a></th><td></td><td></td></tr>
15371 <tr><td></td><td valign="top"><a href="#index-insert_002dcomment-_0028M_002d_0023_0029"><code>insert-comment (M-#)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15372 <tr><td></td><td valign="top"><a href="#index-insert_002dcompletions-_0028M_002d_002a_0029"><code>insert-completions (M-*)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15373 <tr><td></td><td valign="top"><a href="#index-insert_002dlast_002dargument-_0028M_002d_002e-or-M_002d_005f_0029"><code>insert-last-argument (M-. or M-_)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15374 <tr><td colspan="4"> <hr></td></tr>
15375 <tr><th><a name="Function-Index_fn_letter-K">K</a></th><td></td><td></td></tr>
15376 <tr><td></td><td valign="top"><a href="#index-kill_002dline-_0028C_002dk_0029"><code>kill-line (C-k)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15377 <tr><td></td><td valign="top"><a href="#index-kill_002dregion-_0028_0029"><code>kill-region ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15378 <tr><td></td><td valign="top"><a href="#index-kill_002dwhole_002dline-_0028_0029"><code>kill-whole-line ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15379 <tr><td></td><td valign="top"><a href="#index-kill_002dword-_0028M_002dd_0029"><code>kill-word (M-d)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15380 <tr><td colspan="4"> <hr></td></tr>
15381 <tr><th><a name="Function-Index_fn_letter-M">M</a></th><td></td><td></td></tr>
15382 <tr><td></td><td valign="top"><a href="#index-magic_002dspace-_0028_0029"><code>magic-space ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15383 <tr><td></td><td valign="top"><a href="#index-menu_002dcomplete-_0028_0029"><code>menu-complete ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15384 <tr><td></td><td valign="top"><a href="#index-menu_002dcomplete_002dbackward-_0028_0029"><code>menu-complete-backward ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15385 <tr><td colspan="4"> <hr></td></tr>
15386 <tr><th><a name="Function-Index_fn_letter-N">N</a></th><td></td><td></td></tr>
15387 <tr><td></td><td valign="top"><a href="#index-next_002dhistory-_0028C_002dn_0029"><code>next-history (C-n)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15388 <tr><td></td><td valign="top"><a href="#index-next_002dscreen_002dline-_0028_0029"><code>next-screen-line ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Moving">Commands For Moving</a></td></tr>
15389 <tr><td></td><td valign="top"><a href="#index-non_002dincremental_002dforward_002dsearch_002dhistory-_0028M_002dn_0029"><code>non-incremental-forward-search-history (M-n)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15390 <tr><td></td><td valign="top"><a href="#index-non_002dincremental_002dreverse_002dsearch_002dhistory-_0028M_002dp_0029"><code>non-incremental-reverse-search-history (M-p)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15391 <tr><td colspan="4"> <hr></td></tr>
15392 <tr><th><a name="Function-Index_fn_letter-O">O</a></th><td></td><td></td></tr>
15393 <tr><td></td><td valign="top"><a href="#index-operate_002dand_002dget_002dnext-_0028C_002do_0029"><code>operate-and-get-next (C-o)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15394 <tr><td></td><td valign="top"><a href="#index-overwrite_002dmode-_0028_0029"><code>overwrite-mode ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Text">Commands For Text</a></td></tr>
15395 <tr><td colspan="4"> <hr></td></tr>
15396 <tr><th><a name="Function-Index_fn_letter-P">P</a></th><td></td><td></td></tr>
15397 <tr><td></td><td valign="top"><a href="#index-possible_002dcommand_002dcompletions-_0028C_002dx-_0021_0029"><code>possible-command-completions (C-x !)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15398 <tr><td></td><td valign="top"><a href="#index-possible_002dcompletions-_0028M_002d_003f_0029"><code>possible-completions (M-?)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15399 <tr><td></td><td valign="top"><a href="#index-possible_002dfilename_002dcompletions-_0028C_002dx-_002f_0029"><code>possible-filename-completions (C-x /)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15400 <tr><td></td><td valign="top"><a href="#index-possible_002dhostname_002dcompletions-_0028C_002dx-_0040_0029"><code>possible-hostname-completions (C-x @)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15401 <tr><td></td><td valign="top"><a href="#index-possible_002dusername_002dcompletions-_0028C_002dx-_007e_0029"><code>possible-username-completions (C-x ~)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15402 <tr><td></td><td valign="top"><a href="#index-possible_002dvariable_002dcompletions-_0028C_002dx-_0024_0029"><code>possible-variable-completions (C-x $)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Completion">Commands For Completion</a></td></tr>
15403 <tr><td></td><td valign="top"><a href="#index-prefix_002dmeta-_0028ESC_0029"><code>prefix-meta (<span class="key">ESC</span>)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15404 <tr><td></td><td valign="top"><a href="#index-previous_002dhistory-_0028C_002dp_0029"><code>previous-history (C-p)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15405 <tr><td></td><td valign="top"><a href="#index-previous_002dscreen_002dline-_0028_0029"><code>previous-screen-line ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Moving">Commands For Moving</a></td></tr>
15406 <tr><td></td><td valign="top"><a href="#index-print_002dlast_002dkbd_002dmacro-_0028_0029"><code>print-last-kbd-macro ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Keyboard-Macros">Keyboard Macros</a></td></tr>
15407 <tr><td colspan="4"> <hr></td></tr>
15408 <tr><th><a name="Function-Index_fn_letter-Q">Q</a></th><td></td><td></td></tr>
15409 <tr><td></td><td valign="top"><a href="#index-quoted_002dinsert-_0028C_002dq-or-C_002dv_0029"><code>quoted-insert (C-q or C-v)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Text">Commands For Text</a></td></tr>
15410 <tr><td colspan="4"> <hr></td></tr>
15411 <tr><th><a name="Function-Index_fn_letter-R">R</a></th><td></td><td></td></tr>
15412 <tr><td></td><td valign="top"><a href="#index-re_002dread_002dinit_002dfile-_0028C_002dx-C_002dr_0029"><code>re-read-init-file (C-x C-r)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15413 <tr><td></td><td valign="top"><a href="#index-redraw_002dcurrent_002dline-_0028_0029"><code>redraw-current-line ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Moving">Commands For Moving</a></td></tr>
15414 <tr><td></td><td valign="top"><a href="#index-reverse_002dsearch_002dhistory-_0028C_002dr_0029"><code>reverse-search-history (C-r)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15415 <tr><td></td><td valign="top"><a href="#index-revert_002dline-_0028M_002dr_0029"><code>revert-line (M-r)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15416 <tr><td colspan="4"> <hr></td></tr>
15417 <tr><th><a name="Function-Index_fn_letter-S">S</a></th><td></td><td></td></tr>
15418 <tr><td></td><td valign="top"><a href="#index-self_002dinsert-_0028a_002c-b_002c-A_002c-1_002c-_0021_002c-_2026_0029"><code>self-insert (a, b, A, 1, !, &hellip;)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Text">Commands For Text</a></td></tr>
15419 <tr><td></td><td valign="top"><a href="#index-set_002dmark-_0028C_002d_0040_0029"><code>set-mark (C-@)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15420 <tr><td></td><td valign="top"><a href="#index-shell_002dbackward_002dkill_002dword-_0028_0029"><code>shell-backward-kill-word ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15421 <tr><td></td><td valign="top"><a href="#index-shell_002dbackward_002dword-_0028_0029"><code>shell-backward-word ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Moving">Commands For Moving</a></td></tr>
15422 <tr><td></td><td valign="top"><a href="#index-shell_002dexpand_002dline-_0028M_002dC_002de_0029"><code>shell-expand-line (M-C-e)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15423 <tr><td></td><td valign="top"><a href="#index-shell_002dforward_002dword-_0028_0029"><code>shell-forward-word ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Moving">Commands For Moving</a></td></tr>
15424 <tr><td></td><td valign="top"><a href="#index-shell_002dkill_002dword-_0028_0029"><code>shell-kill-word ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15425 <tr><td></td><td valign="top"><a href="#index-skip_002dcsi_002dsequence-_0028_0029"><code>skip-csi-sequence ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15426 <tr><td></td><td valign="top"><a href="#index-start_002dkbd_002dmacro-_0028C_002dx-_0028_0029"><code>start-kbd-macro (C-x ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Keyboard-Macros">Keyboard Macros</a></td></tr>
15427 <tr><td colspan="4"> <hr></td></tr>
15428 <tr><th><a name="Function-Index_fn_letter-T">T</a></th><td></td><td></td></tr>
15429 <tr><td></td><td valign="top"><a href="#index-tilde_002dexpand-_0028M_002d_0026_0029"><code>tilde-expand (M-&amp;)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15430 <tr><td></td><td valign="top"><a href="#index-transpose_002dchars-_0028C_002dt_0029"><code>transpose-chars (C-t)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Text">Commands For Text</a></td></tr>
15431 <tr><td></td><td valign="top"><a href="#index-transpose_002dwords-_0028M_002dt_0029"><code>transpose-words (M-t)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Text">Commands For Text</a></td></tr>
15432 <tr><td colspan="4"> <hr></td></tr>
15433 <tr><th><a name="Function-Index_fn_letter-U">U</a></th><td></td><td></td></tr>
15434 <tr><td></td><td valign="top"><a href="#index-undo-_0028C_002d_005f-or-C_002dx-C_002du_0029"><code>undo (C-_ or C-x C-u)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Miscellaneous-Commands">Miscellaneous Commands</a></td></tr>
15435 <tr><td></td><td valign="top"><a href="#index-universal_002dargument-_0028_0029"><code>universal-argument ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Numeric-Arguments">Numeric Arguments</a></td></tr>
15436 <tr><td></td><td valign="top"><a href="#index-unix_002dfilename_002drubout-_0028_0029"><code>unix-filename-rubout ()</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15437 <tr><td></td><td valign="top"><a href="#index-unix_002dline_002ddiscard-_0028C_002du_0029"><code>unix-line-discard (C-u)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15438 <tr><td></td><td valign="top"><a href="#index-unix_002dword_002drubout-_0028C_002dw_0029"><code>unix-word-rubout (C-w)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15439 <tr><td></td><td valign="top"><a href="#index-upcase_002dword-_0028M_002du_0029"><code>upcase-word (M-u)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Text">Commands For Text</a></td></tr>
15440 <tr><td colspan="4"> <hr></td></tr>
15441 <tr><th><a name="Function-Index_fn_letter-Y">Y</a></th><td></td><td></td></tr>
15442 <tr><td></td><td valign="top"><a href="#index-yank-_0028C_002dy_0029"><code>yank (C-y)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15443 <tr><td></td><td valign="top"><a href="#index-yank_002dlast_002darg-_0028M_002d_002e-or-M_002d_005f_0029"><code>yank-last-arg (M-. or M-_)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15444 <tr><td></td><td valign="top"><a href="#index-yank_002dnth_002darg-_0028M_002dC_002dy_0029"><code>yank-nth-arg (M-C-y)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-History">Commands For History</a></td></tr>
15445 <tr><td></td><td valign="top"><a href="#index-yank_002dpop-_0028M_002dy_0029"><code>yank-pop (M-y)</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Commands-For-Killing">Commands For Killing</a></td></tr>
15446 <tr><td colspan="4"> <hr></td></tr>
15447 </table>
15448 <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Function-Index_fn_letter-A"><b>A</b></a>
15449 &nbsp;
15450 <a class="summary-letter" href="#Function-Index_fn_letter-B"><b>B</b></a>
15451 &nbsp;
15452 <a class="summary-letter" href="#Function-Index_fn_letter-C"><b>C</b></a>
15453 &nbsp;
15454 <a class="summary-letter" href="#Function-Index_fn_letter-D"><b>D</b></a>
15455 &nbsp;
15456 <a class="summary-letter" href="#Function-Index_fn_letter-E"><b>E</b></a>
15457 &nbsp;
15458 <a class="summary-letter" href="#Function-Index_fn_letter-F"><b>F</b></a>
15459 &nbsp;
15460 <a class="summary-letter" href="#Function-Index_fn_letter-G"><b>G</b></a>
15461 &nbsp;
15462 <a class="summary-letter" href="#Function-Index_fn_letter-H"><b>H</b></a>
15463 &nbsp;
15464 <a class="summary-letter" href="#Function-Index_fn_letter-I"><b>I</b></a>
15465 &nbsp;
15466 <a class="summary-letter" href="#Function-Index_fn_letter-K"><b>K</b></a>
15467 &nbsp;
15468 <a class="summary-letter" href="#Function-Index_fn_letter-M"><b>M</b></a>
15469 &nbsp;
15470 <a class="summary-letter" href="#Function-Index_fn_letter-N"><b>N</b></a>
15471 &nbsp;
15472 <a class="summary-letter" href="#Function-Index_fn_letter-O"><b>O</b></a>
15473 &nbsp;
15474 <a class="summary-letter" href="#Function-Index_fn_letter-P"><b>P</b></a>
15475 &nbsp;
15476 <a class="summary-letter" href="#Function-Index_fn_letter-Q"><b>Q</b></a>
15477 &nbsp;
15478 <a class="summary-letter" href="#Function-Index_fn_letter-R"><b>R</b></a>
15479 &nbsp;
15480 <a class="summary-letter" href="#Function-Index_fn_letter-S"><b>S</b></a>
15481 &nbsp;
15482 <a class="summary-letter" href="#Function-Index_fn_letter-T"><b>T</b></a>
15483 &nbsp;
15484 <a class="summary-letter" href="#Function-Index_fn_letter-U"><b>U</b></a>
15485 &nbsp;
15486 <a class="summary-letter" href="#Function-Index_fn_letter-Y"><b>Y</b></a>
15487 &nbsp;
15488 </td></tr></table>
15489
15490 <hr>
15491 <a name="Concept-Index"></a>
15492 <div class="header">
15493 <p>
15494 Previous: <a href="#Function-Index" accesskey="p" rel="prev">Function Index</a>, Up: <a href="#Indexes" accesskey="u" rel="up">Indexes</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
15495 </div>
15496 <a name="Concept-Index-1"></a>
15497 <h3 class="appendixsec">D.5 Concept Index</h3>
15498 <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Concept-Index_cp_letter-A"><b>A</b></a>
15499 &nbsp;
15500 <a class="summary-letter" href="#Concept-Index_cp_letter-B"><b>B</b></a>
15501 &nbsp;
15502 <a class="summary-letter" href="#Concept-Index_cp_letter-C"><b>C</b></a>
15503 &nbsp;
15504 <a class="summary-letter" href="#Concept-Index_cp_letter-D"><b>D</b></a>
15505 &nbsp;
15506 <a class="summary-letter" href="#Concept-Index_cp_letter-E"><b>E</b></a>
15507 &nbsp;
15508 <a class="summary-letter" href="#Concept-Index_cp_letter-F"><b>F</b></a>
15509 &nbsp;
15510 <a class="summary-letter" href="#Concept-Index_cp_letter-H"><b>H</b></a>
15511 &nbsp;
15512 <a class="summary-letter" href="#Concept-Index_cp_letter-I"><b>I</b></a>
15513 &nbsp;
15514 <a class="summary-letter" href="#Concept-Index_cp_letter-J"><b>J</b></a>
15515 &nbsp;
15516 <a class="summary-letter" href="#Concept-Index_cp_letter-K"><b>K</b></a>
15517 &nbsp;
15518 <a class="summary-letter" href="#Concept-Index_cp_letter-L"><b>L</b></a>
15519 &nbsp;
15520 <a class="summary-letter" href="#Concept-Index_cp_letter-M"><b>M</b></a>
15521 &nbsp;
15522 <a class="summary-letter" href="#Concept-Index_cp_letter-N"><b>N</b></a>
15523 &nbsp;
15524 <a class="summary-letter" href="#Concept-Index_cp_letter-O"><b>O</b></a>
15525 &nbsp;
15526 <a class="summary-letter" href="#Concept-Index_cp_letter-P"><b>P</b></a>
15527 &nbsp;
15528 <a class="summary-letter" href="#Concept-Index_cp_letter-Q"><b>Q</b></a>
15529 &nbsp;
15530 <a class="summary-letter" href="#Concept-Index_cp_letter-R"><b>R</b></a>
15531 &nbsp;
15532 <a class="summary-letter" href="#Concept-Index_cp_letter-S"><b>S</b></a>
15533 &nbsp;
15534 <a class="summary-letter" href="#Concept-Index_cp_letter-T"><b>T</b></a>
15535 &nbsp;
15536 <a class="summary-letter" href="#Concept-Index_cp_letter-V"><b>V</b></a>
15537 &nbsp;
15538 <a class="summary-letter" href="#Concept-Index_cp_letter-W"><b>W</b></a>
15539 &nbsp;
15540 <a class="summary-letter" href="#Concept-Index_cp_letter-Y"><b>Y</b></a>
15541 &nbsp;
15542 </td></tr></table>
15543 <table class="index-cp" border="0">
15544 <tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
15545 <tr><td colspan="4"> <hr></td></tr>
15546 <tr><th><a name="Concept-Index_cp_letter-A">A</a></th><td></td><td></td></tr>
15547 <tr><td></td><td valign="top"><a href="#index-alias-expansion">alias expansion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Aliases">Aliases</a></td></tr>
15548 <tr><td></td><td valign="top"><a href="#index-arithmetic-evaluation">arithmetic evaluation</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Arithmetic">Shell Arithmetic</a></td></tr>
15549 <tr><td></td><td valign="top"><a href="#index-arithmetic-expansion">arithmetic expansion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Arithmetic-Expansion">Arithmetic Expansion</a></td></tr>
15550 <tr><td></td><td valign="top"><a href="#index-arithmetic_002c-shell">arithmetic, shell</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Arithmetic">Shell Arithmetic</a></td></tr>
15551 <tr><td></td><td valign="top"><a href="#index-arrays">arrays</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Arrays">Arrays</a></td></tr>
15552 <tr><td colspan="4"> <hr></td></tr>
15553 <tr><th><a name="Concept-Index_cp_letter-B">B</a></th><td></td><td></td></tr>
15554 <tr><td></td><td valign="top"><a href="#index-background">background</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Job-Control-Basics">Job Control Basics</a></td></tr>
15555 <tr><td></td><td valign="top"><a href="#index-Bash-configuration">Bash configuration</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-Installation">Basic Installation</a></td></tr>
15556 <tr><td></td><td valign="top"><a href="#index-Bash-installation">Bash installation</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-Installation">Basic Installation</a></td></tr>
15557 <tr><td></td><td valign="top"><a href="#index-Bourne-shell">Bourne shell</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-Shell-Features">Basic Shell Features</a></td></tr>
15558 <tr><td></td><td valign="top"><a href="#index-brace-expansion">brace expansion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Brace-Expansion">Brace Expansion</a></td></tr>
15559 <tr><td></td><td valign="top"><a href="#index-builtin-1">builtin</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15560 <tr><td colspan="4"> <hr></td></tr>
15561 <tr><th><a name="Concept-Index_cp_letter-C">C</a></th><td></td><td></td></tr>
15562 <tr><td></td><td valign="top"><a href="#index-command-editing">command editing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Bare-Essentials">Readline Bare Essentials</a></td></tr>
15563 <tr><td></td><td valign="top"><a href="#index-command-execution">command execution</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-Search-and-Execution">Command Search and Execution</a></td></tr>
15564 <tr><td></td><td valign="top"><a href="#index-command-expansion">command expansion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Simple-Command-Expansion">Simple Command Expansion</a></td></tr>
15565 <tr><td></td><td valign="top"><a href="#index-command-history">command history</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-History-Facilities">Bash History Facilities</a></td></tr>
15566 <tr><td></td><td valign="top"><a href="#index-command-search">command search</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-Search-and-Execution">Command Search and Execution</a></td></tr>
15567 <tr><td></td><td valign="top"><a href="#index-command-substitution">command substitution</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-Substitution">Command Substitution</a></td></tr>
15568 <tr><td></td><td valign="top"><a href="#index-command-timing">command timing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pipelines">Pipelines</a></td></tr>
15569 <tr><td></td><td valign="top"><a href="#index-commands_002c-compound">commands, compound</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Compound-Commands">Compound Commands</a></td></tr>
15570 <tr><td></td><td valign="top"><a href="#index-commands_002c-conditional">commands, conditional</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Conditional-Constructs">Conditional Constructs</a></td></tr>
15571 <tr><td></td><td valign="top"><a href="#index-commands_002c-grouping">commands, grouping</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-Grouping">Command Grouping</a></td></tr>
15572 <tr><td></td><td valign="top"><a href="#index-commands_002c-lists">commands, lists</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Lists">Lists</a></td></tr>
15573 <tr><td></td><td valign="top"><a href="#index-commands_002c-looping">commands, looping</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Looping-Constructs">Looping Constructs</a></td></tr>
15574 <tr><td></td><td valign="top"><a href="#index-commands_002c-pipelines">commands, pipelines</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pipelines">Pipelines</a></td></tr>
15575 <tr><td></td><td valign="top"><a href="#index-commands_002c-shell">commands, shell</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Commands">Shell Commands</a></td></tr>
15576 <tr><td></td><td valign="top"><a href="#index-commands_002c-simple">commands, simple</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Simple-Commands">Simple Commands</a></td></tr>
15577 <tr><td></td><td valign="top"><a href="#index-comments_002c-shell">comments, shell</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Comments">Comments</a></td></tr>
15578 <tr><td></td><td valign="top"><a href="#index-completion-builtins">completion builtins</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Programmable-Completion-Builtins">Programmable Completion Builtins</a></td></tr>
15579 <tr><td></td><td valign="top"><a href="#index-configuration">configuration</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-Installation">Basic Installation</a></td></tr>
15580 <tr><td></td><td valign="top"><a href="#index-control-operator">control operator</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15581 <tr><td></td><td valign="top"><a href="#index-coprocess">coprocess</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Coprocesses">Coprocesses</a></td></tr>
15582 <tr><td colspan="4"> <hr></td></tr>
15583 <tr><th><a name="Concept-Index_cp_letter-D">D</a></th><td></td><td></td></tr>
15584 <tr><td></td><td valign="top"><a href="#index-directory-stack">directory stack</a>:</td><td>&nbsp;</td><td valign="top"><a href="#The-Directory-Stack">The Directory Stack</a></td></tr>
15585 <tr><td colspan="4"> <hr></td></tr>
15586 <tr><th><a name="Concept-Index_cp_letter-E">E</a></th><td></td><td></td></tr>
15587 <tr><td></td><td valign="top"><a href="#index-editing-command-lines">editing command lines</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Bare-Essentials">Readline Bare Essentials</a></td></tr>
15588 <tr><td></td><td valign="top"><a href="#index-environment">environment</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Environment">Environment</a></td></tr>
15589 <tr><td></td><td valign="top"><a href="#index-evaluation_002c-arithmetic">evaluation, arithmetic</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Arithmetic">Shell Arithmetic</a></td></tr>
15590 <tr><td></td><td valign="top"><a href="#index-event-designators">event designators</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Event-Designators">Event Designators</a></td></tr>
15591 <tr><td></td><td valign="top"><a href="#index-execution-environment">execution environment</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Command-Execution-Environment">Command Execution Environment</a></td></tr>
15592 <tr><td></td><td valign="top"><a href="#index-exit-status">exit status</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15593 <tr><td></td><td valign="top"><a href="#index-exit-status-1">exit status</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Exit-Status">Exit Status</a></td></tr>
15594 <tr><td></td><td valign="top"><a href="#index-expansion">expansion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Expansions">Shell Expansions</a></td></tr>
15595 <tr><td></td><td valign="top"><a href="#index-expansion_002c-arithmetic">expansion, arithmetic</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Arithmetic-Expansion">Arithmetic Expansion</a></td></tr>
15596 <tr><td></td><td valign="top"><a href="#index-expansion_002c-brace">expansion, brace</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Brace-Expansion">Brace Expansion</a></td></tr>
15597 <tr><td></td><td valign="top"><a href="#index-expansion_002c-filename">expansion, filename</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filename-Expansion">Filename Expansion</a></td></tr>
15598 <tr><td></td><td valign="top"><a href="#index-expansion_002c-parameter">expansion, parameter</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a></td></tr>
15599 <tr><td></td><td valign="top"><a href="#index-expansion_002c-pathname">expansion, pathname</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filename-Expansion">Filename Expansion</a></td></tr>
15600 <tr><td></td><td valign="top"><a href="#index-expansion_002c-tilde">expansion, tilde</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Tilde-Expansion">Tilde Expansion</a></td></tr>
15601 <tr><td></td><td valign="top"><a href="#index-expressions_002c-arithmetic">expressions, arithmetic</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Arithmetic">Shell Arithmetic</a></td></tr>
15602 <tr><td></td><td valign="top"><a href="#index-expressions_002c-conditional">expressions, conditional</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Conditional-Expressions">Bash Conditional Expressions</a></td></tr>
15603 <tr><td colspan="4"> <hr></td></tr>
15604 <tr><th><a name="Concept-Index_cp_letter-F">F</a></th><td></td><td></td></tr>
15605 <tr><td></td><td valign="top"><a href="#index-field">field</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15606 <tr><td></td><td valign="top"><a href="#index-filename">filename</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15607 <tr><td></td><td valign="top"><a href="#index-filename-expansion">filename expansion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filename-Expansion">Filename Expansion</a></td></tr>
15608 <tr><td></td><td valign="top"><a href="#index-foreground">foreground</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Job-Control-Basics">Job Control Basics</a></td></tr>
15609 <tr><td></td><td valign="top"><a href="#index-functions_002c-shell">functions, shell</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Functions">Shell Functions</a></td></tr>
15610 <tr><td colspan="4"> <hr></td></tr>
15611 <tr><th><a name="Concept-Index_cp_letter-H">H</a></th><td></td><td></td></tr>
15612 <tr><td></td><td valign="top"><a href="#index-history-builtins">history builtins</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-History-Builtins">Bash History Builtins</a></td></tr>
15613 <tr><td></td><td valign="top"><a href="#index-history-events">history events</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Event-Designators">Event Designators</a></td></tr>
15614 <tr><td></td><td valign="top"><a href="#index-history-expansion">history expansion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#History-Interaction">History Interaction</a></td></tr>
15615 <tr><td></td><td valign="top"><a href="#index-history-list">history list</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-History-Facilities">Bash History Facilities</a></td></tr>
15616 <tr><td></td><td valign="top"><a href="#index-History_002c-how-to-use">History, how to use</a>:</td><td>&nbsp;</td><td valign="top"><a href="#A-Programmable-Completion-Example">A Programmable Completion Example</a></td></tr>
15617 <tr><td colspan="4"> <hr></td></tr>
15618 <tr><th><a name="Concept-Index_cp_letter-I">I</a></th><td></td><td></td></tr>
15619 <tr><td></td><td valign="top"><a href="#index-identifier">identifier</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15620 <tr><td></td><td valign="top"><a href="#index-initialization-file_002c-readline">initialization file, readline</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File">Readline Init File</a></td></tr>
15621 <tr><td></td><td valign="top"><a href="#index-installation">installation</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-Installation">Basic Installation</a></td></tr>
15622 <tr><td></td><td valign="top"><a href="#index-interaction_002c-readline">interaction, readline</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Interaction">Readline Interaction</a></td></tr>
15623 <tr><td></td><td valign="top"><a href="#index-interactive-shell">interactive shell</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Invoking-Bash">Invoking Bash</a></td></tr>
15624 <tr><td></td><td valign="top"><a href="#index-interactive-shell-1">interactive shell</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interactive-Shells">Interactive Shells</a></td></tr>
15625 <tr><td></td><td valign="top"><a href="#index-internationalization">internationalization</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Locale-Translation">Locale Translation</a></td></tr>
15626 <tr><td colspan="4"> <hr></td></tr>
15627 <tr><th><a name="Concept-Index_cp_letter-J">J</a></th><td></td><td></td></tr>
15628 <tr><td></td><td valign="top"><a href="#index-job">job</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15629 <tr><td></td><td valign="top"><a href="#index-job-control">job control</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15630 <tr><td></td><td valign="top"><a href="#index-job-control-1">job control</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Job-Control-Basics">Job Control Basics</a></td></tr>
15631 <tr><td colspan="4"> <hr></td></tr>
15632 <tr><th><a name="Concept-Index_cp_letter-K">K</a></th><td></td><td></td></tr>
15633 <tr><td></td><td valign="top"><a href="#index-kill-ring">kill ring</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Killing-Commands">Readline Killing Commands</a></td></tr>
15634 <tr><td></td><td valign="top"><a href="#index-killing-text">killing text</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Killing-Commands">Readline Killing Commands</a></td></tr>
15635 <tr><td colspan="4"> <hr></td></tr>
15636 <tr><th><a name="Concept-Index_cp_letter-L">L</a></th><td></td><td></td></tr>
15637 <tr><td></td><td valign="top"><a href="#index-localization">localization</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Locale-Translation">Locale Translation</a></td></tr>
15638 <tr><td></td><td valign="top"><a href="#index-login-shell">login shell</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Invoking-Bash">Invoking Bash</a></td></tr>
15639 <tr><td colspan="4"> <hr></td></tr>
15640 <tr><th><a name="Concept-Index_cp_letter-M">M</a></th><td></td><td></td></tr>
15641 <tr><td></td><td valign="top"><a href="#index-matching_002c-pattern">matching, pattern</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pattern-Matching">Pattern Matching</a></td></tr>
15642 <tr><td></td><td valign="top"><a href="#index-metacharacter">metacharacter</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15643 <tr><td colspan="4"> <hr></td></tr>
15644 <tr><th><a name="Concept-Index_cp_letter-N">N</a></th><td></td><td></td></tr>
15645 <tr><td></td><td valign="top"><a href="#index-name">name</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15646 <tr><td></td><td valign="top"><a href="#index-native-languages">native languages</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Locale-Translation">Locale Translation</a></td></tr>
15647 <tr><td></td><td valign="top"><a href="#index-notation_002c-readline">notation, readline</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Bare-Essentials">Readline Bare Essentials</a></td></tr>
15648 <tr><td colspan="4"> <hr></td></tr>
15649 <tr><th><a name="Concept-Index_cp_letter-O">O</a></th><td></td><td></td></tr>
15650 <tr><td></td><td valign="top"><a href="#index-operator_002c-shell">operator, shell</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15651 <tr><td colspan="4"> <hr></td></tr>
15652 <tr><th><a name="Concept-Index_cp_letter-P">P</a></th><td></td><td></td></tr>
15653 <tr><td></td><td valign="top"><a href="#index-parameter-expansion">parameter expansion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a></td></tr>
15654 <tr><td></td><td valign="top"><a href="#index-parameters">parameters</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Parameters">Shell Parameters</a></td></tr>
15655 <tr><td></td><td valign="top"><a href="#index-parameters_002c-positional">parameters, positional</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Positional-Parameters">Positional Parameters</a></td></tr>
15656 <tr><td></td><td valign="top"><a href="#index-parameters_002c-special">parameters, special</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Parameters">Special Parameters</a></td></tr>
15657 <tr><td></td><td valign="top"><a href="#index-pathname-expansion">pathname expansion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Filename-Expansion">Filename Expansion</a></td></tr>
15658 <tr><td></td><td valign="top"><a href="#index-pattern-matching">pattern matching</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pattern-Matching">Pattern Matching</a></td></tr>
15659 <tr><td></td><td valign="top"><a href="#index-pipeline">pipeline</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Pipelines">Pipelines</a></td></tr>
15660 <tr><td></td><td valign="top"><a href="#index-POSIX">POSIX</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15661 <tr><td></td><td valign="top"><a href="#index-POSIX-Mode">POSIX Mode</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-POSIX-Mode">Bash POSIX Mode</a></td></tr>
15662 <tr><td></td><td valign="top"><a href="#index-process-group">process group</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15663 <tr><td></td><td valign="top"><a href="#index-process-group-ID">process group ID</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15664 <tr><td></td><td valign="top"><a href="#index-process-substitution">process substitution</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Process-Substitution">Process Substitution</a></td></tr>
15665 <tr><td></td><td valign="top"><a href="#index-programmable-completion">programmable completion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Programmable-Completion">Programmable Completion</a></td></tr>
15666 <tr><td></td><td valign="top"><a href="#index-prompting">prompting</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Controlling-the-Prompt">Controlling the Prompt</a></td></tr>
15667 <tr><td colspan="4"> <hr></td></tr>
15668 <tr><th><a name="Concept-Index_cp_letter-Q">Q</a></th><td></td><td></td></tr>
15669 <tr><td></td><td valign="top"><a href="#index-quoting">quoting</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Quoting">Quoting</a></td></tr>
15670 <tr><td></td><td valign="top"><a href="#index-quoting_002c-ANSI">quoting, ANSI</a>:</td><td>&nbsp;</td><td valign="top"><a href="#ANSI_002dC-Quoting">ANSI-C Quoting</a></td></tr>
15671 <tr><td colspan="4"> <hr></td></tr>
15672 <tr><th><a name="Concept-Index_cp_letter-R">R</a></th><td></td><td></td></tr>
15673 <tr><td></td><td valign="top"><a href="#index-Readline_002c-how-to-use">Readline, how to use</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Job-Control-Variables">Job Control Variables</a></td></tr>
15674 <tr><td></td><td valign="top"><a href="#index-redirection">redirection</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Redirections">Redirections</a></td></tr>
15675 <tr><td></td><td valign="top"><a href="#index-reserved-word">reserved word</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15676 <tr><td></td><td valign="top"><a href="#index-restricted-shell">restricted shell</a>:</td><td>&nbsp;</td><td valign="top"><a href="#The-Restricted-Shell">The Restricted Shell</a></td></tr>
15677 <tr><td></td><td valign="top"><a href="#index-return-status">return status</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15678 <tr><td colspan="4"> <hr></td></tr>
15679 <tr><th><a name="Concept-Index_cp_letter-S">S</a></th><td></td><td></td></tr>
15680 <tr><td></td><td valign="top"><a href="#index-shell-arithmetic">shell arithmetic</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Arithmetic">Shell Arithmetic</a></td></tr>
15681 <tr><td></td><td valign="top"><a href="#index-shell-function">shell function</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Functions">Shell Functions</a></td></tr>
15682 <tr><td></td><td valign="top"><a href="#index-shell-script">shell script</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Scripts">Shell Scripts</a></td></tr>
15683 <tr><td></td><td valign="top"><a href="#index-shell-variable">shell variable</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Parameters">Shell Parameters</a></td></tr>
15684 <tr><td></td><td valign="top"><a href="#index-shell_002c-interactive">shell, interactive</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Interactive-Shells">Interactive Shells</a></td></tr>
15685 <tr><td></td><td valign="top"><a href="#index-signal">signal</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15686 <tr><td></td><td valign="top"><a href="#index-signal-handling">signal handling</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Signals">Signals</a></td></tr>
15687 <tr><td></td><td valign="top"><a href="#index-special-builtin">special builtin</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15688 <tr><td></td><td valign="top"><a href="#index-special-builtin-1">special builtin</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Special-Builtins">Special Builtins</a></td></tr>
15689 <tr><td></td><td valign="top"><a href="#index-startup-files">startup files</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bash-Startup-Files">Bash Startup Files</a></td></tr>
15690 <tr><td></td><td valign="top"><a href="#index-suspending-jobs">suspending jobs</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Job-Control-Basics">Job Control Basics</a></td></tr>
15691 <tr><td colspan="4"> <hr></td></tr>
15692 <tr><th><a name="Concept-Index_cp_letter-T">T</a></th><td></td><td></td></tr>
15693 <tr><td></td><td valign="top"><a href="#index-tilde-expansion">tilde expansion</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Tilde-Expansion">Tilde Expansion</a></td></tr>
15694 <tr><td></td><td valign="top"><a href="#index-token">token</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15695 <tr><td></td><td valign="top"><a href="#index-translation_002c-native-languages">translation, native languages</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Locale-Translation">Locale Translation</a></td></tr>
15696 <tr><td colspan="4"> <hr></td></tr>
15697 <tr><th><a name="Concept-Index_cp_letter-V">V</a></th><td></td><td></td></tr>
15698 <tr><td></td><td valign="top"><a href="#index-variable_002c-shell">variable, shell</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Shell-Parameters">Shell Parameters</a></td></tr>
15699 <tr><td></td><td valign="top"><a href="#index-variables_002c-readline">variables, readline</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
15700 <tr><td colspan="4"> <hr></td></tr>
15701 <tr><th><a name="Concept-Index_cp_letter-W">W</a></th><td></td><td></td></tr>
15702 <tr><td></td><td valign="top"><a href="#index-word">word</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Definitions">Definitions</a></td></tr>
15703 <tr><td></td><td valign="top"><a href="#index-word-splitting">word splitting</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Word-Splitting">Word Splitting</a></td></tr>
15704 <tr><td colspan="4"> <hr></td></tr>
15705 <tr><th><a name="Concept-Index_cp_letter-Y">Y</a></th><td></td><td></td></tr>
15706 <tr><td></td><td valign="top"><a href="#index-yanking-text">yanking text</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Readline-Killing-Commands">Readline Killing Commands</a></td></tr>
15707 <tr><td colspan="4"> <hr></td></tr>
15708 </table>
15709 <table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Concept-Index_cp_letter-A"><b>A</b></a>
15710 &nbsp;
15711 <a class="summary-letter" href="#Concept-Index_cp_letter-B"><b>B</b></a>
15712 &nbsp;
15713 <a class="summary-letter" href="#Concept-Index_cp_letter-C"><b>C</b></a>
15714 &nbsp;
15715 <a class="summary-letter" href="#Concept-Index_cp_letter-D"><b>D</b></a>
15716 &nbsp;
15717 <a class="summary-letter" href="#Concept-Index_cp_letter-E"><b>E</b></a>
15718 &nbsp;
15719 <a class="summary-letter" href="#Concept-Index_cp_letter-F"><b>F</b></a>
15720 &nbsp;
15721 <a class="summary-letter" href="#Concept-Index_cp_letter-H"><b>H</b></a>
15722 &nbsp;
15723 <a class="summary-letter" href="#Concept-Index_cp_letter-I"><b>I</b></a>
15724 &nbsp;
15725 <a class="summary-letter" href="#Concept-Index_cp_letter-J"><b>J</b></a>
15726 &nbsp;
15727 <a class="summary-letter" href="#Concept-Index_cp_letter-K"><b>K</b></a>
15728 &nbsp;
15729 <a class="summary-letter" href="#Concept-Index_cp_letter-L"><b>L</b></a>
15730 &nbsp;
15731 <a class="summary-letter" href="#Concept-Index_cp_letter-M"><b>M</b></a>
15732 &nbsp;
15733 <a class="summary-letter" href="#Concept-Index_cp_letter-N"><b>N</b></a>
15734 &nbsp;
15735 <a class="summary-letter" href="#Concept-Index_cp_letter-O"><b>O</b></a>
15736 &nbsp;
15737 <a class="summary-letter" href="#Concept-Index_cp_letter-P"><b>P</b></a>
15738 &nbsp;
15739 <a class="summary-letter" href="#Concept-Index_cp_letter-Q"><b>Q</b></a>
15740 &nbsp;
15741 <a class="summary-letter" href="#Concept-Index_cp_letter-R"><b>R</b></a>
15742 &nbsp;
15743 <a class="summary-letter" href="#Concept-Index_cp_letter-S"><b>S</b></a>
15744 &nbsp;
15745 <a class="summary-letter" href="#Concept-Index_cp_letter-T"><b>T</b></a>
15746 &nbsp;
15747 <a class="summary-letter" href="#Concept-Index_cp_letter-V"><b>V</b></a>
15748 &nbsp;
15749 <a class="summary-letter" href="#Concept-Index_cp_letter-W"><b>W</b></a>
15750 &nbsp;
15751 <a class="summary-letter" href="#Concept-Index_cp_letter-Y"><b>Y</b></a>
15752 &nbsp;
15753 </td></tr></table>
15754
15755 <hr>
15756
15757
15758
15759 </body>
15760 </html>