]> git.ipfire.org Git - thirdparty/bash.git/blame - doc/bashref.html
bash-5.0-beta release
[thirdparty/bash.git] / doc / bashref.html
CommitLineData
a0c0a00f
CR
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
2f5dfe5a 4the Bash shell (version 5.0, 7 August 2018).
a0c0a00f 5
2f5dfe5a 6This is Edition 5.0, last updated 7 August 2018,
a0c0a00f 7of The GNU Bash Reference Manual,
9a51695b 8for Bash, Version 5.0.
a0c0a00f 9
9a51695b 10Copyright (C) 1988-2018 Free Software Foundation, Inc.
a0c0a00f
CR
11
12Permission is granted to copy, distribute and/or modify this document
13under the terms of the GNU Free Documentation License, Version 1.3 or
14any later version published by the Free Software Foundation; with no
15Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
16A copy of the license is included in the section entitled
17"GNU Free Documentation License". -->
9a51695b 18<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
a0c0a00f 19<head>
9a51695b 20<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
a0c0a00f
CR
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">
a0c0a00f
CR
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<!--
34a.summary-letter {text-decoration: none}
35blockquote.indentedblock {margin-right: 0em}
36blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
37blockquote.smallquotation {font-size: smaller}
38div.display {margin-left: 3.2em}
39div.example {margin-left: 3.2em}
40div.lisp {margin-left: 3.2em}
41div.smalldisplay {margin-left: 3.2em}
42div.smallexample {margin-left: 3.2em}
43div.smalllisp {margin-left: 3.2em}
44kbd {font-style: oblique}
45pre.display {font-family: inherit}
46pre.format {font-family: inherit}
47pre.menu-comment {font-family: serif}
48pre.menu-preformatted {font-family: serif}
49pre.smalldisplay {font-family: inherit; font-size: smaller}
50pre.smallexample {font-size: smaller}
51pre.smallformat {font-family: inherit; font-size: smaller}
52pre.smalllisp {font-size: smaller}
53span.nolinebreak {white-space: nowrap}
54span.roman {font-family: initial; font-weight: normal}
55span.sansserif {font-family: sans-serif; font-weight: normal}
56ul.no-bullet {list-style: none}
17345e5a 57-->
a0c0a00f
CR
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>
281Next: <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
2f5dfe5a 287the Bash shell (version 5.0, 7 August 2018).
a0c0a00f
CR
288The Bash home page is <a href="http://www.gnu.org/software/bash/">http://www.gnu.org/software/bash/</a>.
289</p>
2f5dfe5a 290<p>This is Edition 5.0, last updated 7 August 2018,
a0c0a00f 291of <cite>The GNU Bash Reference Manual</cite>,
9a51695b 292for <code>Bash</code>, Version 5.0.
a0c0a00f
CR
293</p>
294<p>Bash contains features that appear in other popular shells, and some
17345e5a 295features that only appear in Bash. Some of the shells that Bash has
a0c0a00f
CR
296borrowed 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
ac50fbac
CR
299categories, noting which features were inspired by other shells and
300which are specific to Bash.
a0c0a00f
CR
301</p>
302<p>This manual is meant as a brief introduction to features found in
17345e5a
JA
303Bash. The Bash manual page should be used as the definitive
304reference on shell behavior.
a0c0a00f
CR
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
17345e5a 333 between Bash and historical
a0c0a00f
CR
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>
346Next: <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>
361Next: <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,
367for the <small>GNU</small> operating system.
368The name is an acronym for the &lsquo;<samp>Bourne-Again SHell</samp>&rsquo;,
17345e5a 369a pun on Stephen Bourne, the author of the direct ancestor of
a0c0a00f 370the current Unix shell <code>sh</code>,
17345e5a
JA
371which appeared in the Seventh Edition Bell Labs Research version
372of Unix.
a0c0a00f
CR
373</p>
374<p>Bash is largely compatible with <code>sh</code> and incorporates useful
375features from the Korn shell <code>ksh</code> and the C shell <code>csh</code>.
376It 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>
378specification (<small>IEEE</small> Standard 1003.1).
379It offers functional improvements over <code>sh</code> for both interactive and
17345e5a 380programming use.
a0c0a00f
CR
381</p>
382<p>While the <small>GNU</small> operating system provides other shells, including
383a version of <code>csh</code>, Bash is the default shell.
384Like other <small>GNU</small> software, Bash is quite portable. It currently runs
17345e5a 385on nearly every version of Unix and a few other operating systems -
a0c0a00f 386independently-supported ports exist for <small>MS-DOS</small>, <small>OS/2</small>,
17345e5a 387and Windows platforms.
a0c0a00f
CR
388</p>
389<hr>
390<a name="What-is-a-shell_003f"></a>
391<div class="header">
392<p>
393Previous: <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
17345e5a
JA
399commands. The term macro processor means functionality where text
400and symbols are expanded to create larger expressions.
a0c0a00f
CR
401</p>
402<p>A Unix shell is both a command interpreter and a programming
17345e5a 403language. As a command interpreter, the shell provides the user
a0c0a00f 404interface to the rich set of <small>GNU</small> utilities. The programming
17345e5a
JA
405language features allow these utilities to be combined.
406Files containing commands can be created, and become
407commands themselves. These new commands have the same status as
a0c0a00f 408system commands in directories such as <samp>/bin</samp>, allowing users
17345e5a
JA
409or groups to establish custom environments to automate their common
410tasks.
a0c0a00f
CR
411</p>
412<p>Shells may be used interactively or non-interactively. In
17345e5a
JA
413interactive mode, they accept input typed from the keyboard.
414When executing non-interactively, shells execute commands read
415from a file.
a0c0a00f
CR
416</p>
417<p>A shell allows execution of <small>GNU</small> commands, both synchronously and
17345e5a
JA
418asynchronously.
419The shell waits for synchronous commands to complete before accepting
420more input; asynchronous commands continue to execute in parallel
421with the shell while it reads and executes additional commands.
a0c0a00f 422The <em>redirection</em> constructs permit
17345e5a 423fine-grained control of the input and output of those commands.
a0c0a00f 424Moreover, the shell allows control over the contents of commands&rsquo;
17345e5a 425environments.
a0c0a00f
CR
426</p>
427<p>Shells also provide a small set of built-in
428commands (<em>builtins</em>) implementing functionality impossible
17345e5a 429or inconvenient to obtain via separate utilities.
a0c0a00f
CR
430For example, <code>cd</code>, <code>break</code>, <code>continue</code>, and
431<code>exec</code> cannot be implemented outside of the shell because
17345e5a 432they directly manipulate the shell itself.
a0c0a00f 433The <code>history</code>, <code>getopts</code>, <code>kill</code>, or <code>pwd</code>
17345e5a
JA
434builtins, among others, could be implemented in separate utilities,
435but they are more convenient to use as builtin commands.
436All of the shell builtins are described in
437subsequent sections.
a0c0a00f
CR
438</p>
439<p>While executing commands is essential, most of the power (and
17345e5a
JA
440complexity) of shells is due to their embedded programming
441languages. Like any high-level language, the shell provides
442variables, flow control constructs, quoting, and functions.
a0c0a00f
CR
443</p>
444<p>Shells offer features geared specifically for
17345e5a
JA
445interactive use rather than to augment the programming language.
446These interactive features include job control, command line
447editing, command history and aliases. Each of these features is
448described in this manual.
a0c0a00f
CR
449</p>
450<hr>
451<a name="Definitions"></a>
452<div class="header">
453<p>
454Next: <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
17345e5a 464is primarily concerned with the Shell and Utilities portion of the
a0c0a00f
CR
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
17345e5a 475than by an executable program somewhere in the file system.
a0c0a00f
CR
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>
17345e5a 481or one of the following:
a0c0a00f
CR
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
17345e5a 489to eight bits, so the maximum value is 255.
a0c0a00f
CR
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
17345e5a
JA
495expansion, when executing a command, the resulting fields are used as
496the command name and arguments.
a0c0a00f
CR
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
17345e5a 507from it, that are all in the same process group.
a0c0a00f
CR
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
17345e5a 513(resume) execution of processes.
a0c0a00f
CR
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
519a <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,
528and beginning with a letter or underscore. <code>Name</code>s are used as
17345e5a 529shell variable and function names.
a0c0a00f
CR
530Also 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>.
536See <a href="#Redirections">Redirections</a>, for a list of redirection operators.
537Operators 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
543group <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>
17345e5a 549during its lifetime.
a0c0a00f
CR
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
555words 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
17345e5a 567of an event occurring in the system.
a0c0a00f
CR
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.
579It 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.
585Words 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>
593Next: <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;.
17345e5a
JA
600The Bourne shell is
601the traditional Unix shell originally written by Stephen Bourne.
602All of the Bourne shell builtin commands are available in Bash,
a0c0a00f
CR
603The rules for evaluation and quoting are taken from the <small>POSIX</small>
604specification for the &lsquo;standard&rsquo; Unix shell.
605</p>
606<p>This chapter briefly summarizes the shell&rsquo;s &lsquo;building blocks&rsquo;:
607commands, control structures, shell functions, shell <i>parameters</i>,
17345e5a 608shell expansions,
a0c0a00f 609<i>redirections</i>, which are a way to direct input and output from
17345e5a 610and to named files, and how the shell executes commands.
a0c0a00f
CR
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>
636Next: <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
17345e5a 650sequence of operations. If the input indicates the beginning of a
a0c0a00f 651comment, the shell ignores the comment symbol (&lsquo;<samp>#</samp>&rsquo;), and the rest
17345e5a 652of that line.
a0c0a00f
CR
653</p>
654<p>Otherwise, roughly speaking, the shell reads its input and
17345e5a
JA
655divides the input into words and operators, employing the quoting rules
656to select which meanings to assign various words and characters.
a0c0a00f
CR
657</p>
658<p>The shell then parses these tokens into commands and other constructs,
17345e5a
JA
659removes the special meaning of certain words or characters, expands
660others, redirects input and output as needed, executes the specified
a0c0a00f 661command, waits for the command&rsquo;s exit status, and makes that exit status
17345e5a 662available for further inspection or processing.
a0c0a00f
CR
663</p>
664<hr>
665<a name="Shell-Operation"></a>
666<div class="header">
667<p>
668Next: <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
17345e5a
JA
674reads and executes a command. Basically, the shell does the
675following:
a0c0a00f
CR
676</p>
677<ol>
678<li> Reads its input from a file (see <a href="#Shell-Scripts">Shell Scripts</a>), from a string
679supplied 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
683described 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
691the expanded tokens into lists of filenames (see <a href="#Filename-Expansion">Filename Expansion</a>)
17345e5a 692and commands and arguments.
17345e5a 693
a0c0a00f 694</li><li> Performs any necessary redirections (see <a href="#Redirections">Redirections</a>) and removes
17345e5a 695the redirection operators and their operands from the argument list.
a0c0a00f
CR
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
700status (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>
708Next: <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
17345e5a
JA
730characters or words to the shell. Quoting can be used to
731disable special treatment for special characters, to prevent
732reserved words from being recognized as such, and to prevent
733parameter expansion.
a0c0a00f
CR
734</p>
735<p>Each of the shell metacharacters (see <a href="#Definitions">Definitions</a>)
17345e5a
JA
736has special meaning to the shell and must be quoted if it is to
737represent itself.
738When the command history expansion facilities are being used
a0c0a00f
CR
739(see <a href="#History-Interaction">History Interaction</a>), the
740<var>history expansion</var> character, usually &lsquo;<samp>!</samp>&rsquo;, must be quoted
741to prevent history expansion. See <a href="#Bash-History-Facilities">Bash History Facilities</a>, for
17345e5a 742more details concerning history expansion.
a0c0a00f
CR
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>
751Next: <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.
17345e5a 756It preserves the literal value of the next character that follows,
a0c0a00f
CR
757with the exception of <code>newline</code>. If a <code>\newline</code> pair
758appears, and the backslash itself is not quoted, the <code>\newline</code>
17345e5a
JA
759is treated as a line continuation (that is, it is removed from
760the input stream and effectively ignored).
a0c0a00f
CR
761</p>
762<hr>
763<a name="Single-Quotes"></a>
764<div class="header">
765<p>
766Next: <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
17345e5a
JA
772of each character within the quotes. A single quote may not occur
773between single quotes, even when preceded by a backslash.
a0c0a00f
CR
774</p>
775<hr>
776<a name="Double-Quotes"></a>
777<div class="header">
778<p>
779Next: <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
17345e5a 785of all characters within the quotes, with the exception of
a0c0a00f
CR
786&lsquo;<samp>$</samp>&rsquo;, &lsquo;<samp>`</samp>&rsquo;, &lsquo;<samp>\</samp>&rsquo;,
787and, when history expansion is enabled, &lsquo;<samp>!</samp>&rsquo;.
788When the shell is in
789<small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>),
790the &lsquo;<samp>!</samp>&rsquo; has no special meaning
791within double quotes, even when history expansion is enabled.
792The characters &lsquo;<samp>$</samp>&rsquo; and &lsquo;<samp>`</samp>&rsquo;
793retain their special meaning within double quotes (see <a href="#Shell-Expansions">Shell Expansions</a>).
17345e5a
JA
794The backslash retains its special meaning only when followed by one of
795the following characters:
a0c0a00f 796&lsquo;<samp>$</samp>&rsquo;, &lsquo;<samp>`</samp>&rsquo;, &lsquo;<samp>&quot;</samp>&rsquo;, &lsquo;<samp>\</samp>&rsquo;, or <code>newline</code>.
17345e5a
JA
797Within double quotes, backslashes that are followed by one of these
798characters are removed. Backslashes preceding characters without a
799special meaning are left unmodified.
800A double quote may be quoted within double quotes by preceding it with
801a backslash.
a0c0a00f 802If enabled, history expansion will be performed unless an &lsquo;<samp>!</samp>&rsquo;
17345e5a 803appearing in double quotes is escaped using a backslash.
a0c0a00f
CR
804The 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
807when 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>
813Next: <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
820word expands to <var>string</var>, with backslash-escaped characters replaced
17345e5a
JA
821as specified by the ANSI C standard. Backslash escape sequences, if
822present, are decoded as follows:
a0c0a00f
CR
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>
9a51695b 864(one to three octal digits)
a0c0a00f
CR
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>
17345e5a 868(one or two hex digits)
a0c0a00f
CR
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
17345e5a 884been present.
a0c0a00f
CR
885</p>
886<hr>
887<a name="Locale-Translation"></a>
888<div class="header">
889<p>
890Previous: <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
17345e5a 900the string to be translated according to the current locale.
a0c0a00f 901If the current locale is <code>C</code> or <code>POSIX</code>, the dollar sign
17345e5a
JA
902is ignored.
903If the string is translated and replaced, the replacement is
904double-quoted.
a0c0a00f
CR
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>
17345e5a 910shell variable. Others create the name of the message catalog from the
a0c0a00f
CR
911value of the <code>TEXTDOMAIN</code> shell variable, possibly adding a
912suffix of &lsquo;<samp>.mo</samp>&rsquo;. If you use the <code>TEXTDOMAIN</code> variable, you
913may need to set the <code>TEXTDOMAINDIR</code> variable to the location of
17345e5a
JA
914the message catalog files. Still others use both variables in this
915fashion:
a0c0a00f
CR
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>
922Previous: <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>
930builtin is enabled (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>),
931a word beginning with &lsquo;<samp>#</samp>&rsquo;
17345e5a 932causes that word and all remaining characters on that line to
a0c0a00f
CR
933be ignored. An interactive shell without the <code>interactive_comments</code>
934option enabled does not allow comments. The <code>interactive_comments</code>
17345e5a 935option is on by default in interactive shells.
a0c0a00f 936See <a href="#Interactive-Shells">Interactive Shells</a>, for a description of what makes
17345e5a 937a shell interactive.
a0c0a00f
CR
938</p>
939<hr>
940<a name="Shell-Commands"></a>
941<div class="header">
942<p>
943Next: <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
17345e5a 950itself followed by arguments, separated by spaces.
a0c0a00f
CR
951</p>
952<p>More complex shell commands are composed of simple commands arranged together
17345e5a
JA
953in a variety of ways: in a pipeline in which the output of one command
954becomes the input of a second, in a loop or conditional construct, or in
955some other grouping.
a0c0a00f
CR
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>
977Next: <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.
984It&rsquo;s just a sequence of words separated by <code>blank</code>s, terminated
985by one of the shell&rsquo;s control operators (see <a href="#Definitions">Definitions</a>). The
17345e5a 986first word generally specifies a command to be executed, with the
a0c0a00f
CR
987rest 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
17345e5a 990its exit status as provided
a0c0a00f
CR
991by the <small>POSIX</small> 1003.1 <code>waitpid</code> function, or 128+<var>n</var> if
992the command was terminated by signal <var>n</var>.
993</p>
994<hr>
995<a name="Pipelines"></a>
996<div class="header">
997<p>
998Next: <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
1006one 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
17345e5a 1017to the input of the next command.
a0c0a00f 1018That is, each command reads the previous command&rsquo;s output. This
17345e5a
JA
1019connection is performed before any redirections specified by the
1020command.
a0c0a00f
CR
1021</p>
1022<p>If &lsquo;<samp>|&amp;</samp>&rsquo; is used, <var>command1</var>&rsquo;s standard error, in addition to
ac50fbac 1023its standard output, is connected to
a0c0a00f
CR
1024<var>command2</var>&rsquo;s standard input through the pipe;
1025it is shorthand for <code>2&gt;&amp;1 |</code>.
ac50fbac 1026This implicit redirection of the standard error to the standard output is
17345e5a 1027performed after any redirections specified by the command.
a0c0a00f
CR
1028</p>
1029<p>The reserved word <code>time</code> causes timing statistics
17345e5a
JA
1030to be printed for the pipeline once it finishes.
1031The statistics currently consist of elapsed (wall-clock) time and
a0c0a00f
CR
1032user and system time consumed by the command&rsquo;s execution.
1033The <samp>-p</samp> option changes the output format to that specified
1034by <small>POSIX</small>.
1035When the shell is in <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>),
1036it does not recognize <code>time</code> as a reserved word if the next
1037token begins with a &lsquo;<samp>-</samp>&rsquo;.
1038The <code>TIMEFORMAT</code> variable may be set to a format string that
17345e5a 1039specifies how the timing information should be displayed.
a0c0a00f
CR
1040See <a href="#Bash-Variables">Bash Variables</a>, for a description of the available formats.
1041The use of <code>time</code> as a reserved word permits the timing of
17345e5a 1042shell builtins, shell functions, and pipelines. An external
a0c0a00f
CR
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>
495aee44
CR
1046may be followed by a newline. In this case, the shell displays the
1047total user and system time consumed by the shell and its children.
a0c0a00f 1048The <code>TIMEFORMAT</code> variable may be used to specify the format of
495aee44 1049the time information.
a0c0a00f
CR
1050</p>
1051<p>If the pipeline is not executed asynchronously (see <a href="#Lists">Lists</a>), the
17345e5a 1052shell waits for all commands in the pipeline to complete.
a0c0a00f 1053</p>
9a51695b
CR
1054<p>Each command in a pipeline is executed in its own subshell, which is a
1055separate process (see <a href="#Command-Execution-Environment">Command Execution Environment</a>).
1056If the <code>lastpipe</code> option is enabled using the <code>shopt</code> builtin
1057(see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>),
1058the last element of a pipeline may be run by the shell process.
1059</p>
1060<p>The exit
17345e5a 1061status of a pipeline is the exit status of the last command in the
a0c0a00f
CR
1062pipeline, unless the <code>pipefail</code> option is enabled
1063(see <a href="#The-Set-Builtin">The Set Builtin</a>).
1064If <code>pipefail</code> is enabled, the pipeline&rsquo;s return status is the
17345e5a
JA
1065value of the last (rightmost) command to exit with a non-zero status,
1066or zero if all commands exit successfully.
a0c0a00f 1067If the reserved word &lsquo;<samp>!</samp>&rsquo; precedes the pipeline, the
17345e5a
JA
1068exit status is the logical negation of the exit status as described
1069above.
1070The shell waits for all commands in the pipeline to terminate before
1071returning a value.
a0c0a00f
CR
1072</p>
1073<hr>
1074<a name="Lists"></a>
1075<div class="header">
1076<p>
1077Next: <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
1084of the operators &lsquo;<samp>;</samp>&rsquo;, &lsquo;<samp>&amp;</samp>&rsquo;, &lsquo;<samp>&amp;&amp;</samp>&rsquo;, or &lsquo;<samp>||</samp>&rsquo;,
1085and 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;
1089have equal precedence, followed by &lsquo;<samp>;</samp>&rsquo; and &lsquo;<samp>&amp;</samp>&rsquo;,
17345e5a 1090which have equal precedence.
a0c0a00f
CR
1091</p>
1092<p>A sequence of one or more newlines may appear in a <code>list</code>
17345e5a 1093to delimit commands, equivalent to a semicolon.
a0c0a00f
CR
1094</p>
1095<p>If a command is terminated by the control operator &lsquo;<samp>&amp;</samp>&rsquo;,
17345e5a 1096the shell executes the command asynchronously in a subshell.
a0c0a00f 1097This is known as executing the command in the <var>background</var>.
17345e5a
JA
1098The shell does not wait for the command to finish, and the return
1099status is 0 (true).
a0c0a00f 1100When job control is not active (see <a href="#Job-Control">Job Control</a>),
17345e5a 1101the standard input for asynchronous commands, in the absence of any
a0c0a00f
CR
1102explicit redirections, is redirected from <code>/dev/null</code>.
1103</p>
1104<p>Commands separated by a &lsquo;<samp>;</samp>&rsquo; are executed sequentially; the shell
17345e5a
JA
1105waits for each command to terminate in turn. The return status is the
1106exit status of the last command executed.
a0c0a00f
CR
1107</p>
1108<p><small>AND</small> and <small>OR</small> lists are sequences of one or more pipelines
1109separated by the control operators &lsquo;<samp>&amp;&amp;</samp>&rsquo; and &lsquo;<samp>||</samp>&rsquo;,
1110respectively. <small>AND</small> and <small>OR</small> lists are executed with left
17345e5a 1111associativity.
a0c0a00f
CR
1112</p>
1113<p>An <small>AND</small> list has the form
1114</p><div class="example">
1115<pre class="example"><var>command1</var> &amp;&amp; <var>command2</var>
1116</pre></div>
17345e5a 1117
a0c0a00f 1118<p><var>command2</var> is executed if, and only if, <var>command1</var>
9a51695b 1119returns an exit status of zero (success).
a0c0a00f
CR
1120</p>
1121<p>An <small>OR</small> list has the form
1122</p><div class="example">
1123<pre class="example"><var>command1</var> || <var>command2</var>
1124</pre></div>
17345e5a 1125
a0c0a00f 1126<p><var>command2</var> is executed if, and only if, <var>command1</var>
17345e5a 1127returns a non-zero exit status.
a0c0a00f
CR
1128</p>
1129<p>The return status of
1130<small>AND</small> and <small>OR</small> lists is the exit status of the last command
17345e5a 1131executed in the list.
a0c0a00f
CR
1132</p>
1133<hr>
1134<a name="Compound-Commands"></a>
1135<div class="header">
1136<p>
1137Next: <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>
1138</div>
1139<a name="Compound-Commands-1"></a>
1140<h4 class="subsection">3.2.4 Compound Commands</h4>
1141<a name="index-commands_002c-compound"></a>
1142
1143<table class="menu" border="0" cellspacing="0">
1144<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.
1145</td></tr>
1146<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.
1147</td></tr>
1148<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.
1149</td></tr>
1150</table>
1151
9a51695b 1152<p>Compound commands are the shell programming language constructs.
17345e5a
JA
1153Each construct begins with a reserved word or control operator and is
1154terminated by a corresponding reserved word or operator.
a0c0a00f 1155Any redirections (see <a href="#Redirections">Redirections</a>) associated with a compound command
17345e5a 1156apply to all commands within that compound command unless explicitly overridden.
a0c0a00f
CR
1157</p>
1158<p>In most cases a list of commands in a compound command&rsquo;s description may be
ac50fbac
CR
1159separated from the rest of the command by one or more newlines, and may be
1160followed by a newline in place of a semicolon.
a0c0a00f
CR
1161</p>
1162<p>Bash provides looping constructs, conditional commands, and mechanisms
17345e5a 1163to group commands and execute them as a unit.
a0c0a00f
CR
1164</p>
1165<hr>
1166<a name="Looping-Constructs"></a>
1167<div class="header">
1168<p>
1169Next: <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>
1170</div>
1171<a name="Looping-Constructs-1"></a>
1172<h4 class="subsubsection">3.2.4.1 Looping Constructs</h4>
1173<a name="index-commands_002c-looping"></a>
1174
1175<p>Bash supports the following looping constructs.
1176</p>
1177<p>Note that wherever a &lsquo;<samp>;</samp>&rsquo; appears in the description of a
1178command&rsquo;s syntax, it may be replaced with one or more newlines.
1179</p>
1180<dl compact="compact">
1181<dt><code>until</code></dt>
1182<dd><a name="index-until"></a>
1183<a name="index-do"></a>
1184<a name="index-done"></a>
1185<p>The syntax of the <code>until</code> command is:
1186</p>
1187<div class="example">
1188<pre class="example">until <var>test-commands</var>; do <var>consequent-commands</var>; done
1189</pre></div>
1190
1191<p>Execute <var>consequent-commands</var> as long as
1192<var>test-commands</var> has an exit status which is not zero.
17345e5a 1193The return status is the exit status of the last command executed
a0c0a00f
CR
1194in <var>consequent-commands</var>, or zero if none was executed.
1195</p>
1196</dd>
1197<dt><code>while</code></dt>
1198<dd><a name="index-while"></a>
1199<p>The syntax of the <code>while</code> command is:
1200</p>
1201<div class="example">
1202<pre class="example">while <var>test-commands</var>; do <var>consequent-commands</var>; done
1203</pre></div>
1204
1205<p>Execute <var>consequent-commands</var> as long as
1206<var>test-commands</var> has an exit status of zero.
17345e5a 1207The return status is the exit status of the last command executed
a0c0a00f
CR
1208in <var>consequent-commands</var>, or zero if none was executed.
1209</p>
1210</dd>
1211<dt><code>for</code></dt>
1212<dd><a name="index-for"></a>
1213<p>The syntax of the <code>for</code> command is:
1214</p>
1215<div class="example">
1216<pre class="example">for <var>name</var> [ [in [<var>words</var> &hellip;] ] ; ] do <var>commands</var>; done
1217</pre></div>
1218
9a51695b
CR
1219<p>Expand <var>words</var> (see <a href="#Shell-Expansions">Shell Expansions</a>), and execute <var>commands</var>
1220once for each member
a0c0a00f
CR
1221in the resultant list, with <var>name</var> bound to the current member.
1222If &lsquo;<samp>in <var>words</var></samp>&rsquo; is not present, the <code>for</code> command
1223executes the <var>commands</var> once for each positional parameter that is
1224set, as if &lsquo;<samp>in &quot;$@&quot;</samp>&rsquo; had been specified
1225(see <a href="#Special-Parameters">Special Parameters</a>).
9a51695b
CR
1226</p>
1227<p>The return status is the exit status of the last command that executes.
a0c0a00f 1228If there are no items in the expansion of <var>words</var>, no commands are
17345e5a 1229executed, and the return status is zero.
a0c0a00f
CR
1230</p>
1231<p>An alternate form of the <code>for</code> command is also supported:
1232</p>
1233<div class="example">
1234<pre class="example">for (( <var>expr1</var> ; <var>expr2</var> ; <var>expr3</var> )) ; do <var>commands</var> ; done
1235</pre></div>
1236
1237<p>First, the arithmetic expression <var>expr1</var> is evaluated according
1238to the rules described below (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>).
1239The arithmetic expression <var>expr2</var> is then evaluated repeatedly
17345e5a 1240until it evaluates to zero.
a0c0a00f
CR
1241Each time <var>expr2</var> evaluates to a non-zero value, <var>commands</var> are
1242executed and the arithmetic expression <var>expr3</var> is evaluated.
17345e5a 1243If any expression is omitted, it behaves as if it evaluates to 1.
a0c0a00f 1244The return value is the exit status of the last command in <var>commands</var>
17345e5a 1245that is executed, or false if any of the expressions is invalid.
a0c0a00f
CR
1246</p></dd>
1247</dl>
17345e5a 1248
a0c0a00f 1249<p>The <code>break</code> and <code>continue</code> builtins (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>)
17345e5a 1250may be used to control loop execution.
a0c0a00f
CR
1251</p>
1252<hr>
1253<a name="Conditional-Constructs"></a>
1254<div class="header">
1255<p>
1256Next: <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>
1257</div>
1258<a name="Conditional-Constructs-1"></a>
1259<h4 class="subsubsection">3.2.4.2 Conditional Constructs</h4>
1260<a name="index-commands_002c-conditional"></a>
1261
1262<dl compact="compact">
1263<dt><code>if</code></dt>
1264<dd><a name="index-if"></a>
1265<a name="index-then"></a>
1266<a name="index-else"></a>
1267<a name="index-elif"></a>
1268<a name="index-fi"></a>
1269<p>The syntax of the <code>if</code> command is:
1270</p>
1271<div class="example">
1272<pre class="example">if <var>test-commands</var>; then
1273 <var>consequent-commands</var>;
1274[elif <var>more-test-commands</var>; then
1275 <var>more-consequents</var>;]
1276[else <var>alternate-consequents</var>;]
17345e5a 1277fi
a0c0a00f 1278</pre></div>
17345e5a 1279
a0c0a00f
CR
1280<p>The <var>test-commands</var> list is executed, and if its return status is zero,
1281the <var>consequent-commands</var> list is executed.
1282If <var>test-commands</var> returns a non-zero status, each <code>elif</code> list
17345e5a 1283is executed in turn, and if its exit status is zero,
a0c0a00f 1284the corresponding <var>more-consequents</var> is executed and the
17345e5a 1285command completes.
a0c0a00f
CR
1286If &lsquo;<samp>else <var>alternate-consequents</var></samp>&rsquo; is present, and
1287the final command in the final <code>if</code> or <code>elif</code> clause
1288has a non-zero exit status, then <var>alternate-consequents</var> is executed.
17345e5a
JA
1289The return status is the exit status of the last command executed, or
1290zero if no condition tested true.
a0c0a00f
CR
1291</p>
1292</dd>
1293<dt><code>case</code></dt>
1294<dd><a name="index-case"></a>
1295<a name="index-in"></a>
1296<a name="index-esac"></a>
1297<p>The syntax of the <code>case</code> command is:
1298</p>
1299<div class="example">
2f5dfe5a
CR
1300<pre class="example">case <var>word</var> in
1301 [ [(] <var>pattern</var> [| <var>pattern</var>]&hellip;) <var>command-list</var> ;;]&hellip;
1302esac
a0c0a00f
CR
1303</pre></div>
1304
1305<p><code>case</code> will selectively execute the <var>command-list</var> corresponding to
1306the first <var>pattern</var> that matches <var>word</var>.
9a51695b
CR
1307The match is performed according
1308to the rules described below in <a href="#Pattern-Matching">Pattern Matching</a>.
a0c0a00f
CR
1309If the <code>nocasematch</code> shell option
1310(see the description of <code>shopt</code> in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>)
17345e5a
JA
1311is enabled, the match is performed without regard to the case
1312of alphabetic characters.
a0c0a00f 1313The &lsquo;<samp>|</samp>&rsquo; is used to separate multiple patterns, and the &lsquo;<samp>)</samp>&rsquo;
17345e5a
JA
1314operator terminates a pattern list.
1315A list of patterns and an associated command-list is known
a0c0a00f
CR
1316as a <var>clause</var>.
1317</p>
1318<p>Each clause must be terminated with &lsquo;<samp>;;</samp>&rsquo;, &lsquo;<samp>;&amp;</samp>&rsquo;, or &lsquo;<samp>;;&amp;</samp>&rsquo;.
1319The <var>word</var> undergoes tilde expansion, parameter expansion, command
9a51695b
CR
1320substitution, arithmetic expansion, and quote removal
1321(see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>)
1322before matching is
a0c0a00f 1323attempted. Each <var>pattern</var> undergoes tilde expansion, parameter
17345e5a 1324expansion, command substitution, and arithmetic expansion.
a0c0a00f
CR
1325</p>
1326<p>There may be an arbitrary number of <code>case</code> clauses, each terminated
1327by a &lsquo;<samp>;;</samp>&rsquo;, &lsquo;<samp>;&amp;</samp>&rsquo;, or &lsquo;<samp>;;&amp;</samp>&rsquo;.
17345e5a
JA
1328The first pattern that matches determines the
1329command-list that is executed.
a0c0a00f 1330It&rsquo;s a common idiom to use &lsquo;<samp>*</samp>&rsquo; as the final pattern to define the
ac50fbac 1331default case, since that pattern will always match.
a0c0a00f
CR
1332</p>
1333<p>Here is an example using <code>case</code> in a script that could be used to
17345e5a 1334describe one interesting feature of an animal:
a0c0a00f
CR
1335</p>
1336<div class="example">
1337<pre class="example">echo -n &quot;Enter the name of an animal: &quot;
17345e5a 1338read ANIMAL
a0c0a00f 1339echo -n &quot;The $ANIMAL has &quot;
17345e5a 1340case $ANIMAL in
a0c0a00f
CR
1341 horse | dog | cat) echo -n &quot;four&quot;;;
1342 man | kangaroo ) echo -n &quot;two&quot;;;
1343 *) echo -n &quot;an unknown number of&quot;;;
17345e5a 1344esac
a0c0a00f
CR
1345echo &quot; legs.&quot;
1346</pre></div>
17345e5a 1347
17345e5a 1348
a0c0a00f 1349<p>If the &lsquo;<samp>;;</samp>&rsquo; operator is used, no subsequent matches are attempted after
17345e5a 1350the first pattern match.
a0c0a00f
CR
1351Using &lsquo;<samp>;&amp;</samp>&rsquo; in place of &lsquo;<samp>;;</samp>&rsquo; causes execution to continue with
1352the <var>command-list</var> associated with the next clause, if any.
1353Using &lsquo;<samp>;;&amp;</samp>&rsquo; in place of &lsquo;<samp>;;</samp>&rsquo; causes the shell to test the patterns
1354in the next clause, if any, and execute any associated <var>command-list</var>
17345e5a 1355on a successful match.
a0c0a00f
CR
1356</p>
1357<p>The return status is zero if no <var>pattern</var> is matched. Otherwise, the
1358return status is the exit status of the <var>command-list</var> executed.
1359</p>
1360</dd>
1361<dt><code>select</code></dt>
1362<dd><a name="index-select"></a>
1363
1364<p>The <code>select</code> construct allows the easy generation of menus.
1365It has almost the same syntax as the <code>for</code> command:
1366</p>
1367<div class="example">
1368<pre class="example">select <var>name</var> [in <var>words</var> &hellip;]; do <var>commands</var>; done
1369</pre></div>
1370
1371<p>The list of words following <code>in</code> is expanded, generating a list
17345e5a
JA
1372of items. The set of expanded words is printed on the standard
1373error output stream, each preceded by a number. If the
a0c0a00f
CR
1374&lsquo;<samp>in <var>words</var></samp>&rsquo; is omitted, the positional parameters are printed,
1375as if &lsquo;<samp>in &quot;$@&quot;</samp>&rsquo; had been specified.
1376The <code>PS3</code> prompt is then displayed and a line is read from the
17345e5a
JA
1377standard input.
1378If the line consists of a number corresponding to one of the displayed
a0c0a00f 1379words, then the value of <var>name</var> is set to that word.
17345e5a 1380If the line is empty, the words and prompt are displayed again.
a0c0a00f
CR
1381If <code>EOF</code> is read, the <code>select</code> command completes.
1382Any other value read causes <var>name</var> to be set to null.
1383The line read is saved in the variable <code>REPLY</code>.
1384</p>
1385<p>The <var>commands</var> are executed after each selection until a
1386<code>break</code> command is executed, at which
1387point the <code>select</code> command completes.
1388</p>
1389<p>Here is an example that allows the user to pick a filename from the
17345e5a
JA
1390current directory, and displays the name and index of the file
1391selected.
a0c0a00f
CR
1392</p>
1393<div class="example">
1394<pre class="example">select fname in *;
17345e5a
JA
1395do
1396 echo you picked $fname \($REPLY\)
1397 break;
1398done
a0c0a00f 1399</pre></div>
17345e5a 1400
a0c0a00f
CR
1401</dd>
1402<dt><code>((&hellip;))</code></dt>
1403<dd><div class="example">
1404<pre class="example">(( <var>expression</var> ))
1405</pre></div>
17345e5a 1406
a0c0a00f
CR
1407<p>The arithmetic <var>expression</var> is evaluated according to the rules
1408described below (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>).
17345e5a
JA
1409If the value of the expression is non-zero, the return status is 0;
1410otherwise the return status is 1. This is exactly equivalent to
a0c0a00f
CR
1411</p><div class="example">
1412<pre class="example">let &quot;<var>expression</var>&quot;
1413</pre></div>
1414<p>See <a href="#Bash-Builtins">Bash Builtins</a>, for a full description of the <code>let</code> builtin.
1415</p>
1416</dd>
1417<dt><code>[[&hellip;]]</code></dt>
1418<dd><a name="index-_005b_005b"></a>
1419<a name="index-_005d_005d"></a>
1420<div class="example">
1421<pre class="example">[[ <var>expression</var> ]]
1422</pre></div>
1423
1424<p>Return a status of 0 or 1 depending on the evaluation of
1425the conditional expression <var>expression</var>.
17345e5a 1426Expressions are composed of the primaries described below in
a0c0a00f 1427<a href="#Bash-Conditional-Expressions">Bash Conditional Expressions</a>.
17345e5a 1428Word splitting and filename expansion are not performed on the words
a0c0a00f 1429between the <code>[[</code> and <code>]]</code>; tilde expansion, parameter and
17345e5a
JA
1430variable expansion, arithmetic expansion, command substitution, process
1431substitution, and quote removal are performed.
a0c0a00f 1432Conditional operators such as &lsquo;<samp>-f</samp>&rsquo; must be unquoted to be recognized
17345e5a 1433as primaries.
a0c0a00f
CR
1434</p>
1435<p>When used with <code>[[</code>, the &lsquo;<samp>&lt;</samp>&rsquo; and &lsquo;<samp>&gt;</samp>&rsquo; operators sort
0001803f 1436lexicographically using the current locale.
a0c0a00f
CR
1437</p>
1438<p>When the &lsquo;<samp>==</samp>&rsquo; and &lsquo;<samp>!=</samp>&rsquo; operators are used, the string to the
17345e5a 1439right of the operator is considered a pattern and matched according
a0c0a00f
CR
1440to the rules described below in <a href="#Pattern-Matching">Pattern Matching</a>,
1441as if the <code>extglob</code> shell option were enabled.
1442The &lsquo;<samp>=</samp>&rsquo; operator is identical to &lsquo;<samp>==</samp>&rsquo;.
1443If the <code>nocasematch</code> shell option
1444(see the description of <code>shopt</code> in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>)
17345e5a
JA
1445is enabled, the match is performed without regard to the case
1446of alphabetic characters.
a0c0a00f 1447The return value is 0 if the string matches (&lsquo;<samp>==</samp>&rsquo;) or does not
2f5dfe5a 1448match (&lsquo;<samp>!=</samp>&rsquo;) the pattern, and 1 otherwise.
ac50fbac
CR
1449Any part of the pattern may be quoted to force the quoted portion
1450to be matched as a string.
a0c0a00f
CR
1451</p>
1452<p>An additional binary operator, &lsquo;<samp>=~</samp>&rsquo;, is available, with the same
1453precedence as &lsquo;<samp>==</samp>&rsquo; and &lsquo;<samp>!=</samp>&rsquo;.
17345e5a 1454When it is used, the string to the right of the operator is considered
2f5dfe5a
CR
1455a <small>POSIX</small> extended regular expression and matched accordingly
1456(as in <i>regex</i>3)).
17345e5a
JA
1457The return value is 0 if the string matches
1458the pattern, and 1 otherwise.
1459If the regular expression is syntactically incorrect, the conditional
a0c0a00f
CR
1460expression&rsquo;s return value is 2.
1461If the <code>nocasematch</code> shell option
1462(see the description of <code>shopt</code> in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>)
17345e5a
JA
1463is enabled, the match is performed without regard to the case
1464of alphabetic characters.
ac50fbac
CR
1465Any part of the pattern may be quoted to force the quoted portion
1466to be matched as a string.
1467Bracket expressions in regular expressions must be treated carefully,
1468since normal quoting characters lose their meanings between brackets.
1469If the pattern is stored in a shell variable, quoting the variable
1470expansion forces the entire pattern to be matched as a string.
17345e5a 1471Substrings matched by parenthesized subexpressions within the regular
a0c0a00f
CR
1472expression are saved in the array variable <code>BASH_REMATCH</code>.
1473The element of <code>BASH_REMATCH</code> with index 0 is the portion of the string
17345e5a 1474matching the entire regular expression.
a0c0a00f
CR
1475The element of <code>BASH_REMATCH</code> with index <var>n</var> is the portion of the
1476string matching the <var>n</var>th parenthesized subexpression.
1477</p>
1478<p>For example, the following will match a line
1479(stored in the shell variable <var>line</var>)
ac50fbac
CR
1480if there is a sequence of characters in the value consisting of
1481any number, including zero, of
a0c0a00f
CR
1482space characters, zero or one instances of &lsquo;<samp>a</samp>&rsquo;, then a &lsquo;<samp>b</samp>&rsquo;:
1483</p><div class="example">
9a51695b 1484<pre class="example">[[ $line =~ [[:space:]]*?(a)b ]]
a0c0a00f
CR
1485</pre></div>
1486
1487<p>That means values like &lsquo;<samp>aab</samp>&rsquo; and &lsquo;<samp> aaaaaab</samp>&rsquo; will match, as
1488will a line containing a &lsquo;<samp>b</samp>&rsquo; anywhere in its value.
1489</p>
1490<p>Storing the regular expression in a shell variable is often a useful
ac50fbac
CR
1491way to avoid problems with quoting characters that are special to the
1492shell.
1493It is sometimes difficult to specify a regular expression literally
1494without using quotes, or to keep track of the quoting used by regular
a0c0a00f 1495expressions while paying attention to the shell&rsquo;s quote removal.
ac50fbac
CR
1496Using a shell variable to store the pattern decreases these problems.
1497For example, the following is equivalent to the above:
a0c0a00f 1498</p><div class="example">
9a51695b 1499<pre class="example">pattern='[[:space:]]*?(a)b'
ac50fbac 1500[[ $line =~ $pattern ]]
a0c0a00f 1501</pre></div>
ac50fbac 1502
a0c0a00f 1503<p>If you want to match a character that&rsquo;s special to the regular expression
ac50fbac 1504grammar, it has to be quoted to remove its special meaning.
a0c0a00f 1505This means that in the pattern &lsquo;<samp>xxx.txt</samp>&rsquo;, the &lsquo;<samp>.</samp>&rsquo; matches any
ac50fbac 1506character in the string (its usual regular expression meaning), but in the
a0c0a00f 1507pattern &lsquo;<samp>&quot;xxx.txt&quot;</samp>&rsquo; it can only match a literal &lsquo;<samp>.</samp>&rsquo;.
ac50fbac
CR
1508Shell programmers should take special care with backslashes, since backslashes
1509are used both by the shell and regular expressions to remove the special
1510meaning from the following character.
a0c0a00f
CR
1511The following two sets of commands are <em>not</em> equivalent:
1512</p><div class="example">
1513<pre class="example">pattern='\.'
ac50fbac
CR
1514
1515[[ . =~ $pattern ]]
1516[[ . =~ \. ]]
1517
a0c0a00f 1518[[ . =~ &quot;$pattern&quot; ]]
ac50fbac 1519[[ . =~ '\.' ]]
a0c0a00f 1520</pre></div>
ac50fbac 1521
a0c0a00f 1522<p>The first two matches will succeed, but the second two will not, because
ac50fbac
CR
1523in the second two the backslash will be part of the pattern to be matched.
1524In the first two examples, the backslash removes the special meaning from
a0c0a00f
CR
1525&lsquo;<samp>.</samp>&rsquo;, so the literal &lsquo;<samp>.</samp>&rsquo; matches.
1526If the string in the first examples were anything other than &lsquo;<samp>.</samp>&rsquo;, say
1527&lsquo;<samp>a</samp>&rsquo;, the pattern would not match, because the quoted &lsquo;<samp>.</samp>&rsquo; in the
ac50fbac 1528pattern loses its special meaning of matching any single character.
a0c0a00f
CR
1529</p>
1530<p>Expressions may be combined using the following operators, listed
17345e5a 1531in decreasing order of precedence:
a0c0a00f
CR
1532</p>
1533<dl compact="compact">
1534<dt><code>( <var>expression</var> )</code></dt>
1535<dd><p>Returns the value of <var>expression</var>.
17345e5a 1536This may be used to override the normal precedence of operators.
a0c0a00f
CR
1537</p>
1538</dd>
1539<dt><code>! <var>expression</var></code></dt>
1540<dd><p>True if <var>expression</var> is false.
1541</p>
1542</dd>
1543<dt><code><var>expression1</var> &amp;&amp; <var>expression2</var></code></dt>
1544<dd><p>True if both <var>expression1</var> and <var>expression2</var> are true.
1545</p>
1546</dd>
1547<dt><code><var>expression1</var> || <var>expression2</var></code></dt>
1548<dd><p>True if either <var>expression1</var> or <var>expression2</var> is true.
1549</p></dd>
1550</dl>
1551
1552<p>The <code>&amp;&amp;</code> and <code>||</code> operators do not evaluate <var>expression2</var> if the
1553value of <var>expression1</var> is sufficient to determine the return
17345e5a 1554value of the entire conditional expression.
a0c0a00f
CR
1555</p></dd>
1556</dl>
1557
1558<hr>
1559<a name="Command-Grouping"></a>
1560<div class="header">
1561<p>
1562Previous: <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>
1563</div>
1564<a name="Grouping-Commands"></a>
1565<h4 class="subsubsection">3.2.4.3 Grouping Commands</h4>
1566<a name="index-commands_002c-grouping"></a>
1567
1568<p>Bash provides two ways to group a list of commands to be executed
17345e5a
JA
1569as a unit. When commands are grouped, redirections may be applied
1570to the entire command list. For example, the output of all the
1571commands in the list may be redirected to a single stream.
a0c0a00f
CR
1572</p>
1573<dl compact="compact">
1574<dt><code>()</code></dt>
1575<dd><div class="example">
1576<pre class="example">( <var>list</var> )
1577</pre></div>
1578
1579<p>Placing a list of commands between parentheses causes a subshell
1580environment to be created (see <a href="#Command-Execution-Environment">Command Execution Environment</a>), and each
1581of the commands in <var>list</var> to be executed in that subshell. Since the
1582<var>list</var> is executed in a subshell, variable assignments do not remain in
17345e5a 1583effect after the subshell completes.
a0c0a00f
CR
1584</p>
1585</dd>
1586<dt><code>{}</code></dt>
1587<dd><a name="index-_007b"></a>
1588<a name="index-_007d"></a>
1589<div class="example">
1590<pre class="example">{ <var>list</var>; }
1591</pre></div>
1592
1593<p>Placing a list of commands between curly braces causes the list to
17345e5a 1594be executed in the current shell context. No subshell is created.
a0c0a00f
CR
1595The semicolon (or newline) following <var>list</var> is required.
1596</p></dd>
1597</dl>
17345e5a 1598
a0c0a00f 1599<p>In addition to the creation of a subshell, there is a subtle difference
17345e5a 1600between these two constructs due to historical reasons. The braces
a0c0a00f
CR
1601are <code>reserved words</code>, so they must be separated from the <var>list</var>
1602by <code>blank</code>s or other shell metacharacters.
1603The parentheses are <code>operators</code>, and are
17345e5a 1604recognized as separate tokens by the shell even if they are not separated
a0c0a00f
CR
1605from the <var>list</var> by whitespace.
1606</p>
1607<p>The exit status of both of these constructs is the exit status of
1608<var>list</var>.
1609</p>
1610<hr>
1611<a name="Coprocesses"></a>
1612<div class="header">
1613<p>
1614Next: <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>
1615</div>
1616<a name="Coprocesses-1"></a>
1617<h4 class="subsection">3.2.5 Coprocesses</h4>
1618<a name="index-coprocess"></a>
1619
1620<p>A <code>coprocess</code> is a shell command preceded by the <code>coproc</code>
17345e5a
JA
1621reserved word.
1622A coprocess is executed asynchronously in a subshell, as if the command
a0c0a00f 1623had been terminated with the &lsquo;<samp>&amp;</samp>&rsquo; control operator, with a two-way pipe
17345e5a 1624established between the executing shell and the coprocess.
a0c0a00f
CR
1625</p>
1626<p>The format for a coprocess is:
1627</p><div class="example">
1628<pre class="example">coproc [<var>NAME</var>] <var>command</var> [<var>redirections</var>]
1629</pre></div>
1630
1631<p>This creates a coprocess named <var>NAME</var>.
1632If <var>NAME</var> is not supplied, the default name is <var>COPROC</var>.
1633<var>NAME</var> must not be supplied if <var>command</var> is a simple
1634command (see <a href="#Simple-Commands">Simple Commands</a>); otherwise, it is interpreted as
17345e5a 1635the first word of the simple command.
a0c0a00f
CR
1636</p>
1637<p>When the coprocess is executed, the shell creates an array variable
1638(see <a href="#Arrays">Arrays</a>)
1639named <code>NAME</code> in the context of the executing shell.
1640The standard output of <var>command</var>
17345e5a 1641is connected via a pipe to a file descriptor in the executing shell,
a0c0a00f
CR
1642and that file descriptor is assigned to <code>NAME</code>[0].
1643The standard input of <var>command</var>
17345e5a 1644is connected via a pipe to a file descriptor in the executing shell,
a0c0a00f 1645and that file descriptor is assigned to <code>NAME</code>[1].
17345e5a 1646This pipe is established before any redirections specified by the
a0c0a00f 1647command (see <a href="#Redirections">Redirections</a>).
17345e5a
JA
1648The file descriptors can be utilized as arguments to shell commands
1649and redirections using standard word expansions.
9a51695b
CR
1650Other than those created to execute command and process substitutions,
1651the file descriptors are not available in subshells.
a0c0a00f
CR
1652</p>
1653<p>The process ID of the shell spawned to execute the coprocess is
1654available as the value of the variable <code>NAME</code>_PID.
1655The <code>wait</code>
17345e5a 1656builtin command may be used to wait for the coprocess to terminate.
a0c0a00f
CR
1657</p>
1658<p>Since the coprocess is created as an asynchronous command,
1659the <code>coproc</code> command always returns success.
1660The return status of a coprocess is the exit status of <var>command</var>.
1661</p>
1662<hr>
1663<a name="GNU-Parallel"></a>
1664<div class="header">
1665<p>
1666Previous: <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>
1667</div>
1668<a name="GNU-Parallel-1"></a>
1669<h4 class="subsection">3.2.6 GNU Parallel</h4>
1670
1671<p>There are ways to run commands in parallel that are not built into Bash.
ac50fbac 1672GNU Parallel is a tool to do just that.
a0c0a00f
CR
1673</p>
1674<p>GNU Parallel, as its name suggests, can be used to build and run commands
495aee44 1675in parallel. You may run the same command with different arguments, whether
ac50fbac
CR
1676they are filenames, usernames, hostnames, or lines read from files. GNU
1677Parallel provides shorthand references to many of the most common operations
1678(input lines, various portions of the input line, different ways to specify
a0c0a00f 1679the input source, and so on). Parallel can replace <code>xargs</code> or feed
ac50fbac 1680commands from its input sources to several different instances of Bash.
a0c0a00f
CR
1681</p>
1682<p>For a complete description, refer to the GNU Parallel documentation. A few
495aee44 1683examples should provide a brief introduction to its use.
a0c0a00f
CR
1684</p>
1685<p>For example, it is easy to replace <code>xargs</code> to gzip all html files in the
ac50fbac 1686current directory and its subdirectories:
a0c0a00f
CR
1687</p><div class="example">
1688<pre class="example">find . -type f -name '*.html' -print | parallel gzip
1689</pre></div>
1690<p>If you need to protect special characters such as newlines in file names,
1691use find&rsquo;s <samp>-print0</samp> option and parallel&rsquo;s <samp>-0</samp> option.
1692</p>
1693<p>You can use Parallel to move files from the current directory when the
1694number of files is too large to process with one <code>mv</code> invocation:
1695</p><div class="example">
1696<pre class="example">ls | parallel mv {} destdir
1697</pre></div>
1698
1699<p>As you can see, the {} is replaced with each line read from standard input.
1700While using <code>ls</code> will work in most instances, it is not sufficient to
ac50fbac
CR
1701deal with all filenames.
1702If you need to accommodate special characters in filenames, you can use
a0c0a00f
CR
1703</p>
1704<div class="example">
1705<pre class="example">find . -depth 1 \! -name '.*' -print0 | parallel -0 mv {} destdir
1706</pre></div>
1707
1708<p>as alluded to above.
1709</p>
1710<p>This will run as many <code>mv</code> commands as there are files in the current
ac50fbac 1711directory.
a0c0a00f
CR
1712You can emulate a parallel <code>xargs</code> by adding the <samp>-X</samp> option:
1713</p><div class="example">
1714<pre class="example">find . -depth 1 \! -name '.*' -print0 | parallel -0 -X mv {} destdir
1715</pre></div>
495aee44 1716
a0c0a00f 1717<p>GNU Parallel can replace certain common idioms that operate on lines read
ac50fbac 1718from a file (in this case, filenames listed one per line):
a0c0a00f
CR
1719</p><div class="example">
1720<pre class="example"> while IFS= read -r x; do
1721 do-something1 &quot;$x&quot; &quot;config-$x&quot;
1722 do-something2 &lt; &quot;$x&quot;
1723 done &lt; file | process-output
1724</pre></div>
1725
1726<p>with a more compact syntax reminiscent of lambdas:
1727</p><div class="example">
2f5dfe5a
CR
1728<pre class="example">cat list | parallel &quot;do-something1 {} config-{} ; do-something2 &lt; {}&quot; |
1729 process-output
a0c0a00f
CR
1730</pre></div>
1731
1732<p>Parallel provides a built-in mechanism to remove filename extensions, which
495aee44 1733lends itself to batch file transformations or renaming:
a0c0a00f
CR
1734</p><div class="example">
1735<pre class="example">ls *.gz | parallel -j+0 &quot;zcat {} | bzip2 &gt;{.}.bz2 &amp;&amp; rm {}&quot;
1736</pre></div>
1737<p>This will recompress all files in the current directory with names ending
ac50fbac 1738in .gz using bzip2, running one job per CPU (-j+0) in parallel.
a0c0a00f 1739(We use <code>ls</code> for brevity here; using <code>find</code> as above is more
ac50fbac
CR
1740robust in the face of filenames containing unexpected characters.)
1741Parallel can take arguments from the command line; the above can also be
1742written as
a0c0a00f
CR
1743</p>
1744<div class="example">
1745<pre class="example">parallel &quot;zcat {} | bzip2 &gt;{.}.bz2 &amp;&amp; rm {}&quot; ::: *.gz
1746</pre></div>
495aee44 1747
a0c0a00f 1748<p>If a command generates output, you may want to preserve the input order in
495aee44 1749the output. For instance, the following command
a0c0a00f 1750</p><div class="example">
2f5dfe5a
CR
1751<pre class="example">{
1752 echo foss.org.my ;
1753 echo debian.org ;
1754 echo freenetproject.org ;
1755} | parallel traceroute
a0c0a00f
CR
1756</pre></div>
1757<p>will display as output the traceroute invocation that finishes first.
1758Adding the <samp>-k</samp> option
1759</p><div class="example">
2f5dfe5a
CR
1760<pre class="example">{
1761 echo foss.org.my ;
1762 echo debian.org ;
1763 echo freenetproject.org ;
1764} | parallel -k traceroute
a0c0a00f
CR
1765</pre></div>
1766<p>will ensure that the output of <code>traceroute foss.org.my</code> is displayed first.
1767</p>
1768<p>Finally, Parallel can be used to run a sequence of shell commands in parallel,
1769similar to &lsquo;<samp>cat file | bash</samp>&rsquo;.
ac50fbac 1770It is not uncommon to take a list of filenames, create a series of shell
9a51695b 1771commands to operate on them, and feed that list of commands to a shell.
a0c0a00f 1772Parallel can speed this up. Assuming that <samp>file</samp> contains a list of
ac50fbac 1773shell commands, one per line,
a0c0a00f
CR
1774</p>
1775<div class="example">
1776<pre class="example">parallel -j 10 &lt; file
1777</pre></div>
ac50fbac 1778
a0c0a00f 1779<p>will evaluate the commands using the shell (since no explicit command is
ac50fbac 1780supplied as an argument), in blocks of ten shell jobs at a time.
a0c0a00f
CR
1781</p>
1782<hr>
1783<a name="Shell-Functions"></a>
1784<div class="header">
1785<p>
1786Next: <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>
1787</div>
1788<a name="Shell-Functions-1"></a>
1789<h3 class="section">3.3 Shell Functions</h3>
1790<a name="index-shell-function"></a>
1791<a name="index-functions_002c-shell"></a>
1792
1793<p>Shell functions are a way to group commands for later execution
17345e5a 1794using a single name for the group. They are executed just like
a0c0a00f 1795a &quot;regular&quot; command.
17345e5a
JA
1796When the name of a shell function is used as a simple command name,
1797the list of commands associated with that function name is executed.
1798Shell functions are executed in the current
1799shell context; no new process is created to interpret them.
a0c0a00f
CR
1800</p>
1801<p>Functions are declared using this syntax:
1802<a name="index-function"></a>
1803</p><div class="example">
1804<pre class="example"><var>name</var> () <var>compound-command</var> [ <var>redirections</var> ]
1805</pre></div>
1806
1807<p>or
1808</p>
1809<div class="example">
1810<pre class="example">function <var>name</var> [()] <var>compound-command</var> [ <var>redirections</var> ]
1811</pre></div>
1812
1813<p>This defines a shell function named <var>name</var>. The reserved
1814word <code>function</code> is optional.
1815If the <code>function</code> reserved
17345e5a 1816word is supplied, the parentheses are optional.
a0c0a00f
CR
1817The <var>body</var> of the function is the compound command
1818<var>compound-command</var> (see <a href="#Compound-Commands">Compound Commands</a>).
1819That command is usually a <var>list</var> enclosed between { and }, but
1820may be any compound command listed above,
1821with one exception: If the <code>function</code> reserved word is used, but the
1822parentheses are not supplied, the braces are required.
1823<var>compound-command</var> is executed whenever <var>name</var> is specified as the
17345e5a 1824name of a command.
a0c0a00f
CR
1825When the shell is in <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>),
1826<var>name</var> may not be the same as one of the special builtins
1827(see <a href="#Special-Builtins">Special Builtins</a>).
1828Any redirections (see <a href="#Redirections">Redirections</a>) associated with the shell function
17345e5a 1829are performed when the function is executed.
a0c0a00f
CR
1830</p>
1831<p>A function definition may be deleted using the <samp>-f</samp> option to the
1832<code>unset</code> builtin (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
1833</p>
1834<p>The exit status of a function definition is zero unless a syntax error
17345e5a
JA
1835occurs or a readonly function with the same name already exists.
1836When executed, the exit status of a function is the exit status of the
1837last command executed in the body.
a0c0a00f
CR
1838</p>
1839<p>Note that for historical reasons, in the most common usage the curly braces
17345e5a 1840that surround the body of the function must be separated from the body by
a0c0a00f 1841<code>blank</code>s or newlines.
17345e5a
JA
1842This is because the braces are reserved words and are only recognized
1843as such when they are separated from the command list
1844by whitespace or another shell metacharacter.
a0c0a00f
CR
1845Also, when using the braces, the <var>list</var> must be terminated by a semicolon,
1846a &lsquo;<samp>&amp;</samp>&rsquo;, or a newline.
1847</p>
1848<p>When a function is executed, the arguments to the
17345e5a 1849function become the positional parameters
a0c0a00f
CR
1850during its execution (see <a href="#Positional-Parameters">Positional Parameters</a>).
1851The special parameter &lsquo;<samp>#</samp>&rsquo; that expands to the number of
17345e5a 1852positional parameters is updated to reflect the change.
a0c0a00f
CR
1853Special parameter <code>0</code> is unchanged.
1854The first element of the <code>FUNCNAME</code> variable is set to the
17345e5a 1855name of the function while the function is executing.
a0c0a00f
CR
1856</p>
1857<p>All other aspects of the shell execution
17345e5a 1858environment are identical between a function and its caller
0001803f 1859with these exceptions:
a0c0a00f 1860the <code>DEBUG</code> and <code>RETURN</code> traps
17345e5a 1861are not inherited unless the function has been given the
a0c0a00f
CR
1862<code>trace</code> attribute using the <code>declare</code> builtin or
1863the <code>-o functrace</code> option has been enabled with
1864the <code>set</code> builtin,
1865(in which case all functions inherit the <code>DEBUG</code> and <code>RETURN</code> traps),
1866and the <code>ERR</code> trap is not inherited unless the <code>-o errtrace</code>
0001803f 1867shell option has been enabled.
a0c0a00f
CR
1868See <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>, for the description of the
1869<code>trap</code> builtin.
1870</p>
1871<p>The <code>FUNCNEST</code> variable, if set to a numeric value greater
495aee44
CR
1872than 0, defines a maximum function nesting level. Function
1873invocations that exceed the limit cause the entire command to
1874abort.
a0c0a00f
CR
1875</p>
1876<p>If the builtin command <code>return</code>
17345e5a
JA
1877is executed in a function, the function completes and
1878execution resumes with the next command after the function
1879call.
a0c0a00f 1880Any command associated with the <code>RETURN</code> trap is executed
17345e5a
JA
1881before execution resumes.
1882When a function completes, the values of the
a0c0a00f
CR
1883positional parameters and the special parameter &lsquo;<samp>#</samp>&rsquo;
1884are restored to the values they had prior to the function&rsquo;s
1885execution. If a numeric argument is given to <code>return</code>,
1886that is the function&rsquo;s return status; otherwise the function&rsquo;s
17345e5a 1887return status is the exit status of the last command executed
a0c0a00f
CR
1888before the <code>return</code>.
1889</p>
1890<p>Variables local to the function may be declared with the
1891<code>local</code> builtin. These variables are visible only to
9a51695b
CR
1892the function and the commands it invokes. This is particularly
1893important when a shell function calls other functions.
1894</p>
1895<p>Local variables &quot;shadow&quot; variables with the same name declared at
1896previous scopes. For instance, a local variable declared in a function
1897hides a global variable of the same name: references and assignments
1898refer to the local variable, leaving the global variable unmodified.
1899When the function returns, the global variable is once again visible.
1900</p>
1901<p>The shell uses <var>dynamic scoping</var> to control a variable&rsquo;s visibility
1902within functions.
1903With dynamic scoping, visible variables and their values
1904are a result of the sequence of function calls that caused execution
1905to reach the current function.
1906The value of a variable that a function sees depends
1907on its value within its caller, if any, whether that caller is
1908the &quot;global&quot; scope or another shell function.
1909This is also the value that a local variable
1910declaration &quot;shadows&quot;, and the value that is restored when the function
1911returns.
1912</p>
1913<p>For example, if a variable <var>var</var> is declared as local in function
1914<var>func1</var>, and <var>func1</var> calls another function <var>func2</var>,
1915references to <var>var</var> made from within <var>func2</var> will resolve to the
1916local variable <var>var</var> from <var>func1</var>, shadowing any global variable
1917named <var>var</var>.
1918</p>
1919<p>The following script demonstrates this behavior.
1920When executed, the script displays
1921</p>
1922<div class="example">
1923<pre class="example">In func2, var = func1 local
1924</pre></div>
1925
1926<div class="example">
1927<pre class="example">func1()
1928{
1929 local var='func1 local'
1930 func2
1931}
1932
1933func2()
1934{
1935 echo &quot;In func2, var = $var&quot;
1936}
1937
1938var=global
1939func1
1940</pre></div>
1941
1942<p>The <code>unset</code> builtin also acts using the same dynamic scope: if a
1943variable is local to the current scope, <code>unset</code> will unset it;
1944otherwise the unset will refer to the variable found in any calling scope
1945as described above.
1946If a variable at the current local scope is unset, it will remain so
1947until it is reset in that scope or until the function returns.
1948Once the function returns, any instance of the variable at a previous
1949scope will become visible.
1950If the unset acts on a variable at a previous scope, any instance of a
1951variable with that name that had been shadowed will become visible.
a0c0a00f
CR
1952</p>
1953<p>Function names and definitions may be listed with the
1954<samp>-f</samp> option to the <code>declare</code> (<code>typeset</code>)
1955builtin command (see <a href="#Bash-Builtins">Bash Builtins</a>).
1956The <samp>-F</samp> option to <code>declare</code> or <code>typeset</code>
17345e5a 1957will list the function names only
a0c0a00f 1958(and optionally the source file and line number, if the <code>extdebug</code>
17345e5a
JA
1959shell option is enabled).
1960Functions may be exported so that subshells
1961automatically have them defined with the
a0c0a00f
CR
1962<samp>-f</samp> option to the <code>export</code> builtin
1963(see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
a0c0a00f
CR
1964</p>
1965<p>Functions may be recursive.
1966The <code>FUNCNEST</code> variable may be used to limit the depth of the
495aee44
CR
1967function call stack and restrict the number of function invocations.
1968By default, no limit is placed on the number of recursive calls.
a0c0a00f
CR
1969</p>
1970<hr>
1971<a name="Shell-Parameters"></a>
1972<div class="header">
1973<p>
1974Next: <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>
1975</div>
1976<a name="Shell-Parameters-1"></a>
1977<h3 class="section">3.4 Shell Parameters</h3>
1978<a name="index-parameters"></a>
1979<a name="index-variable_002c-shell"></a>
1980<a name="index-shell-variable"></a>
1981
1982<table class="menu" border="0" cellspacing="0">
1983<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.
1984</td></tr>
1985<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.
1986</td></tr>
1987</table>
1988
1989<p>A <var>parameter</var> is an entity that stores values.
1990It can be a <code>name</code>, a number, or one of the special characters
17345e5a 1991listed below.
a0c0a00f
CR
1992A <var>variable</var> is a parameter denoted by a <code>name</code>.
1993A variable has a <var>value</var> and zero or more <var>attributes</var>.
1994Attributes are assigned using the <code>declare</code> builtin command
1995(see the description of the <code>declare</code> builtin in <a href="#Bash-Builtins">Bash Builtins</a>).
1996</p>
1997<p>A parameter is set if it has been assigned a value. The null string is
17345e5a 1998a valid value. Once a variable is set, it may be unset only by using
a0c0a00f
CR
1999the <code>unset</code> builtin command.
2000</p>
2001<p>A variable may be assigned to by a statement of the form
2002</p><div class="example">
2003<pre class="example"><var>name</var>=[<var>value</var>]
2004</pre></div>
2005<p>If <var>value</var>
17345e5a 2006is not given, the variable is assigned the null string. All
a0c0a00f 2007<var>value</var>s undergo tilde expansion, parameter and variable expansion,
17345e5a 2008command substitution, arithmetic expansion, and quote
a0c0a00f
CR
2009removal (detailed below). If the variable has its <code>integer</code>
2010attribute set, then <var>value</var>
2011is evaluated as an arithmetic expression even if the <code>$((&hellip;))</code>
2012expansion is not used (see <a href="#Arithmetic-Expansion">Arithmetic Expansion</a>).
17345e5a 2013Word splitting is not performed, with the exception
a0c0a00f 2014of <code>&quot;$@&quot;</code> as explained below.
17345e5a
JA
2015Filename expansion is not performed.
2016Assignment statements may also appear as arguments to the
a0c0a00f
CR
2017<code>alias</code>,
2018<code>declare</code>, <code>typeset</code>, <code>export</code>, <code>readonly</code>,
2019and <code>local</code> builtin commands (<var>declaration</var> commands).
2020When in <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>), these builtins may appear
2021in a command after one or more instances of the <code>command</code> builtin
ac50fbac 2022and retain these assignment statement properties.
a0c0a00f
CR
2023</p>
2024<p>In the context where an assignment statement is assigning a value
2025to a shell variable or array index (see <a href="#Arrays">Arrays</a>), the &lsquo;<samp>+=</samp>&rsquo;
17345e5a 2026operator can be used to
a0c0a00f
CR
2027append to or add to the variable&rsquo;s previous value.
2028This includes arguments to builtin commands such as <code>declare</code> that
2029accept assignment statements (<var>declaration</var> commands).
2030When &lsquo;<samp>+=</samp>&rsquo; is applied to a variable for which the <var>integer</var> attribute
2031has been set, <var>value</var> is evaluated as an arithmetic expression and
2032added to the variable&rsquo;s current value, which is also evaluated.
2033When &lsquo;<samp>+=</samp>&rsquo; is applied to an array variable using compound assignment
2034(see <a href="#Arrays">Arrays</a>), the
2035variable&rsquo;s value is not unset (as it is when using &lsquo;<samp>=</samp>&rsquo;), and new
2036values are appended to the array beginning at one greater than the array&rsquo;s
17345e5a
JA
2037maximum index (for indexed arrays), or added as additional key-value pairs
2038in an associative array.
a0c0a00f
CR
2039When applied to a string-valued variable, <var>value</var> is expanded and
2040appended to the variable&rsquo;s value.
2041</p>
2042<p>A variable can be assigned the <var>nameref</var> attribute using the
2043<samp>-n</samp> option to the <code>declare</code> or <code>local</code> builtin commands
2044(see <a href="#Bash-Builtins">Bash Builtins</a>)
2045to create a <var>nameref</var>, or a reference to another variable.
ac50fbac 2046This allows variables to be manipulated indirectly.
a0c0a00f
CR
2047Whenever the nameref variable is referenced, assigned to, unset, or has
2048its attributes modified (other than using or changing the nameref
2049attribute itself), the
2050operation is actually performed on the variable specified by the nameref
2051variable&rsquo;s value.
ac50fbac
CR
2052A nameref is commonly used within shell functions to refer to a variable
2053whose name is passed as an argument to the function.
2054For instance, if a variable name is passed to a shell function as its first
2055argument, running
a0c0a00f
CR
2056</p><div class="example">
2057<pre class="example">declare -n ref=$1
2058</pre></div>
2059<p>inside the function creates a nameref variable <var>ref</var> whose value is
ac50fbac 2060the variable name passed as the first argument.
a0c0a00f
CR
2061References and assignments to <var>ref</var>, and changes to its attributes,
2062are treated as references, assignments, and attribute modifications
2063to the variable whose name was passed as <code>$1</code>.
2064</p>
2065<p>If the control variable in a <code>for</code> loop has the nameref attribute,
ac50fbac
CR
2066the list of words can be a list of shell variables, and a name reference
2067will be established for each word in the list, in turn, when the loop is
2068executed.
a0c0a00f 2069Array variables cannot be given the nameref attribute.
ac50fbac
CR
2070However, nameref variables can reference array variables and subscripted
2071array variables.
a0c0a00f
CR
2072Namerefs can be unset using the <samp>-n</samp> option to the <code>unset</code> builtin
2073(see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
2074Otherwise, if <code>unset</code> is executed with the name of a nameref variable
ac50fbac 2075as an argument, the variable referenced by the nameref variable will be unset.
a0c0a00f
CR
2076</p>
2077<hr>
2078<a name="Positional-Parameters"></a>
2079<div class="header">
2080<p>
2081Next: <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>
2082</div>
2083<a name="Positional-Parameters-1"></a>
2084<h4 class="subsection">3.4.1 Positional Parameters</h4>
2085<a name="index-parameters_002c-positional"></a>
2086
2087<p>A <var>positional parameter</var> is a parameter denoted by one or more
2088digits, other than the single digit <code>0</code>. Positional parameters are
2089assigned from the shell&rsquo;s arguments when it is invoked,
2090and may be reassigned using the <code>set</code> builtin command.
2091Positional parameter <code>N</code> may be referenced as <code>${N}</code>, or
2092as <code>$N</code> when <code>N</code> consists of a single digit.
17345e5a 2093Positional parameters may not be assigned to with assignment statements.
a0c0a00f
CR
2094The <code>set</code> and <code>shift</code> builtins are used to set and
2095unset them (see <a href="#Shell-Builtin-Commands">Shell Builtin Commands</a>).
17345e5a
JA
2096The positional parameters are
2097temporarily replaced when a shell function is executed
a0c0a00f
CR
2098(see <a href="#Shell-Functions">Shell Functions</a>).
2099</p>
2100<p>When a positional parameter consisting of more than a single
17345e5a 2101digit is expanded, it must be enclosed in braces.
a0c0a00f
CR
2102</p>
2103<hr>
2104<a name="Special-Parameters"></a>
2105<div class="header">
2106<p>
2107Previous: <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>
2108</div>
2109<a name="Special-Parameters-1"></a>
2110<h4 class="subsection">3.4.2 Special Parameters</h4>
2111<a name="index-parameters_002c-special"></a>
2112
2113<p>The shell treats several parameters specially. These parameters may
17345e5a 2114only be referenced; assignment to them is not allowed.
a0c0a00f
CR
2115</p>
2116<dl compact="compact">
2117<dt><code>*</code>
2118<a name="index-_002a"></a>
2119</dt>
2120<dd><a name="index-_0024_002a"></a>
2121<p>($*) Expands to the positional parameters, starting from one.
ac50fbac
CR
2122When the expansion is not within double quotes, each positional parameter
2123expands to a separate word.
2124In contexts where it is performed, those words
2125are subject to further word splitting and pathname expansion.
2126When the expansion occurs within double quotes, it expands to a single word
a0c0a00f
CR
2127with the value of each parameter separated by the first character of the
2128<code>IFS</code> special variable. That is, <code>&quot;$*&quot;</code> is equivalent
2129to <code>&quot;$1<var>c</var>$2<var>c</var>&hellip;&quot;</code>, where <var>c</var>
2130is the first character of the value of the <code>IFS</code>
17345e5a 2131variable.
a0c0a00f
CR
2132If <code>IFS</code> is unset, the parameters are separated by spaces.
2133If <code>IFS</code> is null, the parameters are joined without intervening
17345e5a 2134separators.
a0c0a00f
CR
2135</p>
2136</dd>
2137<dt><code>@</code>
2138<a name="index-_0040"></a>
2139</dt>
2140<dd><a name="index-_0024_0040"></a>
2f5dfe5a
CR
2141<p>($@) Expands to the positional parameters, starting from one.
2142In contexts where word splitting is performed, this expands each
2143positional parameter to a separate word; if not within double
2144quotes, these words are subject to word splitting.
2145In contexts where word splitting is not performed,
2146this expands to a single word
2147with each positional parameter separated by a space.
2148When the
2149expansion occurs within double quotes, and word splitting is performed,
2150each parameter expands to a
a0c0a00f
CR
2151separate word. That is, <code>&quot;$@&quot;</code> is equivalent to
2152<code>&quot;$1&quot; &quot;$2&quot; &hellip;</code>.
17345e5a
JA
2153If the double-quoted expansion occurs within a word, the expansion of
2154the first parameter is joined with the beginning part of the original
2155word, and the expansion of the last parameter is joined with the last
2156part of the original word.
a0c0a00f
CR
2157When there are no positional parameters, <code>&quot;$@&quot;</code> and
2158<code>$@</code>
17345e5a 2159expand to nothing (i.e., they are removed).
a0c0a00f
CR
2160</p>
2161</dd>
2162<dt><code>#</code>
2163<a name="index-_0023"></a>
2164</dt>
2165<dd><a name="index-_0024_0023"></a>
2166<p>($#) Expands to the number of positional parameters in decimal.
2167</p>
2168</dd>
2169<dt><code>?</code>
2170<a name="index-_003f"></a>
2171</dt>
2172<dd><a name="index-_0024_003f"></a>
2173<p>($?) Expands to the exit status of the most recently executed foreground
17345e5a 2174pipeline.
a0c0a00f
CR
2175</p>
2176</dd>
2177<dt><code>-</code>
2178<a name="index-_002d"></a>
2179</dt>
2180<dd><a name="index-_0024_002d"></a>
2181<p>($-, a hyphen.) Expands to the current option flags as specified upon
2182invocation, by the <code>set</code>
17345e5a 2183builtin command, or those set by the shell itself
a0c0a00f
CR
2184(such as the <samp>-i</samp> option).
2185</p>
2186</dd>
2187<dt><code>$</code>
2188<a name="index-_0024"></a>
2189</dt>
2190<dd><a name="index-_0024_0024"></a>
2191<p>($$) Expands to the process <small>ID</small> of the shell. In a <code>()</code> subshell, it
2192expands to the process <small>ID</small> of the invoking shell, not the subshell.
2193</p>
2194</dd>
2195<dt><code>!</code>
2196<a name="index-_0021-1"></a>
2197</dt>
2198<dd><a name="index-_0024_0021"></a>
2199<p>($!) Expands to the process <small>ID</small> of the job most recently placed into the
ac50fbac 2200background, whether executed as an asynchronous command or using
a0c0a00f
CR
2201the <code>bg</code> builtin (see <a href="#Job-Control-Builtins">Job Control Builtins</a>).
2202</p>
2203</dd>
2204<dt><code>0</code>
2205<a name="index-0"></a>
2206</dt>
2207<dd><a name="index-_00240"></a>
2208<p>($0) Expands to the name of the shell or shell script. This is set at
17345e5a 2209shell initialization. If Bash is invoked with a file of commands
a0c0a00f
CR
2210(see <a href="#Shell-Scripts">Shell Scripts</a>), <code>$0</code> is set to the name of that file.
2211If Bash is started with the <samp>-c</samp> option (see <a href="#Invoking-Bash">Invoking Bash</a>),
2212then <code>$0</code> is set to the first argument after the string to be
17345e5a
JA
2213executed, if one is present. Otherwise, it is set
2214to the filename used to invoke Bash, as given by argument zero.
a0c0a00f
CR
2215</p>
2216</dd>
2217<dt><code>_</code>
2218<a name="index-_005f"></a>
2219</dt>
2220<dd><a name="index-_0024_005f"></a>
2221<p>($_, an underscore.)
17345e5a
JA
2222At shell startup, set to the absolute pathname used to invoke the
2223shell or shell script being executed as passed in the environment
2224or argument list.
2225Subsequently, expands to the last argument to the previous command,
2226after expansion.
2227Also set to the full pathname used to invoke each command executed
2228and placed in the environment exported to that command.
2229When checking mail, this parameter holds the name of the mail file.
a0c0a00f
CR
2230</p></dd>
2231</dl>
2232
2233<hr>
2234<a name="Shell-Expansions"></a>
2235<div class="header">
2236<p>
2237Next: <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>
2238</div>
2239<a name="Shell-Expansions-1"></a>
2240<h3 class="section">3.5 Shell Expansions</h3>
2241<a name="index-expansion"></a>
2242
2243<p>Expansion is performed on the command line after it has been split into
2244<code>token</code>s. There are seven kinds of expansion performed:
2245</p>
2246<ul>
2247<li> brace expansion
2248</li><li> tilde expansion
2249</li><li> parameter and variable expansion
2250</li><li> command substitution
2251</li><li> arithmetic expansion
2252</li><li> word splitting
2253</li><li> filename expansion
2254</li></ul>
2255
2256<table class="menu" border="0" cellspacing="0">
2257<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.
2258</td></tr>
2259<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.
2260</td></tr>
2261<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.
2262</td></tr>
2263<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.
2264</td></tr>
2265<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.
2266</td></tr>
2267<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
2268 command.
2269</td></tr>
2270<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
2271 arguments.
2272</td></tr>
2273<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.
2274</td></tr>
2275<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
2276 words.
2277</td></tr>
2278</table>
2279
2280<p>The order of expansions is:
ac50fbac
CR
2281brace expansion;
2282tilde expansion, parameter and variable expansion, arithmetic expansion,
2283and command substitution (done in a left-to-right fashion);
2284word splitting;
2285and filename expansion.
a0c0a00f
CR
2286</p>
2287<p>On systems that can support it, there is an additional expansion
2288available: <var>process substitution</var>.
ac50fbac
CR
2289This is performed at the
2290same time as tilde, parameter, variable, and arithmetic expansion and
17345e5a 2291command substitution.
a0c0a00f
CR
2292</p>
2293<p>After these expansions are performed, quote characters present in the
2294original word are removed unless they have been quoted themselves
2295(<var>quote removal</var>).
2296</p>
2297<p>Only brace expansion, word splitting, and filename expansion
9a51695b 2298can increase the number of words of the expansion; other expansions
17345e5a
JA
2299expand a single word to a single word.
2300The only exceptions to this are the expansions of
9a51695b
CR
2301<code>&quot;$@&quot;</code> and <code>$*</code> (see <a href="#Special-Parameters">Special Parameters</a>), and
2302<code>&quot;${<var>name</var>[@]}&quot;</code> and <code>${<var>name</var>[*]}</code>
a0c0a00f
CR
2303(see <a href="#Arrays">Arrays</a>).
2304</p>
2305<p>After all expansions, <code>quote removal</code> (see <a href="#Quote-Removal">Quote Removal</a>)
17345e5a 2306is performed.
a0c0a00f
CR
2307</p>
2308<hr>
2309<a name="Brace-Expansion"></a>
2310<div class="header">
2311<p>
2312Next: <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>
2313</div>
2314<a name="Brace-Expansion-1"></a>
2315<h4 class="subsection">3.5.1 Brace Expansion</h4>
2316<a name="index-brace-expansion"></a>
2317<a name="index-expansion_002c-brace"></a>
2318
2319<p>Brace expansion is a mechanism by which arbitrary strings may be generated.
17345e5a 2320This mechanism is similar to
a0c0a00f 2321<var>filename expansion</var> (see <a href="#Filename-Expansion">Filename Expansion</a>),
ac50fbac 2322but the filenames generated need not exist.
a0c0a00f 2323Patterns to be brace expanded take the form of an optional <var>preamble</var>,
ac50fbac 2324followed by either a series of comma-separated strings or a sequence expression
17345e5a 2325between a pair of braces,
a0c0a00f 2326followed by an optional <var>postscript</var>.
17345e5a
JA
2327The preamble is prefixed to each string contained within the braces, and
2328the postscript is then appended to each resulting string, expanding left
2329to right.
a0c0a00f
CR
2330</p>
2331<p>Brace expansions may be nested.
17345e5a
JA
2332The results of each expanded string are not sorted; left to right order
2333is preserved.
2334For example,
a0c0a00f
CR
2335</p><div class="example">
2336<pre class="example">bash$ echo a{d,c,b}e
17345e5a 2337ade ace abe
a0c0a00f 2338</pre></div>
17345e5a 2339
a0c0a00f
CR
2340<p>A sequence expression takes the form <code>{<var>x</var>..<var>y</var>[..<var>incr</var>]}</code>,
2341where <var>x</var> and <var>y</var> are either integers or single characters,
2342and <var>incr</var>, an optional increment, is an integer.
17345e5a 2343When integers are supplied, the expression expands to each number between
a0c0a00f
CR
2344<var>x</var> and <var>y</var>, inclusive.
2345Supplied integers may be prefixed with &lsquo;<samp>0</samp>&rsquo; to force each term to have the
ac50fbac 2346same width.
a0c0a00f 2347When either <var>x</var> or <var>y</var> begins with a zero, the shell
17345e5a
JA
2348attempts to force all generated terms to contain the same number of digits,
2349zero-padding where necessary.
2350When characters are supplied, the expression expands to each character
a0c0a00f 2351lexicographically between <var>x</var> and <var>y</var>, inclusive,
ac50fbac 2352using the default C locale.
a0c0a00f 2353Note that both <var>x</var> and <var>y</var> must be of the same type.
17345e5a
JA
2354When the increment is supplied, it is used as the difference between
2355each term. The default increment is 1 or -1 as appropriate.
a0c0a00f
CR
2356</p>
2357<p>Brace expansion is performed before any other expansions,
17345e5a
JA
2358and any characters special to other expansions are preserved
2359in the result. It is strictly textual. Bash
2360does not apply any syntactic interpretation to the context of the
2361expansion or the text between the braces.
a0c0a00f
CR
2362</p>
2363<p>A correctly-formed brace expansion must contain unquoted opening
17345e5a
JA
2364and closing braces, and at least one unquoted comma or a valid
2365sequence expression.
2366Any incorrectly formed brace expansion is left unchanged.
a0c0a00f
CR
2367</p>
2368<p>A { or &lsquo;<samp>,</samp>&rsquo; may be quoted with a backslash to prevent its
17345e5a 2369being considered part of a brace expression.
a0c0a00f 2370To avoid conflicts with parameter expansion, the string &lsquo;<samp>${</samp>&rsquo;
9a51695b
CR
2371is not considered eligible for brace expansion,
2372and inhibits brace expansion until the closing &lsquo;<samp>}</samp>&rsquo;..
a0c0a00f
CR
2373</p>
2374<p>This construct is typically used as shorthand when the common
17345e5a
JA
2375prefix of the strings to be generated is longer than in the
2376above example:
a0c0a00f
CR
2377</p><div class="example">
2378<pre class="example">mkdir /usr/local/src/bash/{old,new,dist,bugs}
2379</pre></div>
2380<p>or
2381</p><div class="example">
2382<pre class="example">chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
2383</pre></div>
2384
2385<hr>
2386<a name="Tilde-Expansion"></a>
2387<div class="header">
2388<p>
2389Next: <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>
2390</div>
2391<a name="Tilde-Expansion-1"></a>
2392<h4 class="subsection">3.5.2 Tilde Expansion</h4>
2393<a name="index-tilde-expansion"></a>
2394<a name="index-expansion_002c-tilde"></a>
2395
2396<p>If a word begins with an unquoted tilde character (&lsquo;<samp>~</samp>&rsquo;), all of the
17345e5a 2397characters up to the first unquoted slash (or all characters,
a0c0a00f 2398if there is no unquoted slash) are considered a <var>tilde-prefix</var>.
17345e5a
JA
2399If none of the characters in the tilde-prefix are quoted, the
2400characters in the tilde-prefix following the tilde are treated as a
a0c0a00f 2401possible <var>login name</var>.
17345e5a 2402If this login name is the null string, the tilde is replaced with the
a0c0a00f
CR
2403value of the <code>HOME</code> shell variable.
2404If <code>HOME</code> is unset, the home directory of the user executing the
17345e5a
JA
2405shell is substituted instead.
2406Otherwise, the tilde-prefix is replaced with the home directory
2407associated with the specified login name.
a0c0a00f
CR
2408</p>
2409<p>If the tilde-prefix is &lsquo;<samp>~+</samp>&rsquo;, the value of
2410the shell variable <code>PWD</code> replaces the tilde-prefix.
2411If the tilde-prefix is &lsquo;<samp>~-</samp>&rsquo;, the value of the shell variable
2412<code>OLDPWD</code>, if it is set, is substituted.
2413</p>
2414<p>If the characters following the tilde in the tilde-prefix consist of a
2415number <var>N</var>, optionally prefixed by a &lsquo;<samp>+</samp>&rsquo; or a &lsquo;<samp>-</samp>&rsquo;,
17345e5a
JA
2416the tilde-prefix is replaced with the
2417corresponding element from the directory stack, as it would be displayed
a0c0a00f
CR
2418by the <code>dirs</code> builtin invoked with the characters following tilde
2419in the tilde-prefix as an argument (see <a href="#The-Directory-Stack">The Directory Stack</a>).
17345e5a 2420If the tilde-prefix, sans the tilde, consists of a number without a
a0c0a00f
CR
2421leading &lsquo;<samp>+</samp>&rsquo; or &lsquo;<samp>-</samp>&rsquo;, &lsquo;<samp>+</samp>&rsquo; is assumed.
2422</p>
2423<p>If the login name is invalid, or the tilde expansion fails, the word is
17345e5a 2424left unchanged.
a0c0a00f
CR
2425</p>
2426<p>Each variable assignment is checked for unquoted tilde-prefixes immediately
2427following a &lsquo;<samp>:</samp>&rsquo; or the first &lsquo;<samp>=</samp>&rsquo;.
17345e5a 2428In these cases, tilde expansion is also performed.
ac50fbac 2429Consequently, one may use filenames with tildes in assignments to
a0c0a00f 2430<code>PATH</code>, <code>MAILPATH</code>, and <code>CDPATH</code>,
17345e5a 2431and the shell assigns the expanded value.
a0c0a00f
CR
2432</p>
2433<p>The following table shows how Bash treats unquoted tilde-prefixes:
2434</p>
2435<dl compact="compact">
2436<dt><code>~</code></dt>
2437<dd><p>The value of <code>$HOME</code>
2438</p></dd>
2439<dt><code>~/foo</code></dt>
2440<dd><p><samp>$HOME/foo</samp>
2441</p>
2442</dd>
2443<dt><code>~fred/foo</code></dt>
2444<dd><p>The subdirectory <code>foo</code> of the home directory of the user
2445<code>fred</code>
2446</p>
2447</dd>
2448<dt><code>~+/foo</code></dt>
2449<dd><p><samp>$PWD/foo</samp>
2450</p>
2451</dd>
2452<dt><code>~-/foo</code></dt>
2453<dd><p><samp>${OLDPWD-'~-'}/foo</samp>
2454</p>
2455</dd>
2456<dt><code>~<var>N</var></code></dt>
2457<dd><p>The string that would be displayed by &lsquo;<samp>dirs +<var>N</var></samp>&rsquo;
2458</p>
2459</dd>
2460<dt><code>~+<var>N</var></code></dt>
2461<dd><p>The string that would be displayed by &lsquo;<samp>dirs +<var>N</var></samp>&rsquo;
2462</p>
2463</dd>
2464<dt><code>~-<var>N</var></code></dt>
2465<dd><p>The string that would be displayed by &lsquo;<samp>dirs -<var>N</var></samp>&rsquo;
2466</p></dd>
2467</dl>
2468
2f5dfe5a
CR
2469<p>Bash also performs tilde expansion on words satisfying the conditions of
2470variable assignments (see <a href="#Shell-Parameters">Shell Parameters</a>)
2471when they appear as arguments to simple commands.
2472Bash does not do this, except for the <var>declaration</var> commands listed
2473above, when in <small>POSIX</small> mode.
2474</p>
a0c0a00f
CR
2475<hr>
2476<a name="Shell-Parameter-Expansion"></a>
2477<div class="header">
2478<p>
2479Next: <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>
2480</div>
2481<a name="Shell-Parameter-Expansion-1"></a>
2482<h4 class="subsection">3.5.3 Shell Parameter Expansion</h4>
2483<a name="index-parameter-expansion"></a>
2484<a name="index-expansion_002c-parameter"></a>
2485
2486<p>The &lsquo;<samp>$</samp>&rsquo; character introduces parameter expansion,
17345e5a
JA
2487command substitution, or arithmetic expansion. The parameter name
2488or symbol to be expanded may be enclosed in braces, which
2489are optional but serve to protect the variable to be expanded from
2490characters immediately following it which could be
2491interpreted as part of the name.
a0c0a00f
CR
2492</p>
2493<p>When braces are used, the matching ending brace is the first &lsquo;<samp>}</samp>&rsquo;
17345e5a
JA
2494not escaped by a backslash or within a quoted string, and not within an
2495embedded arithmetic expansion, command substitution, or parameter
2496expansion.
a0c0a00f
CR
2497</p>
2498<p>The basic form of parameter expansion is ${<var>parameter</var>}.
2499The value of <var>parameter</var> is substituted.
2500The <var>parameter</var> is a shell parameter as described above
2501(see <a href="#Shell-Parameters">Shell Parameters</a>) or an array reference (see <a href="#Arrays">Arrays</a>).
2502The braces are required when <var>parameter</var>
17345e5a 2503is a positional parameter with more than one digit,
a0c0a00f 2504or when <var>parameter</var> is followed by a character that is not to be
17345e5a 2505interpreted as part of its name.
a0c0a00f
CR
2506</p>
2507<p>If the first character of <var>parameter</var> is an exclamation point (!),
2508and <var>parameter</var> is not a <var>nameref</var>,
2f5dfe5a
CR
2509it introduces a level of indirection.
2510Bash uses the value formed by expanding the rest of
2511<var>parameter</var> as the new <var>parameter</var>; this is then
2512expanded and that value is used in the rest of the expansion, rather
2513than the expansion of the original <var>parameter</var>.
a0c0a00f 2514This is known as <code>indirect expansion</code>.
9a51695b
CR
2515The value is subject to tilde expansion,
2516parameter expansion, command substitution, and arithmetic expansion.
a0c0a00f
CR
2517If <var>parameter</var> is a nameref, this expands to the name of the
2518variable referenced by <var>parameter</var> instead of performing the
2519complete indirect expansion.
2520The exceptions to this are the expansions of ${!<var>prefix</var>*}
2521and ${!<var>name</var>[@]}
17345e5a
JA
2522described below.
2523The exclamation point must immediately follow the left brace in order to
2524introduce indirection.
a0c0a00f
CR
2525</p>
2526<p>In each of the cases below, <var>word</var> is subject to tilde expansion,
17345e5a 2527parameter expansion, command substitution, and arithmetic expansion.
a0c0a00f
CR
2528</p>
2529<p>When not performing substring expansion, using the form described
2530below (e.g., &lsquo;<samp>:-</samp>&rsquo;), Bash tests for a parameter that is unset or null.
17345e5a
JA
2531Omitting the colon results in a test only for a parameter that is unset.
2532Put another way, if the colon is included,
a0c0a00f 2533the operator tests for both <var>parameter</var>&rsquo;s existence and that its value
17345e5a 2534is not null; if the colon is omitted, the operator tests only for existence.
a0c0a00f
CR
2535</p>
2536<dl compact="compact">
2537<dt><code>${<var>parameter</var>:-<var>word</var>}</code></dt>
2538<dd><p>If <var>parameter</var> is unset or null, the expansion of
2539<var>word</var> is substituted. Otherwise, the value of
2540<var>parameter</var> is substituted.
2541</p>
2542</dd>
2543<dt><code>${<var>parameter</var>:=<var>word</var>}</code></dt>
2544<dd><p>If <var>parameter</var>
2545is unset or null, the expansion of <var>word</var>
2546is assigned to <var>parameter</var>.
2547The value of <var>parameter</var> is then substituted.
17345e5a
JA
2548Positional parameters and special parameters may not be assigned to
2549in this way.
a0c0a00f
CR
2550</p>
2551</dd>
2552<dt><code>${<var>parameter</var>:?<var>word</var>}</code></dt>
2553<dd><p>If <var>parameter</var>
2554is null or unset, the expansion of <var>word</var> (or a message
2555to that effect if <var>word</var>
17345e5a 2556is not present) is written to the standard error and the shell, if it
a0c0a00f 2557is not interactive, exits. Otherwise, the value of <var>parameter</var> is
17345e5a 2558substituted.
a0c0a00f
CR
2559</p>
2560</dd>
2561<dt><code>${<var>parameter</var>:+<var>word</var>}</code></dt>
2562<dd><p>If <var>parameter</var>
17345e5a 2563is null or unset, nothing is substituted, otherwise the expansion of
a0c0a00f
CR
2564<var>word</var> is substituted.
2565</p>
2566</dd>
2567<dt><code>${<var>parameter</var>:<var>offset</var>}</code></dt>
2568<dt><code>${<var>parameter</var>:<var>offset</var>:<var>length</var>}</code></dt>
2569<dd><p>This is referred to as Substring Expansion.
2570It expands to up to <var>length</var> characters of the value of <var>parameter</var>
2571starting at the character specified by <var>offset</var>.
2572If <var>parameter</var> is &lsquo;<samp>@</samp>&rsquo;, an indexed array subscripted by
2573&lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;, or an associative array name, the results differ as
ac50fbac 2574described below.
a0c0a00f
CR
2575If <var>length</var> is omitted, it expands to the substring of the value of
2576<var>parameter</var> starting at the character specified by <var>offset</var>
ac50fbac 2577and extending to the end of the value.
a0c0a00f
CR
2578<var>length</var> and <var>offset</var> are arithmetic expressions
2579(see <a href="#Shell-Arithmetic">Shell Arithmetic</a>).
2580</p>
2581<p>If <var>offset</var> evaluates to a number less than zero, the value
ac50fbac 2582is used as an offset in characters
a0c0a00f
CR
2583from the end of the value of <var>parameter</var>.
2584If <var>length</var> evaluates to a number less than zero,
ac50fbac 2585it is interpreted as an offset in characters
a0c0a00f 2586from the end of the value of <var>parameter</var> rather than
ac50fbac 2587a number of characters, and the expansion is the characters between
a0c0a00f 2588<var>offset</var> and that result.
ac50fbac 2589Note that a negative offset must be separated from the colon by at least
a0c0a00f
CR
2590one space to avoid being confused with the &lsquo;<samp>:-</samp>&rsquo; expansion.
2591</p>
2592<p>Here are some examples illustrating substring expansion on parameters and
ac50fbac 2593subscripted arrays:
a0c0a00f
CR
2594</p>
2595<pre class="verbatim">$ string=01234567890abcdefgh
ac50fbac
CR
2596$ echo ${string:7}
25977890abcdefgh
2598$ echo ${string:7:0}
ac50fbac
CR
2599
2600$ echo ${string:7:2}
260178
2602$ echo ${string:7:-2}
26037890abcdef
2604$ echo ${string: -7}
2605bcdefgh
2606$ echo ${string: -7:0}
ac50fbac
CR
2607
2608$ echo ${string: -7:2}
2609bc
2610$ echo ${string: -7:-2}
2611bcdef
2612$ set -- 01234567890abcdefgh
2613$ echo ${1:7}
26147890abcdefgh
2615$ echo ${1:7:0}
ac50fbac
CR
2616
2617$ echo ${1:7:2}
261878
2619$ echo ${1:7:-2}
26207890abcdef
2621$ echo ${1: -7}
2622bcdefgh
2623$ echo ${1: -7:0}
ac50fbac
CR
2624
2625$ echo ${1: -7:2}
2626bc
2627$ echo ${1: -7:-2}
2628bcdef
2629$ array[0]=01234567890abcdefgh
2630$ echo ${array[0]:7}
26317890abcdefgh
2632$ echo ${array[0]:7:0}
ac50fbac
CR
2633
2634$ echo ${array[0]:7:2}
263578
2636$ echo ${array[0]:7:-2}
26377890abcdef
2638$ echo ${array[0]: -7}
2639bcdefgh
2640$ echo ${array[0]: -7:0}
ac50fbac
CR
2641
2642$ echo ${array[0]: -7:2}
2643bc
2644$ echo ${array[0]: -7:-2}
2645bcdef
a0c0a00f
CR
2646</pre>
2647<p>If <var>parameter</var> is &lsquo;<samp>@</samp>&rsquo;, the result is <var>length</var> positional
2648parameters beginning at <var>offset</var>.
2649A negative <var>offset</var> is taken relative to one greater than the greatest
ac50fbac
CR
2650positional parameter, so an offset of -1 evaluates to the last positional
2651parameter.
a0c0a00f
CR
2652It is an expansion error if <var>length</var> evaluates to a number less than zero.
2653</p>
2654<p>The following examples illustrate substring expansion using positional
ac50fbac 2655parameters:
a0c0a00f
CR
2656</p>
2657<pre class="verbatim">$ set -- 1 2 3 4 5 6 7 8 9 0 a b c d e f g h
2658$ echo ${@:7}
ac50fbac 26597 8 9 0 a b c d e f g h
a0c0a00f 2660$ echo ${@:7:0}
ac50fbac 2661
a0c0a00f 2662$ echo ${@:7:2}
ac50fbac 26637 8
a0c0a00f
CR
2664$ echo ${@:7:-2}
2665bash: -2: substring expression &lt; 0
2666$ echo ${@: -7:2}
ac50fbac 2667b c
a0c0a00f 2668$ echo ${@:0}
ac50fbac 2669./bash 1 2 3 4 5 6 7 8 9 0 a b c d e f g h
a0c0a00f 2670$ echo ${@:0:2}
ac50fbac 2671./bash 1
a0c0a00f 2672$ echo ${@: -7:0}
ac50fbac 2673
a0c0a00f
CR
2674</pre>
2675<p>If <var>parameter</var> is an indexed array name subscripted
2676by &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;, the result is the <var>length</var>
2677members of the array beginning with <code>${<var>parameter</var>[<var>offset</var>]}</code>.
2678A negative <var>offset</var> is taken relative to one greater than the maximum
17345e5a 2679index of the specified array.
a0c0a00f
CR
2680It is an expansion error if <var>length</var> evaluates to a number less than zero.
2681</p>
2682<p>These examples show how you can use substring expansion with indexed
ac50fbac 2683arrays:
a0c0a00f
CR
2684</p>
2685<pre class="verbatim">$ array=(0 1 2 3 4 5 6 7 8 9 0 a b c d e f g h)
ac50fbac
CR
2686$ echo ${array[@]:7}
26877 8 9 0 a b c d e f g h
2688$ echo ${array[@]:7:2}
26897 8
2690$ echo ${array[@]: -7:2}
2691b c
2692$ echo ${array[@]: -7:-2}
a0c0a00f 2693bash: -2: substring expression &lt; 0
ac50fbac
CR
2694$ echo ${array[@]:0}
26950 1 2 3 4 5 6 7 8 9 0 a b c d e f g h
2696$ echo ${array[@]:0:2}
26970 1
2698$ echo ${array[@]: -7:0}
ac50fbac 2699
a0c0a00f
CR
2700</pre>
2701<p>Substring expansion applied to an associative array produces undefined
17345e5a 2702results.
a0c0a00f
CR
2703</p>
2704<p>Substring indexing is zero-based unless the positional parameters
17345e5a 2705are used, in which case the indexing starts at 1 by default.
a0c0a00f 2706If <var>offset</var> is 0, and the positional parameters are used, <code>$@</code> is
17345e5a 2707prefixed to the list.
a0c0a00f
CR
2708</p>
2709</dd>
2710<dt><code>${!<var>prefix</var>*}</code></dt>
2711<dt><code>${!<var>prefix</var>@}</code></dt>
2712<dd><p>Expands to the names of variables whose names begin with <var>prefix</var>,
2713separated by the first character of the <code>IFS</code> special variable.
2714When &lsquo;<samp>@</samp>&rsquo; is used and the expansion appears within double quotes, each
17345e5a 2715variable name expands to a separate word.
a0c0a00f
CR
2716</p>
2717</dd>
2718<dt><code>${!<var>name</var>[@]}</code></dt>
2719<dt><code>${!<var>name</var>[*]}</code></dt>
2720<dd><p>If <var>name</var> is an array variable, expands to the list of array indices
2721(keys) assigned in <var>name</var>.
2722If <var>name</var> is not an array, expands to 0 if <var>name</var> is set and null
17345e5a 2723otherwise.
a0c0a00f 2724When &lsquo;<samp>@</samp>&rsquo; is used and the expansion appears within double quotes, each
17345e5a 2725key expands to a separate word.
a0c0a00f
CR
2726</p>
2727</dd>
2728<dt><code>${#<var>parameter</var>}</code></dt>
2729<dd><p>The length in characters of the expanded value of <var>parameter</var> is
17345e5a 2730substituted.
a0c0a00f 2731If <var>parameter</var> is &lsquo;<samp>*</samp>&rsquo; or &lsquo;<samp>@</samp>&rsquo;, the value substituted
17345e5a 2732is the number of positional parameters.
a0c0a00f 2733If <var>parameter</var> is an array name subscripted by &lsquo;<samp>*</samp>&rsquo; or &lsquo;<samp>@</samp>&rsquo;,
17345e5a 2734the value substituted is the number of elements in the array.
a0c0a00f 2735If <var>parameter</var>
ac50fbac
CR
2736is an indexed array name subscripted by a negative number, that number is
2737interpreted as relative to one greater than the maximum index of
a0c0a00f 2738<var>parameter</var>, so negative indices count back from the end of the
ac50fbac 2739array, and an index of -1 references the last element.
a0c0a00f
CR
2740</p>
2741</dd>
2742<dt><code>${<var>parameter</var>#<var>word</var>}</code></dt>
2743<dt><code>${<var>parameter</var>##<var>word</var>}</code></dt>
2744<dd><p>The <var>word</var>
9a51695b
CR
2745is expanded to produce a pattern and matched according to the rules
2746described below (see <a href="#Pattern-Matching">Pattern Matching</a>). If the pattern matches
a0c0a00f
CR
2747the beginning of the expanded value of <var>parameter</var>,
2748then the result of the expansion is the expanded value of <var>parameter</var>
2749with the shortest matching pattern (the &lsquo;<samp>#</samp>&rsquo; case) or the
2750longest matching pattern (the &lsquo;<samp>##</samp>&rsquo; case) deleted.
2751If <var>parameter</var> is &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
17345e5a
JA
2752the pattern removal operation is applied to each positional
2753parameter in turn, and the expansion is the resultant list.
a0c0a00f
CR
2754If <var>parameter</var> is an array variable subscripted with
2755&lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
17345e5a
JA
2756the pattern removal operation is applied to each member of the
2757array in turn, and the expansion is the resultant list.
a0c0a00f
CR
2758</p>
2759</dd>
2760<dt><code>${<var>parameter</var>%<var>word</var>}</code></dt>
2761<dt><code>${<var>parameter</var>%%<var>word</var>}</code></dt>
9a51695b
CR
2762<dd><p>The <var>word</var>
2763is expanded to produce a pattern and matched according to the rules
2764described below (see <a href="#Pattern-Matching">Pattern Matching</a>). If the pattern matches
17345e5a 2765If the pattern matches a trailing portion of the expanded value of
a0c0a00f
CR
2766<var>parameter</var>, then the result of the expansion is the value of
2767<var>parameter</var> with the shortest matching pattern (the &lsquo;<samp>%</samp>&rsquo; case)
2768or the longest matching pattern (the &lsquo;<samp>%%</samp>&rsquo; case) deleted.
2769If <var>parameter</var> is &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
17345e5a
JA
2770the pattern removal operation is applied to each positional
2771parameter in turn, and the expansion is the resultant list.
a0c0a00f
CR
2772If <var>parameter</var>
2773is an array variable subscripted with &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
17345e5a
JA
2774the pattern removal operation is applied to each member of the
2775array in turn, and the expansion is the resultant list.
a0c0a00f
CR
2776</p>
2777</dd>
2778<dt><code>${<var>parameter</var>/<var>pattern</var>/<var>string</var>}</code></dt>
2779<dd>
2780<p>The <var>pattern</var> is expanded to produce a pattern just as in
17345e5a 2781filename expansion.
a0c0a00f
CR
2782<var>Parameter</var> is expanded and the longest match of <var>pattern</var>
2783against its value is replaced with <var>string</var>.
9a51695b
CR
2784The match is performed according to the rules described below
2785(see <a href="#Pattern-Matching">Pattern Matching</a>).
a0c0a00f
CR
2786If <var>pattern</var> begins with &lsquo;<samp>/</samp>&rsquo;, all matches of <var>pattern</var> are
2787replaced with <var>string</var>. Normally only the first match is replaced.
2788If <var>pattern</var> begins with &lsquo;<samp>#</samp>&rsquo;, it must match at the beginning
2789of the expanded value of <var>parameter</var>.
2790If <var>pattern</var> begins with &lsquo;<samp>%</samp>&rsquo;, it must match at the end
2791of the expanded value of <var>parameter</var>.
2792If <var>string</var> is null, matches of <var>pattern</var> are deleted
2793and the <code>/</code> following <var>pattern</var> may be omitted.
2794If the <code>nocasematch</code> shell option
2795(see the description of <code>shopt</code> in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>)
2796is enabled, the match is performed without regard to the case
2797of alphabetic characters.
2798If <var>parameter</var> is &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
17345e5a
JA
2799the substitution operation is applied to each positional
2800parameter in turn, and the expansion is the resultant list.
a0c0a00f
CR
2801If <var>parameter</var>
2802is an array variable subscripted with &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
17345e5a
JA
2803the substitution operation is applied to each member of the
2804array in turn, and the expansion is the resultant list.
a0c0a00f
CR
2805</p>
2806</dd>
2807<dt><code>${<var>parameter</var>^<var>pattern</var>}</code></dt>
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<dd><p>This expansion modifies the case of alphabetic characters in <var>parameter</var>.
2812The <var>pattern</var> is expanded to produce a pattern just as in
0001803f 2813filename expansion.
a0c0a00f
CR
2814Each character in the expanded value of <var>parameter</var> is tested against
2815<var>pattern</var>, and, if it matches the pattern, its case is converted.
ac50fbac 2816The pattern should not attempt to match more than one character.
a0c0a00f
CR
2817The &lsquo;<samp>^</samp>&rsquo; operator converts lowercase letters matching <var>pattern</var>
2818to uppercase; the &lsquo;<samp>,</samp>&rsquo; operator converts matching uppercase letters
17345e5a 2819to lowercase.
a0c0a00f
CR
2820The &lsquo;<samp>^^</samp>&rsquo; and &lsquo;<samp>,,</samp>&rsquo; expansions convert each matched character in the
2821expanded value; the &lsquo;<samp>^</samp>&rsquo; and &lsquo;<samp>,</samp>&rsquo; expansions match and convert only
17345e5a 2822the first character in the expanded value.
a0c0a00f 2823If <var>pattern</var> is omitted, it is treated like a &lsquo;<samp>?</samp>&rsquo;, which matches
17345e5a 2824every character.
a0c0a00f 2825If <var>parameter</var> is &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
17345e5a
JA
2826the case modification operation is applied to each positional
2827parameter in turn, and the expansion is the resultant list.
a0c0a00f
CR
2828If <var>parameter</var>
2829is an array variable subscripted with &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
17345e5a
JA
2830the case modification operation is applied to each member of the
2831array in turn, and the expansion is the resultant list.
a0c0a00f
CR
2832</p>
2833</dd>
2834<dt><code>${<var>parameter</var>@<var>operator</var>}</code></dt>
2835<dd><p>The expansion is either a transformation of the value of <var>parameter</var>
2836or information about <var>parameter</var> itself, depending on the value of
2837<var>operator</var>. Each <var>operator</var> is a single letter:
2838</p>
2839<dl compact="compact">
2840<dt><code>Q</code></dt>
2841<dd><p>The expansion is a string that is the value of <var>parameter</var> quoted in a
2842format that can be reused as input.
2843</p></dd>
2844<dt><code>E</code></dt>
2845<dd><p>The expansion is a string that is the value of <var>parameter</var> with backslash
9a51695b 2846escape sequences expanded as with the <code>$'&hellip;'</code> quoting mechanism.
a0c0a00f
CR
2847</p></dd>
2848<dt><code>P</code></dt>
2849<dd><p>The expansion is a string that is the result of expanding the value of
2850<var>parameter</var> as if it were a prompt string (see <a href="#Controlling-the-Prompt">Controlling the Prompt</a>).
2851</p></dd>
2852<dt><code>A</code></dt>
2853<dd><p>The expansion is a string in the form of
2854an assignment statement or <code>declare</code> command that, if
2855evaluated, will recreate <var>parameter</var> with its attributes and value.
2856</p></dd>
2857<dt><code>a</code></dt>
2858<dd><p>The expansion is a string consisting of flag values representing
2859<var>parameter</var>&rsquo;s attributes.
2860</p></dd>
2861</dl>
2862
2863<p>If <var>parameter</var> is &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
2864the operation is applied to each positional
2865parameter in turn, and the expansion is the resultant list.
2866If <var>parameter</var>
2867is an array variable subscripted with &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;,
2868the operation is applied to each member of the
2869array in turn, and the expansion is the resultant list.
2870</p>
2871<p>The result of the expansion is subject to word splitting and pathname
2872expansion as described below.
2873</p></dd>
2874</dl>
2875
2876<hr>
2877<a name="Command-Substitution"></a>
2878<div class="header">
2879<p>
2880Next: <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>
2881</div>
2882<a name="Command-Substitution-1"></a>
2883<h4 class="subsection">3.5.4 Command Substitution</h4>
2884<a name="index-command-substitution"></a>
2885
2886<p>Command substitution allows the output of a command to replace
17345e5a
JA
2887the command itself.
2888Command substitution occurs when a command is enclosed as follows:
a0c0a00f
CR
2889</p><div class="example">
2890<pre class="example">$(<var>command</var>)
2891</pre></div>
2892<p>or
2893</p><div class="example">
2894<pre class="example">`<var>command</var>`
2895</pre></div>
2896
2897<p>Bash performs the expansion by executing <var>command</var> in a subshell environment
2898and replacing the command substitution with the standard output of the
17345e5a
JA
2899command, with any trailing newlines deleted.
2900Embedded newlines are not deleted, but they may be removed during
2901word splitting.
a0c0a00f
CR
2902The command substitution <code>$(cat <var>file</var>)</code> can be
2903replaced by the equivalent but faster <code>$(&lt; <var>file</var>)</code>.
2904</p>
2905<p>When the old-style backquote form of substitution is used,
17345e5a 2906backslash retains its literal meaning except when followed by
a0c0a00f 2907&lsquo;<samp>$</samp>&rsquo;, &lsquo;<samp>`</samp>&rsquo;, or &lsquo;<samp>\</samp>&rsquo;.
17345e5a
JA
2908The first backquote not preceded by a backslash terminates the
2909command substitution.
a0c0a00f 2910When using the <code>$(<var>command</var>)</code> form, all characters between
17345e5a 2911the parentheses make up the command; none are treated specially.
a0c0a00f
CR
2912</p>
2913<p>Command substitutions may be nested. To nest when using the backquoted
17345e5a 2914form, escape the inner backquotes with backslashes.
a0c0a00f
CR
2915</p>
2916<p>If the substitution appears within double quotes, word splitting and
17345e5a 2917filename expansion are not performed on the results.
a0c0a00f
CR
2918</p>
2919<hr>
2920<a name="Arithmetic-Expansion"></a>
2921<div class="header">
2922<p>
2923Next: <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>
2924</div>
2925<a name="Arithmetic-Expansion-1"></a>
2926<h4 class="subsection">3.5.5 Arithmetic Expansion</h4>
2927<a name="index-expansion_002c-arithmetic"></a>
2928<a name="index-arithmetic-expansion"></a>
2929
2930<p>Arithmetic expansion allows the evaluation of an arithmetic expression
17345e5a 2931and the substitution of the result. The format for arithmetic expansion is:
a0c0a00f
CR
2932</p>
2933<div class="example">
2934<pre class="example">$(( <var>expression</var> ))
2935</pre></div>
17345e5a 2936
a0c0a00f 2937<p>The expression is treated as if it were within double quotes, but
17345e5a 2938a double quote inside the parentheses is not treated specially.
ac50fbac
CR
2939All tokens in the expression undergo parameter and variable expansion,
2940command substitution, and quote removal.
2941The result is treated as the arithmetic expression to be evaluated.
17345e5a 2942Arithmetic expansions may be nested.
a0c0a00f
CR
2943</p>
2944<p>The evaluation is performed according to the rules listed below
2945(see <a href="#Shell-Arithmetic">Shell Arithmetic</a>).
17345e5a
JA
2946If the expression is invalid, Bash prints a message indicating
2947failure to the standard error and no substitution occurs.
a0c0a00f
CR
2948</p>
2949<hr>
2950<a name="Process-Substitution"></a>
2951<div class="header">
2952<p>
2953Next: <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>
2954</div>
2955<a name="Process-Substitution-1"></a>
2956<h4 class="subsection">3.5.6 Process Substitution</h4>
2957<a name="index-process-substitution"></a>
2958
2959<p>Process substitution allows a process&rsquo;s input or output to be
2960referred to using a filename.
17345e5a 2961It takes the form of
a0c0a00f
CR
2962</p><div class="example">
2963<pre class="example">&lt;(<var>list</var>)
2964</pre></div>
2965<p>or
2966</p><div class="example">
2967<pre class="example">&gt;(<var>list</var>)
2968</pre></div>
2969<p>The process <var>list</var> is run asynchronously, and its input or output
2970appears as a filename.
2971This filename is
17345e5a 2972passed as an argument to the current command as the result of the
a0c0a00f
CR
2973expansion.
2974If the <code>&gt;(<var>list</var>)</code> form is used, writing to
2975the file will provide input for <var>list</var>. If the
2976<code>&lt;(<var>list</var>)</code> form is used, the file passed as an
2977argument should be read to obtain the output of <var>list</var>.
2978Note that no space may appear between the <code>&lt;</code> or <code>&gt;</code>
17345e5a
JA
2979and the left parenthesis, otherwise the construct would be interpreted
2980as a redirection.
a0c0a00f
CR
2981Process substitution is supported on systems that support named
2982pipes (<small>FIFO</small>s) or the <samp>/dev/fd</samp> method of naming open files.
2983</p>
2984<p>When available, process substitution is performed simultaneously with
17345e5a
JA
2985parameter and variable expansion, command substitution, and arithmetic
2986expansion.
a0c0a00f
CR
2987</p>
2988<hr>
2989<a name="Word-Splitting"></a>
2990<div class="header">
2991<p>
2992Next: <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>
2993</div>
2994<a name="Word-Splitting-1"></a>
2995<h4 class="subsection">3.5.7 Word Splitting</h4>
2996<a name="index-word-splitting"></a>
2997
2998<p>The shell scans the results of parameter expansion, command substitution,
17345e5a
JA
2999and arithmetic expansion that did not occur within double quotes for
3000word splitting.
a0c0a00f
CR
3001</p>
3002<p>The shell treats each character of <code>$IFS</code> as a delimiter, and splits
ac50fbac
CR
3003the results of the other expansions into words using these characters
3004as field terminators.
a0c0a00f 3005If <code>IFS</code> is unset, or its value is exactly <code>&lt;space&gt;&lt;tab&gt;&lt;newline&gt;</code>,
17345e5a 3006the default, then sequences of
a0c0a00f 3007<code> &lt;space&gt;</code>, <code>&lt;tab&gt;</code>, and <code>&lt;newline&gt;</code>
17345e5a 3008at the beginning and end of the results of the previous
a0c0a00f 3009expansions are ignored, and any sequence of <code>IFS</code>
17345e5a 3010characters not at the beginning or end serves to delimit words.
a0c0a00f
CR
3011If <code>IFS</code> has a value other than the default, then sequences of
3012the whitespace characters <code>space</code>, <code>tab</code>, and <code>newline</code>
17345e5a
JA
3013are ignored at the beginning and end of the
3014word, as long as the whitespace character is in the
a0c0a00f
CR
3015value of <code>IFS</code> (an <code>IFS</code> whitespace character).
3016Any character in <code>IFS</code> that is not <code>IFS</code>
3017whitespace, along with any adjacent <code>IFS</code>
3018whitespace characters, delimits a field. A sequence of <code>IFS</code>
17345e5a 3019whitespace characters is also treated as a delimiter.
a0c0a00f
CR
3020If the value of <code>IFS</code> is null, no word splitting occurs.
3021</p>
3022<p>Explicit null arguments (<code>&quot;&quot;</code> or <code>''</code>) are retained
3023and passed to commands as empty strings.
17345e5a
JA
3024Unquoted implicit null arguments, resulting from the expansion of
3025parameters that have no values, are removed.
3026If a parameter with no value is expanded within double quotes, a
a0c0a00f
CR
3027null argument results and is retained
3028and passed to a command as an empty string.
3029When a quoted null argument appears as part of a word whose expansion is
3030non-null, the null argument is removed.
3031That is, the word
3032<code>-d''</code> becomes <code>-d</code> after word splitting and
3033null argument removal.
3034</p>
3035<p>Note that if no expansion occurs, no splitting
17345e5a 3036is performed.
a0c0a00f
CR
3037</p>
3038<hr>
3039<a name="Filename-Expansion"></a>
3040<div class="header">
3041<p>
3042Next: <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>
3043</div>
3044<a name="Filename-Expansion-1"></a>
3045<h4 class="subsection">3.5.8 Filename Expansion</h4>
3046<table class="menu" border="0" cellspacing="0">
3047<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.
3048</td></tr>
3049</table>
3050<a name="index-expansion_002c-filename"></a>
3051<a name="index-expansion_002c-pathname"></a>
3052<a name="index-filename-expansion"></a>
3053<a name="index-pathname-expansion"></a>
3054
3055<p>After word splitting, unless the <samp>-f</samp> option has been set
3056(see <a href="#The-Set-Builtin">The Set Builtin</a>), Bash scans each word for the characters
3057&lsquo;<samp>*</samp>&rsquo;, &lsquo;<samp>?</samp>&rsquo;, and &lsquo;<samp>[</samp>&rsquo;.
17345e5a 3058If one of these characters appears, then the word is
a0c0a00f 3059regarded as a <var>pattern</var>,
17345e5a 3060and replaced with an alphabetically sorted list of
a0c0a00f 3061filenames matching the pattern (see <a href="#Pattern-Matching">Pattern Matching</a>).
ac50fbac 3062If no matching filenames are found,
a0c0a00f 3063and the shell option <code>nullglob</code> is disabled, the word is left
17345e5a 3064unchanged.
a0c0a00f 3065If the <code>nullglob</code> option is set, and no matches are found, the word
17345e5a 3066is removed.
a0c0a00f 3067If the <code>failglob</code> shell option is set, and no matches are found,
17345e5a 3068an error message is printed and the command is not executed.
a0c0a00f 3069If the shell option <code>nocaseglob</code> is enabled, the match is performed
17345e5a 3070without regard to the case of alphabetic characters.
a0c0a00f
CR
3071</p>
3072<p>When a pattern is used for filename expansion, the character &lsquo;<samp>.</samp>&rsquo;
17345e5a 3073at the start of a filename or immediately following a slash
a0c0a00f 3074must be matched explicitly, unless the shell option <code>dotglob</code> is set.
9a51695b
CR
3075The filenames &lsquo;<samp>.</samp>&rsquo; and &lsquo;<samp>..</samp>&rsquo; must always be matched explicitly,
3076even if <code>dotglob</code> is set.
a0c0a00f
CR
3077In other cases, the &lsquo;<samp>.</samp>&rsquo; character is not treated specially.
3078</p>
9a51695b
CR
3079<p>When matching a filename, the slash character must always be
3080matched explicitly by a slash in the pattern, but in other matching
3081contexts it can be matched by a special pattern character as described
3082below (see <a href="#Pattern-Matching">Pattern Matching</a>).
3083</p>
a0c0a00f
CR
3084<p>See the description of <code>shopt</code> in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>,
3085for a description of the <code>nocaseglob</code>, <code>nullglob</code>,
3086<code>failglob</code>, and <code>dotglob</code> options.
3087</p>
3088<p>The <code>GLOBIGNORE</code>
9a51695b 3089shell variable may be used to restrict the set of file names matching a
a0c0a00f 3090pattern. If <code>GLOBIGNORE</code>
9a51695b 3091is set, each matching file name that also matches one of the patterns in
a0c0a00f
CR
3092<code>GLOBIGNORE</code> is removed from the list of matches.
3093If the <code>nocaseglob</code> option is set, the matching against the patterns in
3094<code>GLOBIGNORE</code> is performed without regard to case.
3095The filenames
3096<samp>.</samp> and <samp>..</samp>
3097are always ignored when <code>GLOBIGNORE</code>
17345e5a 3098is set and not null.
a0c0a00f
CR
3099However, setting <code>GLOBIGNORE</code> to a non-null value has the effect of
3100enabling the <code>dotglob</code>
17345e5a 3101shell option, so all other filenames beginning with a
a0c0a00f 3102&lsquo;<samp>.</samp>&rsquo; will match.
17345e5a 3103To get the old behavior of ignoring filenames beginning with a
a0c0a00f
CR
3104&lsquo;<samp>.</samp>&rsquo;, make &lsquo;<samp>.*</samp>&rsquo; one of the patterns in <code>GLOBIGNORE</code>.
3105The <code>dotglob</code> option is disabled when <code>GLOBIGNORE</code>
17345e5a 3106is unset.
a0c0a00f
CR
3107</p>
3108<hr>
3109<a name="Pattern-Matching"></a>
3110<div class="header">
3111<p>
3112Up: <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>
3113</div>
3114<a name="Pattern-Matching-1"></a>
3115<h4 class="subsubsection">3.5.8.1 Pattern Matching</h4>
3116<a name="index-pattern-matching"></a>
3117<a name="index-matching_002c-pattern"></a>
3118
3119<p>Any character that appears in a pattern, other than the special pattern
17345e5a 3120characters described below, matches itself.
a0c0a00f 3121The <small>NUL</small> character may not occur in a pattern.
17345e5a
JA
3122A backslash escapes the following character; the
3123escaping backslash is discarded when matching.
3124The special pattern characters must be quoted if they are to be matched
3125literally.
a0c0a00f
CR
3126</p>
3127<p>The special pattern characters have the following meanings:
3128</p><dl compact="compact">
3129<dt><code>*</code></dt>
3130<dd><p>Matches any string, including the null string.
3131When the <code>globstar</code> shell option is enabled, and &lsquo;<samp>*</samp>&rsquo; is used in
3132a filename expansion context, two adjacent &lsquo;<samp>*</samp>&rsquo;s used as a single
17345e5a
JA
3133pattern will match all files and zero or more directories and
3134subdirectories.
a0c0a00f 3135If followed by a &lsquo;<samp>/</samp>&rsquo;, two adjacent &lsquo;<samp>*</samp>&rsquo;s will match only
17345e5a 3136directories and subdirectories.
a0c0a00f
CR
3137</p></dd>
3138<dt><code>?</code></dt>
3139<dd><p>Matches any single character.
3140</p></dd>
3141<dt><code>[&hellip;]</code></dt>
3142<dd><p>Matches any one of the enclosed characters. A pair of characters
3143separated by a hyphen denotes a <var>range expression</var>;
ac50fbac 3144any character that falls between those two characters, inclusive,
a0c0a00f 3145using the current locale&rsquo;s collating sequence and character set,
17345e5a 3146is matched. If the first character following the
a0c0a00f
CR
3147&lsquo;<samp>[</samp>&rsquo; is a &lsquo;<samp>!</samp>&rsquo; or a &lsquo;<samp>^</samp>&rsquo;
3148then any character not enclosed is matched. A &lsquo;<samp>-</samp>&rsquo;
17345e5a 3149may be matched by including it as the first or last character
a0c0a00f 3150in the set. A &lsquo;<samp>]</samp>&rsquo; may be matched by including it as the first
17345e5a
JA
3151character in the set.
3152The sorting order of characters in range expressions is determined by
ac50fbac 3153the current locale and the values of the
a0c0a00f
CR
3154<code>LC_COLLATE</code> and <code>LC_ALL</code> shell variables, if set.
3155</p>
3156<p>For example, in the default C locale, &lsquo;<samp>[a-dx-z]</samp>&rsquo; is equivalent to
3157&lsquo;<samp>[abcdxyz]</samp>&rsquo;. Many locales sort characters in dictionary order, and in
3158these locales &lsquo;<samp>[a-dx-z]</samp>&rsquo; is typically not equivalent to &lsquo;<samp>[abcdxyz]</samp>&rsquo;;
3159it might be equivalent to &lsquo;<samp>[aBbCcDdxXyYz]</samp>&rsquo;, for example. To obtain
17345e5a 3160the traditional interpretation of ranges in bracket expressions, you can
a0c0a00f
CR
3161force the use of the C locale by setting the <code>LC_COLLATE</code> or
3162<code>LC_ALL</code> environment variable to the value &lsquo;<samp>C</samp>&rsquo;, or enable the
3163<code>globasciiranges</code> shell option.
3164</p>
3165<p>Within &lsquo;<samp>[</samp>&rsquo; and &lsquo;<samp>]</samp>&rsquo;, <var>character classes</var> can be specified
17345e5a 3166using the syntax
a0c0a00f
CR
3167<code>[:</code><var>class</var><code>:]</code>, where <var>class</var> is one of the
3168following classes defined in the <small>POSIX</small> standard:
3169</p><div class="example">
3170<pre class="example">alnum alpha ascii blank cntrl digit graph lower
17345e5a 3171print punct space upper word xdigit
a0c0a00f
CR
3172</pre></div>
3173<p>A character class matches any character belonging to that class.
3174The <code>word</code> character class matches letters, digits, and the character
3175&lsquo;<samp>_</samp>&rsquo;.
3176</p>
3177<p>Within &lsquo;<samp>[</samp>&rsquo; and &lsquo;<samp>]</samp>&rsquo;, an <var>equivalence class</var> can be
3178specified using the syntax <code>[=</code><var>c</var><code>=]</code>, which
17345e5a 3179matches all characters with the same collation weight (as defined
a0c0a00f
CR
3180by the current locale) as the character <var>c</var>.
3181</p>
3182<p>Within &lsquo;<samp>[</samp>&rsquo; and &lsquo;<samp>]</samp>&rsquo;, the syntax <code>[.</code><var>symbol</var><code>.]</code>
3183matches the collating symbol <var>symbol</var>.
3184</p></dd>
3185</dl>
3186
3187<p>If the <code>extglob</code> shell option is enabled using the <code>shopt</code>
17345e5a 3188builtin, several extended pattern matching operators are recognized.
a0c0a00f
CR
3189In the following description, a <var>pattern-list</var> is a list of one
3190or more patterns separated by a &lsquo;<samp>|</samp>&rsquo;.
17345e5a
JA
3191Composite patterns may be formed using one or more of the following
3192sub-patterns:
a0c0a00f
CR
3193</p>
3194<dl compact="compact">
3195<dt><code>?(<var>pattern-list</var>)</code></dt>
3196<dd><p>Matches zero or one occurrence of the given patterns.
3197</p>
3198</dd>
3199<dt><code>*(<var>pattern-list</var>)</code></dt>
3200<dd><p>Matches zero or more occurrences of the given patterns.
3201</p>
3202</dd>
3203<dt><code>+(<var>pattern-list</var>)</code></dt>
3204<dd><p>Matches one or more occurrences of the given patterns.
3205</p>
3206</dd>
3207<dt><code>@(<var>pattern-list</var>)</code></dt>
3208<dd><p>Matches one of the given patterns.
3209</p>
3210</dd>
3211<dt><code>!(<var>pattern-list</var>)</code></dt>
3212<dd><p>Matches anything except one of the given patterns.
3213</p></dd>
3214</dl>
3215
9a51695b
CR
3216<p>Complicated extended pattern matching against long strings is slow,
3217especially when the patterns contain alternations and the strings
3218contain multiple matches.
3219Using separate matches against shorter strings, or using arrays of
3220strings instead of a single long string, may be faster.
3221</p>
a0c0a00f
CR
3222<hr>
3223<a name="Quote-Removal"></a>
3224<div class="header">
3225<p>
3226Previous: <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>
3227</div>
3228<a name="Quote-Removal-1"></a>
3229<h4 class="subsection">3.5.9 Quote Removal</h4>
3230
3231<p>After the preceding expansions, all unquoted occurrences of the
3232characters &lsquo;<samp>\</samp>&rsquo;, &lsquo;<samp>'</samp>&rsquo;, and &lsquo;<samp>&quot;</samp>&rsquo; that did not
17345e5a 3233result from one of the above expansions are removed.
a0c0a00f
CR
3234</p>
3235<hr>
3236<a name="Redirections"></a>
3237<div class="header">
3238<p>
3239Next: <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>
3240</div>
3241<a name="Redirections-1"></a>
3242<h3 class="section">3.6 Redirections</h3>
3243<a name="index-redirection"></a>
3244
3245<p>Before a command is executed, its input and output
3246may be <var>redirected</var>
17345e5a 3247using a special notation interpreted by the shell.
a0c0a00f 3248Redirection allows commands&rsquo; file handles to be
ac50fbac
CR
3249duplicated, opened, closed,
3250made to refer to different files,
3251and can change the files the command reads from and writes to.
3252Redirection may also be used to modify file handles in the
17345e5a
JA
3253current shell execution environment. The following redirection
3254operators may precede or appear anywhere within a
3255simple command or may follow a command.
3256Redirections are processed in the order they appear, from
3257left to right.
a0c0a00f
CR
3258</p>
3259<p>Each redirection that may be preceded by a file descriptor number
3260may instead be preceded by a word of the form {<var>varname</var>}.
0001803f 3261In this case, for each redirection operator except
a0c0a00f
CR
3262&gt;&amp;- and &lt;&amp;-, the shell will allocate a file descriptor greater
3263than 10 and assign it to {<var>varname</var>}. If &gt;&amp;- or &lt;&amp;- is preceded
3264by {<var>varname</var>}, the value of <var>varname</var> defines the file
0001803f 3265descriptor to close.
9a51695b
CR
3266If {<var>varname</var>} is supplied, the redirection persists beyond
3267the scope of the command, allowing the shell programmer to manage
3268the file descriptor himself.
a0c0a00f
CR
3269</p>
3270<p>In the following descriptions, if the file descriptor number is
17345e5a 3271omitted, and the first character of the redirection operator is
a0c0a00f 3272&lsquo;<samp>&lt;</samp>&rsquo;, the redirection refers to the standard input (file
17345e5a 3273descriptor 0). If the first character of the redirection operator
a0c0a00f 3274is &lsquo;<samp>&gt;</samp>&rsquo;, the redirection refers to the standard output (file
17345e5a 3275descriptor 1).
a0c0a00f
CR
3276</p>
3277<p>The word following the redirection operator in the following
17345e5a
JA
3278descriptions, unless otherwise noted, is subjected to brace expansion,
3279tilde expansion, parameter expansion, command substitution, arithmetic
3280expansion, quote removal, filename expansion, and word splitting.
3281If it expands to more than one word, Bash reports an error.
a0c0a00f
CR
3282</p>
3283<p>Note that the order of redirections is significant. For example,
17345e5a 3284the command
a0c0a00f
CR
3285</p><div class="example">
3286<pre class="example">ls &gt; <var>dirlist</var> 2&gt;&amp;1
3287</pre></div>
3288<p>directs both standard output (file descriptor 1) and standard error
3289(file descriptor 2) to the file <var>dirlist</var>, while the command
3290</p><div class="example">
3291<pre class="example">ls 2&gt;&amp;1 &gt; <var>dirlist</var>
3292</pre></div>
3293<p>directs only the standard output to file <var>dirlist</var>,
0001803f 3294because the standard error was made a copy of the standard output
a0c0a00f
CR
3295before the standard output was redirected to <var>dirlist</var>.
3296</p>
3297<p>Bash handles several filenames specially when they are used in
3298redirections, as described in the following table.
3299If the operating system on which Bash is running provides these
3300special files, bash will use them; otherwise it will emulate them
3301internally with the behavior described below.
3302</p>
3303<dl compact="compact">
3304<dt><code>/dev/fd/<var>fd</var></code></dt>
3305<dd><p>If <var>fd</var> is a valid integer, file descriptor <var>fd</var> is duplicated.
3306</p>
3307</dd>
3308<dt><code>/dev/stdin</code></dt>
3309<dd><p>File descriptor 0 is duplicated.
3310</p>
3311</dd>
3312<dt><code>/dev/stdout</code></dt>
3313<dd><p>File descriptor 1 is duplicated.
3314</p>
3315</dd>
3316<dt><code>/dev/stderr</code></dt>
3317<dd><p>File descriptor 2 is duplicated.
3318</p>
3319</dd>
3320<dt><code>/dev/tcp/<var>host</var>/<var>port</var></code></dt>
3321<dd><p>If <var>host</var> is a valid hostname or Internet address, and <var>port</var>
ac50fbac
CR
3322is an integer port number or service name, Bash attempts to open
3323the corresponding TCP socket.
a0c0a00f
CR
3324</p>
3325</dd>
3326<dt><code>/dev/udp/<var>host</var>/<var>port</var></code></dt>
3327<dd><p>If <var>host</var> is a valid hostname or Internet address, and <var>port</var>
ac50fbac
CR
3328is an integer port number or service name, Bash attempts to open
3329the corresponding UDP socket.
a0c0a00f
CR
3330</p></dd>
3331</dl>
17345e5a 3332
a0c0a00f
CR
3333<p>A failure to open or create a file causes the redirection to fail.
3334</p>
3335<p>Redirections using file descriptors greater than 9 should be used with
17345e5a
JA
3336care, as they may conflict with file descriptors the shell uses
3337internally.
a0c0a00f
CR
3338</p>
3339<a name="Redirecting-Input"></a>
3340<h4 class="subsection">3.6.1 Redirecting Input</h4>
3341<p>Redirection of input causes the file whose name results from
3342the expansion of <var>word</var>
3343to be opened for reading on file descriptor <code>n</code>,
3344or the standard input (file descriptor 0) if <code>n</code>
17345e5a 3345is not specified.
a0c0a00f
CR
3346</p>
3347<p>The general format for redirecting input is:
3348</p><div class="example">
3349<pre class="example">[<var>n</var>]&lt;<var>word</var>
3350</pre></div>
3351
3352<a name="Redirecting-Output"></a>
3353<h4 class="subsection">3.6.2 Redirecting Output</h4>
3354<p>Redirection of output causes the file whose name results from
3355the expansion of <var>word</var>
3356to be opened for writing on file descriptor <var>n</var>,
3357or the standard output (file descriptor 1) if <var>n</var>
17345e5a
JA
3358is not specified. If the file does not exist it is created;
3359if it does exist it is truncated to zero size.
a0c0a00f
CR
3360</p>
3361<p>The general format for redirecting output is:
3362</p><div class="example">
3363<pre class="example">[<var>n</var>]&gt;[|]<var>word</var>
3364</pre></div>
3365
3366<p>If the redirection operator is &lsquo;<samp>&gt;</samp>&rsquo;, and the <code>noclobber</code>
3367option to the <code>set</code> builtin has been enabled, the redirection
17345e5a 3368will fail if the file whose name results from the expansion of
a0c0a00f
CR
3369<var>word</var> exists and is a regular file.
3370If the redirection operator is &lsquo;<samp>&gt;|</samp>&rsquo;, or the redirection operator is
3371&lsquo;<samp>&gt;</samp>&rsquo; and the <code>noclobber</code> option is not enabled, the redirection
3372is attempted even if the file named by <var>word</var> exists.
3373</p>
3374<a name="Appending-Redirected-Output"></a>
3375<h4 class="subsection">3.6.3 Appending Redirected Output</h4>
3376<p>Redirection of output in this fashion
17345e5a 3377causes the file whose name results from
a0c0a00f
CR
3378the expansion of <var>word</var>
3379to be opened for appending on file descriptor <var>n</var>,
3380or the standard output (file descriptor 1) if <var>n</var>
17345e5a 3381is not specified. If the file does not exist it is created.
a0c0a00f
CR
3382</p>
3383<p>The general format for appending output is:
3384</p><div class="example">
3385<pre class="example">[<var>n</var>]&gt;&gt;<var>word</var>
3386</pre></div>
3387
3388<a name="Redirecting-Standard-Output-and-Standard-Error"></a>
3389<h4 class="subsection">3.6.4 Redirecting Standard Output and Standard Error</h4>
3390<p>This construct allows both the
17345e5a
JA
3391standard output (file descriptor 1) and
3392the standard error output (file descriptor 2)
3393to be redirected to the file whose name is the
a0c0a00f
CR
3394expansion of <var>word</var>.
3395</p>
3396<p>There are two formats for redirecting standard output and
17345e5a 3397standard error:
a0c0a00f
CR
3398</p><div class="example">
3399<pre class="example">&amp;&gt;<var>word</var>
3400</pre></div>
3401<p>and
3402</p><div class="example">
3403<pre class="example">&gt;&amp;<var>word</var>
3404</pre></div>
3405<p>Of the two forms, the first is preferred.
17345e5a 3406This is semantically equivalent to
a0c0a00f
CR
3407</p><div class="example">
3408<pre class="example">&gt;<var>word</var> 2&gt;&amp;1
3409</pre></div>
3410<p>When using the second form, <var>word</var> may not expand to a number or
3411&lsquo;<samp>-</samp>&rsquo;. If it does, other redirection operators apply
ac50fbac 3412(see Duplicating File Descriptors below) for compatibility reasons.
a0c0a00f
CR
3413</p>
3414<a name="Appending-Standard-Output-and-Standard-Error"></a>
3415<h4 class="subsection">3.6.5 Appending Standard Output and Standard Error</h4>
3416<p>This construct allows both the
17345e5a
JA
3417standard output (file descriptor 1) and
3418the standard error output (file descriptor 2)
3419to be appended to the file whose name is the
a0c0a00f
CR
3420expansion of <var>word</var>.
3421</p>
3422<p>The format for appending standard output and standard error is:
3423</p><div class="example">
3424<pre class="example">&amp;&gt;&gt;<var>word</var>
3425</pre></div>
3426<p>This is semantically equivalent to
3427</p><div class="example">
3428<pre class="example">&gt;&gt;<var>word</var> 2&gt;&amp;1
3429</pre></div>
3430<p>(see Duplicating File Descriptors below).
3431</p>
3432<a name="Here-Documents"></a>
3433<h4 class="subsection">3.6.6 Here Documents</h4>
3434<p>This type of redirection instructs the shell to read input from the
3435current source until a line containing only <var>word</var>
17345e5a
JA
3436(with no trailing blanks) is seen. All of
3437the lines read up to that point are then used as the standard
a0c0a00f
CR
3438input (or file descriptor <var>n</var> if <var>n</var> is specified) for a command.
3439</p>
3440<p>The format of here-documents is:
3441</p><div class="example">
3442<pre class="example">[<var>n</var>]&lt;&lt;[-]<var>word</var>
3443 <var>here-document</var>
3444<var>delimiter</var>
3445</pre></div>
3446
3447<p>No parameter and variable expansion, command substitution,
ac50fbac 3448arithmetic expansion, or filename expansion is performed on
a0c0a00f
CR
3449<var>word</var>. If any part of <var>word</var> is quoted, the
3450<var>delimiter</var> is the result of quote removal on <var>word</var>,
17345e5a 3451and the lines in the here-document are not expanded.
a0c0a00f 3452If <var>word</var> is unquoted,
ac50fbac
CR
3453all lines of the here-document are subjected to
3454parameter expansion, command substitution, and arithmetic expansion,
a0c0a00f 3455the character sequence <code>\newline</code> is ignored, and &lsquo;<samp>\</samp>&rsquo;
17345e5a 3456must be used to quote the characters
a0c0a00f
CR
3457&lsquo;<samp>\</samp>&rsquo;, &lsquo;<samp>$</samp>&rsquo;, and &lsquo;<samp>`</samp>&rsquo;.
3458</p>
3459<p>If the redirection operator is &lsquo;<samp>&lt;&lt;-</samp>&rsquo;,
17345e5a 3460then all leading tab characters are stripped from input lines and the
a0c0a00f 3461line containing <var>delimiter</var>.
17345e5a
JA
3462This allows here-documents within shell scripts to be indented in a
3463natural fashion.
a0c0a00f
CR
3464</p>
3465<a name="Here-Strings"></a>
3466<h4 class="subsection">3.6.7 Here Strings</h4>
3467<p>A variant of here documents, the format is:
3468</p><div class="example">
3469<pre class="example">[<var>n</var>]&lt;&lt;&lt; <var>word</var>
3470</pre></div>
3471
3472<p>The <var>word</var> undergoes
9a51695b 3473tilde expansion, parameter and variable expansion,
ac50fbac
CR
3474command substitution, arithmetic expansion, and quote removal.
3475Pathname expansion and word splitting are not performed.
a0c0a00f
CR
3476The result is supplied as a single string,
3477with a newline appended,
3478to the command on its
3479standard input (or file descriptor <var>n</var> if <var>n</var> is specified).
3480</p>
3481<a name="Duplicating-File-Descriptors"></a>
3482<h4 class="subsection">3.6.8 Duplicating File Descriptors</h4>
3483<p>The redirection operator
3484</p><div class="example">
3485<pre class="example">[<var>n</var>]&lt;&amp;<var>word</var>
3486</pre></div>
3487<p>is used to duplicate input file descriptors.
3488If <var>word</var>
3489expands to one or more digits, the file descriptor denoted by <var>n</var>
17345e5a 3490is made to be a copy of that file descriptor.
a0c0a00f 3491If the digits in <var>word</var> do not specify a file descriptor open for
17345e5a 3492input, a redirection error occurs.
a0c0a00f
CR
3493If <var>word</var>
3494evaluates to &lsquo;<samp>-</samp>&rsquo;, file descriptor <var>n</var> is closed.
3495If <var>n</var> is not specified, the standard input (file descriptor 0) is used.
3496</p>
3497<p>The operator
3498</p><div class="example">
3499<pre class="example">[<var>n</var>]&gt;&amp;<var>word</var>
3500</pre></div>
3501<p>is used similarly to duplicate output file descriptors. If
3502<var>n</var> is not specified, the standard output (file descriptor 1) is used.
3503If the digits in <var>word</var> do not specify a file descriptor open for
17345e5a 3504output, a redirection error occurs.
a0c0a00f
CR
3505If <var>word</var>
3506evaluates to &lsquo;<samp>-</samp>&rsquo;, file descriptor <var>n</var> is closed.
3507As a special case, if <var>n</var> is omitted, and <var>word</var> does not
3508expand to one or more digits or &lsquo;<samp>-</samp>&rsquo;, the standard output and standard
17345e5a 3509error are redirected as described previously.
a0c0a00f
CR
3510</p>
3511<a name="Moving-File-Descriptors"></a>
3512<h4 class="subsection">3.6.9 Moving File Descriptors</h4>
3513<p>The redirection operator
3514</p><div class="example">
3515<pre class="example">[<var>n</var>]&lt;&amp;<var>digit</var>-
3516</pre></div>
3517<p>moves the file descriptor <var>digit</var> to file descriptor <var>n</var>,
3518or the standard input (file descriptor 0) if <var>n</var> is not specified.
3519<var>digit</var> is closed after being duplicated to <var>n</var>.
3520</p>
3521<p>Similarly, the redirection operator
3522</p><div class="example">
3523<pre class="example">[<var>n</var>]&gt;&amp;<var>digit</var>-
3524</pre></div>
3525<p>moves the file descriptor <var>digit</var> to file descriptor <var>n</var>,
3526or the standard output (file descriptor 1) if <var>n</var> is not specified.
3527</p>
3528<a name="Opening-File-Descriptors-for-Reading-and-Writing"></a>
3529<h4 class="subsection">3.6.10 Opening File Descriptors for Reading and Writing</h4>
3530<p>The redirection operator
3531</p><div class="example">
3532<pre class="example">[<var>n</var>]&lt;&gt;<var>word</var>
3533</pre></div>
3534<p>causes the file whose name is the expansion of <var>word</var>
17345e5a 3535to be opened for both reading and writing on file descriptor
a0c0a00f 3536<var>n</var>, or on file descriptor 0 if <var>n</var>
17345e5a 3537is not specified. If the file does not exist, it is created.
a0c0a00f
CR
3538</p>
3539<hr>
3540<a name="Executing-Commands"></a>
3541<div class="header">
3542<p>
3543Next: <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>
3544</div>
3545<a name="Executing-Commands-1"></a>
3546<h3 class="section">3.7 Executing Commands</h3>
3547
3548<table class="menu" border="0" cellspacing="0">
3549<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
3550 executing them.
3551</td></tr>
3552<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.
3553</td></tr>
3554<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
17345e5a 3555 executes commands that are not
a0c0a00f
CR
3556 shell builtins.
3557</td></tr>
3558<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.
3559</td></tr>
3560<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
3561 interprets it.
3562</td></tr>
3563<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
3564 receives a signal.
3565</td></tr>
3566</table>
3567
3568<hr>
3569<a name="Simple-Command-Expansion"></a>
3570<div class="header">
3571<p>
3572Next: <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>
3573</div>
3574<a name="Simple-Command-Expansion-1"></a>
3575<h4 class="subsection">3.7.1 Simple Command Expansion</h4>
3576<a name="index-command-expansion"></a>
3577
3578<p>When a simple command is executed, the shell performs the following
17345e5a 3579expansions, assignments, and redirections, from left to right.
a0c0a00f
CR
3580</p>
3581<ol>
3582<li> The words that the parser has marked as variable assignments (those
17345e5a
JA
3583preceding the command name) and redirections are saved for later
3584processing.
17345e5a 3585
a0c0a00f
CR
3586</li><li> The words that are not variable assignments or redirections are
3587expanded (see <a href="#Shell-Expansions">Shell Expansions</a>).
17345e5a
JA
3588If any words remain after expansion, the first word
3589is taken to be the name of the command and the remaining words are
3590the arguments.
17345e5a 3591
a0c0a00f 3592</li><li> Redirections are performed as described above (see <a href="#Redirections">Redirections</a>).
17345e5a 3593
a0c0a00f 3594</li><li> The text after the &lsquo;<samp>=</samp>&rsquo; in each variable assignment undergoes tilde
17345e5a
JA
3595expansion, parameter expansion, command substitution, arithmetic expansion,
3596and quote removal before being assigned to the variable.
a0c0a00f 3597</li></ol>
17345e5a 3598
a0c0a00f 3599<p>If no command name results, the variable assignments affect the current
17345e5a
JA
3600shell environment. Otherwise, the variables are added to the environment
3601of the executed command and do not affect the current shell environment.
3602If any of the assignments attempts to assign a value to a readonly variable,
3603an error occurs, and the command exits with a non-zero status.
a0c0a00f
CR
3604</p>
3605<p>If no command name results, redirections are performed, but do not
17345e5a
JA
3606affect the current shell environment. A redirection error causes the
3607command to exit with a non-zero status.
a0c0a00f
CR
3608</p>
3609<p>If there is a command name left after expansion, execution proceeds as
17345e5a
JA
3610described below. Otherwise, the command exits. If one of the expansions
3611contained a command substitution, the exit status of the command is
3612the exit status of the last command substitution performed. If there
3613were no command substitutions, the command exits with a status of zero.
a0c0a00f
CR
3614</p>
3615<hr>
3616<a name="Command-Search-and-Execution"></a>
3617<div class="header">
3618<p>
3619Next: <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>
3620</div>
3621<a name="Command-Search-and-Execution-1"></a>
3622<h4 class="subsection">3.7.2 Command Search and Execution</h4>
3623<a name="index-command-execution"></a>
3624<a name="index-command-search"></a>
3625
3626<p>After a command has been split into words, if it results in a
17345e5a
JA
3627simple command and an optional list of arguments, the following
3628actions are taken.
a0c0a00f
CR
3629</p>
3630<ol>
3631<li> If the command name contains no slashes, the shell attempts to
17345e5a 3632locate it. If there exists a shell function by that name, that
a0c0a00f 3633function is invoked as described in <a href="#Shell-Functions">Shell Functions</a>.
17345e5a 3634
a0c0a00f 3635</li><li> If the name does not match a function, the shell searches for
17345e5a
JA
3636it in the list of shell builtins. If a match is found, that
3637builtin is invoked.
17345e5a 3638
a0c0a00f 3639</li><li> If the name is neither a shell function nor a builtin,
17345e5a 3640and contains no slashes, Bash searches each element of
a0c0a00f 3641<code>$PATH</code> for a directory containing an executable file
17345e5a 3642by that name. Bash uses a hash table to remember the full
a0c0a00f
CR
3643pathnames of executable files to avoid multiple <code>PATH</code> searches
3644(see the description of <code>hash</code> in <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
3645A full search of the directories in <code>$PATH</code>
17345e5a
JA
3646is performed only if the command is not found in the hash table.
3647If the search is unsuccessful, the shell searches for a defined shell
a0c0a00f 3648function named <code>command_not_found_handle</code>.
9a51695b
CR
3649If that function exists, it is invoked in a separate execution environment
3650with the original command and
a0c0a00f 3651the original command&rsquo;s arguments as its arguments, and the function&rsquo;s
9a51695b 3652exit status becomes the exit status of that subshell.
17345e5a
JA
3653If that function is not defined, the shell prints an error
3654message and returns an exit status of 127.
17345e5a 3655
a0c0a00f 3656</li><li> If the search is successful, or if the command name contains
17345e5a
JA
3657one or more slashes, the shell executes the named program in
3658a separate execution environment.
3659Argument 0 is set to the name given, and the remaining arguments
3660to the command are set to the arguments supplied, if any.
17345e5a 3661
a0c0a00f 3662</li><li> If this execution fails because the file is not in executable
17345e5a 3663format, and the file is not a directory, it is assumed to be a
a0c0a00f
CR
3664<var>shell script</var> and the shell executes it as described in
3665<a href="#Shell-Scripts">Shell Scripts</a>.
17345e5a 3666
a0c0a00f 3667</li><li> If the command was not begun asynchronously, the shell waits for
17345e5a 3668the command to complete and collects its exit status.
a0c0a00f
CR
3669
3670</li></ol>
3671
3672<hr>
3673<a name="Command-Execution-Environment"></a>
3674<div class="header">
3675<p>
3676Next: <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>
3677</div>
3678<a name="Command-Execution-Environment-1"></a>
3679<h4 class="subsection">3.7.3 Command Execution Environment</h4>
3680<a name="index-execution-environment"></a>
3681
3682<p>The shell has an <var>execution environment</var>, which consists of the
17345e5a 3683following:
a0c0a00f
CR
3684</p>
3685<ul>
3686<li> open files inherited by the shell at invocation, as modified by
3687redirections supplied to the <code>exec</code> builtin
3688
3689</li><li> the current working directory as set by <code>cd</code>, <code>pushd</code>, or
3690<code>popd</code>, or inherited by the shell at invocation
3691
3692</li><li> the file creation mode mask as set by <code>umask</code> or inherited from
3693the shell&rsquo;s parent
3694
3695</li><li> current traps set by <code>trap</code>
3696
3697</li><li> shell parameters that are set by variable assignment or with <code>set</code>
3698or inherited from the shell&rsquo;s parent in the environment
3699
3700</li><li> shell functions defined during execution or inherited from the shell&rsquo;s
17345e5a 3701parent in the environment
17345e5a 3702
a0c0a00f
CR
3703</li><li> options enabled at invocation (either by default or with command-line
3704arguments) or by <code>set</code>
17345e5a 3705
a0c0a00f 3706</li><li> options enabled by <code>shopt</code> (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>)
17345e5a 3707
a0c0a00f 3708</li><li> shell aliases defined with <code>alias</code> (see <a href="#Aliases">Aliases</a>)
17345e5a 3709
a0c0a00f
CR
3710</li><li> various process <small>ID</small>s, including those of background jobs
3711(see <a href="#Lists">Lists</a>), the value of <code>$$</code>, and the value of
3712<code>$PPID</code>
17345e5a 3713
a0c0a00f 3714</li></ul>
17345e5a 3715
a0c0a00f 3716<p>When a simple command other than a builtin or shell function
17345e5a
JA
3717is to be executed, it
3718is invoked in a separate execution environment that consists of
3719the following. Unless otherwise noted, the values are inherited
3720from the shell.
a0c0a00f
CR
3721</p>
3722<ul>
3723<li> the shell&rsquo;s open files, plus any modifications and additions specified
17345e5a 3724by redirections to the command
17345e5a 3725
a0c0a00f 3726</li><li> the current working directory
17345e5a 3727
a0c0a00f 3728</li><li> the file creation mode mask
17345e5a 3729
a0c0a00f
CR
3730</li><li> shell variables and functions marked for export, along with variables
3731exported for the command, passed in the environment (see <a href="#Environment">Environment</a>)
17345e5a 3732
a0c0a00f
CR
3733</li><li> traps caught by the shell are reset to the values inherited from the
3734shell&rsquo;s parent, and traps ignored by the shell are ignored
17345e5a 3735
a0c0a00f 3736</li></ul>
17345e5a 3737
a0c0a00f
CR
3738<p>A command invoked in this separate environment cannot affect the
3739shell&rsquo;s execution environment.
3740</p>
3741<p>Command substitution, commands grouped with parentheses,
17345e5a
JA
3742and asynchronous commands are invoked in a
3743subshell environment that is a duplicate of the shell environment,
3744except that traps caught by the shell are reset to the values
3745that the shell inherited from its parent at invocation. Builtin
3746commands that are invoked as part of a pipeline are also executed
3747in a subshell environment. Changes made to the subshell environment
a0c0a00f
CR
3748cannot affect the shell&rsquo;s execution environment.
3749</p>
3750<p>Subshells spawned to execute command substitutions inherit the value of
3751the <samp>-e</samp> option from the parent shell. When not in <small>POSIX</small> mode,
3752Bash clears the <samp>-e</samp> option in such subshells.
3753</p>
3754<p>If a command is followed by a &lsquo;<samp>&amp;</samp>&rsquo; and job control is not active, the
3755default standard input for the command is the empty file <samp>/dev/null</samp>.
17345e5a
JA
3756Otherwise, the invoked command inherits the file descriptors of the calling
3757shell as modified by redirections.
a0c0a00f
CR
3758</p>
3759<hr>
3760<a name="Environment"></a>
3761<div class="header">
3762<p>
3763Next: <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>
3764</div>
3765<a name="Environment-1"></a>
3766<h4 class="subsection">3.7.4 Environment</h4>
3767<a name="index-environment"></a>
3768
3769<p>When a program is invoked it is given an array of strings
3770called the <var>environment</var>.
3771This is a list of name-value pairs, of the form <code>name=value</code>.
3772</p>
3773<p>Bash provides several ways to manipulate the environment.
17345e5a
JA
3774On invocation, the shell scans its own environment and
3775creates a parameter for each name found, automatically marking
a0c0a00f 3776it for <var>export</var>
17345e5a 3777to child processes. Executed commands inherit the environment.
a0c0a00f 3778The <code>export</code> and &lsquo;<samp>declare -x</samp>&rsquo;
17345e5a
JA
3779commands allow parameters and functions to be added to and
3780deleted from the environment. If the value of a parameter
3781in the environment is modified, the new value becomes part
3782of the environment, replacing the old. The environment
a0c0a00f 3783inherited by any executed command consists of the shell&rsquo;s
17345e5a 3784initial environment, whose values may be modified in the shell,
a0c0a00f
CR
3785less any pairs removed by the <code>unset</code> and &lsquo;<samp>export -n</samp>&rsquo;
3786commands, plus any additions via the <code>export</code> and
3787&lsquo;<samp>declare -x</samp>&rsquo; commands.
3788</p>
3789<p>The environment for any simple command
17345e5a 3790or function may be augmented temporarily by prefixing it with
a0c0a00f 3791parameter assignments, as described in <a href="#Shell-Parameters">Shell Parameters</a>.
17345e5a
JA
3792These assignment statements affect only the environment seen
3793by that command.
a0c0a00f
CR
3794</p>
3795<p>If the <samp>-k</samp> option is set (see <a href="#The-Set-Builtin">The Set Builtin</a>), then all
17345e5a
JA
3796parameter assignments are placed in the environment for a command,
3797not just those that precede the command name.
a0c0a00f
CR
3798</p>
3799<p>When Bash invokes an external command, the variable &lsquo;<samp>$_</samp>&rsquo;
ac50fbac 3800is set to the full pathname of the command and passed to that
17345e5a 3801command in its environment.
a0c0a00f
CR
3802</p>
3803<hr>
3804<a name="Exit-Status"></a>
3805<div class="header">
3806<p>
3807Next: <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>
3808</div>
3809<a name="Exit-Status-1"></a>
3810<h4 class="subsection">3.7.5 Exit Status</h4>
3811<a name="index-exit-status-1"></a>
3812
3813<p>The exit status of an executed command is the value returned by the
3814<var>waitpid</var> system call or equivalent function. Exit statuses
17345e5a
JA
3815fall between 0 and 255, though, as explained below, the shell may
3816use values above 125 specially. Exit statuses from shell builtins and
ac50fbac 3817compound commands are also limited to this range. Under certain
17345e5a
JA
3818circumstances, the shell will use special values to indicate specific
3819failure modes.
a0c0a00f
CR
3820</p>
3821<p>For the shell&rsquo;s purposes, a command which exits with a
17345e5a
JA
3822zero exit status has succeeded.
3823A non-zero exit status indicates failure.
3824This seemingly counter-intuitive scheme is used so there
3825is one well-defined way to indicate success and a variety of
3826ways to indicate various failure modes.
a0c0a00f
CR
3827When a command terminates on a fatal signal whose number is <var>N</var>,
3828Bash uses the value 128+<var>N</var> as the exit status.
3829</p>
3830<p>If a command is not found, the child process created to
17345e5a
JA
3831execute it returns a status of 127. If a command is found
3832but is not executable, the return status is 126.
a0c0a00f
CR
3833</p>
3834<p>If a command fails because of an error during expansion or redirection,
17345e5a 3835the exit status is greater than zero.
a0c0a00f
CR
3836</p>
3837<p>The exit status is used by the Bash conditional commands
3838(see <a href="#Conditional-Constructs">Conditional Constructs</a>) and some of the list
3839constructs (see <a href="#Lists">Lists</a>).
3840</p>
3841<p>All of the Bash builtins return an exit status of zero if they succeed
17345e5a
JA
3842and a non-zero status on failure, so they may be used by the
3843conditional and list constructs.
a0c0a00f
CR
3844All builtins return an exit status of 2 to indicate incorrect usage,
3845generally invalid options or missing arguments.
3846</p>
3847<hr>
3848<a name="Signals"></a>
3849<div class="header">
3850<p>
3851Previous: <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>
3852</div>
3853<a name="Signals-1"></a>
3854<h4 class="subsection">3.7.6 Signals</h4>
3855<a name="index-signal-handling"></a>
3856
3857<p>When Bash is interactive, in the absence of any traps, it ignores
3858<code>SIGTERM</code> (so that &lsquo;<samp>kill 0</samp>&rsquo; does not kill an interactive shell),
3859and <code>SIGINT</code>
3860is caught and handled (so that the <code>wait</code> builtin is interruptible).
3861When Bash receives a <code>SIGINT</code>, it breaks out of any executing loops.
3862In all cases, Bash ignores <code>SIGQUIT</code>.
3863If job control is in effect (see <a href="#Job-Control">Job Control</a>), Bash
3864ignores <code>SIGTTIN</code>, <code>SIGTTOU</code>, and <code>SIGTSTP</code>.
3865</p>
3866<p>Non-builtin commands started by Bash have signal handlers set to the
17345e5a
JA
3867values inherited by the shell from its parent.
3868When job control is not in effect, asynchronous commands
a0c0a00f 3869ignore <code>SIGINT</code> and <code>SIGQUIT</code> in addition to these inherited
17345e5a
JA
3870handlers.
3871Commands run as a result of
3872command substitution ignore the keyboard-generated job control signals
a0c0a00f
CR
3873<code>SIGTTIN</code>, <code>SIGTTOU</code>, and <code>SIGTSTP</code>.
3874</p>
3875<p>The shell exits by default upon receipt of a <code>SIGHUP</code>.
3876Before exiting, an interactive shell resends the <code>SIGHUP</code> to
17345e5a 3877all jobs, running or stopped.
a0c0a00f
CR
3878Stopped jobs are sent <code>SIGCONT</code> to ensure that they receive
3879the <code>SIGHUP</code>.
3880To prevent the shell from sending the <code>SIGHUP</code> signal to a
17345e5a 3881particular job, it should be removed
a0c0a00f
CR
3882from the jobs table with the <code>disown</code>
3883builtin (see <a href="#Job-Control-Builtins">Job Control Builtins</a>) or marked
3884to not receive <code>SIGHUP</code> using <code>disown -h</code>.
3885</p>
3886<p>If the <code>huponexit</code> shell option has been set with <code>shopt</code>
3887(see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), Bash sends a <code>SIGHUP</code> to all jobs when
17345e5a 3888an interactive login shell exits.
a0c0a00f
CR
3889</p>
3890<p>If Bash is waiting for a command to complete and receives a signal
17345e5a 3891for which a trap has been set, the trap will not be executed until
a0c0a00f 3892the command completes.
17345e5a 3893When Bash is waiting for an asynchronous
a0c0a00f
CR
3894command via the <code>wait</code> builtin, the reception of a signal for
3895which a trap has been set will cause the <code>wait</code> builtin to return
17345e5a
JA
3896immediately with an exit status greater than 128, immediately after
3897which the trap is executed.
a0c0a00f
CR
3898</p>
3899<hr>
3900<a name="Shell-Scripts"></a>
3901<div class="header">
3902<p>
3903Previous: <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>
3904</div>
3905<a name="Shell-Scripts-1"></a>
3906<h3 class="section">3.8 Shell Scripts</h3>
3907<a name="index-shell-script"></a>
3908
3909<p>A shell script is a text file containing shell commands. When such
17345e5a 3910a file is used as the first non-option argument when invoking Bash,
a0c0a00f
CR
3911and neither the <samp>-c</samp> nor <samp>-s</samp> option is supplied
3912(see <a href="#Invoking-Bash">Invoking Bash</a>),
17345e5a
JA
3913Bash reads and executes commands from the file, then exits. This
3914mode of operation creates a non-interactive shell. The shell first
3915searches for the file in the current directory, and looks in the
a0c0a00f
CR
3916directories in <code>$PATH</code> if not found there.
3917</p>
3918<p>When Bash runs
3919a shell script, it sets the special parameter <code>0</code> to the name
17345e5a
JA
3920of the file, rather than the name of the shell, and the positional
3921parameters are set to the remaining arguments, if any are given.
3922If no additional arguments are supplied, the positional parameters
3923are unset.
a0c0a00f
CR
3924</p>
3925<p>A shell script may be made executable by using the <code>chmod</code> command
17345e5a 3926to turn on the execute bit. When Bash finds such a file while
a0c0a00f 3927searching the <code>$PATH</code> for a command, it spawns a subshell to
17345e5a 3928execute it. In other words, executing
a0c0a00f
CR
3929</p><div class="example">
3930<pre class="example">filename <var>arguments</var>
3931</pre></div>
3932<p>is equivalent to executing
3933</p><div class="example">
3934<pre class="example">bash filename <var>arguments</var>
3935</pre></div>
3936
3937<p>if <code>filename</code> is an executable shell script.
17345e5a
JA
3938This subshell reinitializes itself, so that the effect is as if a
3939new shell had been invoked to interpret the script, with the
3940exception that the locations of commands remembered by the parent
a0c0a00f 3941(see the description of <code>hash</code> in <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>)
17345e5a 3942are retained by the child.
a0c0a00f
CR
3943</p>
3944<p>Most versions of Unix make this a part of the operating system&rsquo;s command
17345e5a 3945execution mechanism. If the first line of a script begins with
a0c0a00f 3946the two characters &lsquo;<samp>#!</samp>&rsquo;, the remainder of the line specifies
17345e5a 3947an interpreter for the program.
a0c0a00f 3948Thus, you can specify Bash, <code>awk</code>, Perl, or some other
17345e5a 3949interpreter and write the rest of the script file in that language.
a0c0a00f
CR
3950</p>
3951<p>The arguments to the interpreter
17345e5a
JA
3952consist of a single optional argument following the interpreter
3953name on the first line of the script file, followed by the name of
3954the script file, followed by the rest of the arguments. Bash
3955will perform this action on operating systems that do not handle it
3956themselves. Note that some older versions of Unix limit the interpreter
3957name and argument to a maximum of 32 characters.
a0c0a00f
CR
3958</p>
3959<p>Bash scripts often begin with <code>#! /bin/bash</code> (assuming that
3960Bash has been installed in <samp>/bin</samp>), since this ensures that
17345e5a
JA
3961Bash will be used to interpret the script, even if it is executed
3962under another shell.
a0c0a00f
CR
3963</p>
3964<hr>
3965<a name="Shell-Builtin-Commands"></a>
3966<div class="header">
3967<p>
3968Next: <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>
3969</div>
3970<a name="Shell-Builtin-Commands-1"></a>
3971<h2 class="chapter">4 Shell Builtin Commands</h2>
3972
3973<table class="menu" border="0" cellspacing="0">
3974<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
3975 Shell.
3976</td></tr>
3977<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.
3978</td></tr>
3979<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
3980 optional behavior.
3981</td></tr>
3982<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
3983 POSIX.
3984</td></tr>
3985</table>
3986
3987<p>Builtin commands are contained within the shell itself.
17345e5a 3988When the name of a builtin command is used as the first word of
a0c0a00f 3989a simple command (see <a href="#Simple-Commands">Simple Commands</a>), the shell executes
17345e5a
JA
3990the command directly, without invoking another program.
3991Builtin commands are necessary to implement functionality impossible
3992or inconvenient to obtain with separate utilities.
a0c0a00f
CR
3993</p>
3994<p>This section briefly describes the builtins which Bash inherits from
17345e5a
JA
3995the Bourne Shell, as well as the builtin commands which are unique
3996to or have been extended in Bash.
a0c0a00f
CR
3997</p>
3998<p>Several builtin commands are described in other chapters: builtin
17345e5a 3999commands which provide the Bash interface to the job control
a0c0a00f
CR
4000facilities (see <a href="#Job-Control-Builtins">Job Control Builtins</a>), the directory stack
4001(see <a href="#Directory-Stack-Builtins">Directory Stack Builtins</a>), the command history
4002(see <a href="#Bash-History-Builtins">Bash History Builtins</a>), and the programmable completion
4003facilities (see <a href="#Programmable-Completion-Builtins">Programmable Completion Builtins</a>).
4004</p>
4005<p>Many of the builtins have been extended by <small>POSIX</small> or Bash.
4006</p>
4007<p>Unless otherwise noted, each builtin command documented as accepting
4008options preceded by &lsquo;<samp>-</samp>&rsquo; accepts &lsquo;<samp>--</samp>&rsquo;
17345e5a 4009to signify the end of the options.
9a51695b 4010The <code>:</code>, <code>true</code>, <code>false</code>, and <code>test</code>/<code>[</code>
a0c0a00f
CR
4011builtins do not accept options and do not treat &lsquo;<samp>--</samp>&rsquo; specially.
4012The <code>exit</code>, <code>logout</code>, <code>return</code>,
4013<code>break</code>, <code>continue</code>, <code>let</code>,
4014and <code>shift</code> builtins accept and process arguments beginning
4015with &lsquo;<samp>-</samp>&rsquo; without requiring &lsquo;<samp>--</samp>&rsquo;.
0001803f 4016Other builtins that accept arguments but are not specified as accepting
a0c0a00f
CR
4017options interpret arguments beginning with &lsquo;<samp>-</samp>&rsquo; as invalid options and
4018require &lsquo;<samp>--</samp>&rsquo; to prevent this interpretation.
4019</p>
4020<hr>
4021<a name="Bourne-Shell-Builtins"></a>
4022<div class="header">
4023<p>
4024Next: <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>
4025</div>
4026<a name="Bourne-Shell-Builtins-1"></a>
4027<h3 class="section">4.1 Bourne Shell Builtins</h3>
4028
4029<p>The following shell builtin commands are inherited from the Bourne Shell.
4030These commands are implemented as specified by the <small>POSIX</small> standard.
4031</p>
4032<dl compact="compact">
4033<dt><code>: <span class="roman">(a colon)</span></code></dt>
4034<dd><a name="index-_003a"></a>
4035<div class="example">
4036<pre class="example">: [<var>arguments</var>]
4037</pre></div>
4038
4039<p>Do nothing beyond expanding <var>arguments</var> and performing redirections.
17345e5a 4040The return status is zero.
a0c0a00f
CR
4041</p>
4042</dd>
4043<dt><code>. <span class="roman">(a period)</span></code></dt>
4044<dd><a name="index-_002e"></a>
4045<div class="example">
4046<pre class="example">. <var>filename</var> [<var>arguments</var>]
4047</pre></div>
4048
4049<p>Read and execute commands from the <var>filename</var> argument in the
4050current shell context. If <var>filename</var> does not contain a slash,
4051the <code>PATH</code> variable is used to find <var>filename</var>.
4052When Bash is not in <small>POSIX</small> mode, the current directory is searched
4053if <var>filename</var> is not found in <code>$PATH</code>.
4054If any <var>arguments</var> are supplied, they become the positional
4055parameters when <var>filename</var> is executed. Otherwise the positional
17345e5a 4056parameters are unchanged.
a0c0a00f
CR
4057If the <samp>-T</samp> option is enabled, <code>source</code> inherits any trap on
4058<code>DEBUG</code>; if it is not, any <code>DEBUG</code> trap string is saved and
4059restored around the call to <code>source</code>, and <code>source</code> unsets the
4060<code>DEBUG</code> trap while it executes.
4061If <samp>-T</samp> is not set, and the sourced file changes
4062the <code>DEBUG</code> trap, the new value is retained when <code>source</code> completes.
17345e5a 4063The return status is the exit status of the last command executed, or
a0c0a00f 4064zero if no commands are executed. If <var>filename</var> is not found, or
17345e5a 4065cannot be read, the return status is non-zero.
a0c0a00f
CR
4066This builtin is equivalent to <code>source</code>.
4067</p>
4068</dd>
4069<dt><code>break</code></dt>
4070<dd><a name="index-break"></a>
4071<div class="example">
4072<pre class="example">break [<var>n</var>]
4073</pre></div>
4074
4075<p>Exit from a <code>for</code>, <code>while</code>, <code>until</code>, or <code>select</code> loop.
4076If <var>n</var> is supplied, the <var>n</var>th enclosing loop is exited.
4077<var>n</var> must be greater than or equal to 1.
4078The return status is zero unless <var>n</var> is not greater than or equal to 1.
4079</p>
4080</dd>
4081<dt><code>cd</code></dt>
4082<dd><a name="index-cd"></a>
4083<div class="example">
4084<pre class="example">cd [-L|[-P [-e]] [-@] [<var>directory</var>]
4085</pre></div>
4086
4087<p>Change the current working directory to <var>directory</var>.
4088If <var>directory</var> is not supplied, the value of the <code>HOME</code>
ac50fbac 4089shell variable is used.
a0c0a00f 4090Any additional arguments following <var>directory</var> are ignored.
ac50fbac 4091If the shell variable
a0c0a00f
CR
4092<code>CDPATH</code> exists, it is used as a search path:
4093each directory name in <code>CDPATH</code> is searched for
4094<var>directory</var>, with alternative directory names in <code>CDPATH</code>
4095separated by a colon (&lsquo;<samp>:</samp>&rsquo;).
4096If <var>directory</var> begins with a slash, <code>CDPATH</code> is not used.
4097</p>
4098<p>The <samp>-P</samp> option means to not follow symbolic links: symbolic links
4099are resolved while <code>cd</code> is traversing <var>directory</var> and before
4100processing an instance of &lsquo;<samp>..</samp>&rsquo; in <var>directory</var>.
4101</p>
4102<p>By default, or when the <samp>-L</samp> option is supplied, symbolic links
4103in <var>directory</var> are resolved after <code>cd</code> processes an instance
4104of &lsquo;<samp>..</samp>&rsquo; in <var>directory</var>.
4105</p>
4106<p>If &lsquo;<samp>..</samp>&rsquo; appears in <var>directory</var>, it is processed by removing the
ac50fbac 4107immediately preceding pathname component, back to a slash or the beginning
a0c0a00f
CR
4108of <var>directory</var>.
4109</p>
4110<p>If the <samp>-e</samp> option is supplied with <samp>-P</samp>
495aee44 4111and the current working directory cannot be successfully determined
a0c0a00f 4112after a successful directory change, <code>cd</code> will return an unsuccessful
495aee44 4113status.
a0c0a00f
CR
4114</p>
4115<p>On systems that support it, the <samp>-@</samp> option presents the extended
ac50fbac 4116attributes associated with a file as a directory.
a0c0a00f
CR
4117</p>
4118<p>If <var>directory</var> is &lsquo;<samp>-</samp>&rsquo;, it is converted to <code>$OLDPWD</code>
ac50fbac 4119before the directory change is attempted.
a0c0a00f
CR
4120</p>
4121<p>If a non-empty directory name from <code>CDPATH</code> is used, or if
4122&lsquo;<samp>-</samp>&rsquo; is the first argument, and the directory change is
17345e5a
JA
4123successful, the absolute pathname of the new working directory is
4124written to the standard output.
a0c0a00f
CR
4125</p>
4126<p>The return status is zero if the directory is successfully changed,
17345e5a 4127non-zero otherwise.
a0c0a00f
CR
4128</p>
4129</dd>
4130<dt><code>continue</code></dt>
4131<dd><a name="index-continue"></a>
4132<div class="example">
4133<pre class="example">continue [<var>n</var>]
4134</pre></div>
4135
4136<p>Resume the next iteration of an enclosing <code>for</code>, <code>while</code>,
4137<code>until</code>, or <code>select</code> loop.
4138If <var>n</var> is supplied, the execution of the <var>n</var>th enclosing loop
17345e5a 4139is resumed.
a0c0a00f
CR
4140<var>n</var> must be greater than or equal to 1.
4141The return status is zero unless <var>n</var> is not greater than or equal to 1.
4142</p>
4143</dd>
4144<dt><code>eval</code></dt>
4145<dd><a name="index-eval"></a>
4146<div class="example">
4147<pre class="example">eval [<var>arguments</var>]
4148</pre></div>
4149
4150<p>The arguments are concatenated together into a single command, which is
17345e5a 4151then read and executed, and its exit status returned as the exit status
a0c0a00f 4152of <code>eval</code>.
17345e5a
JA
4153If there are no arguments or only empty arguments, the return status is
4154zero.
a0c0a00f
CR
4155</p>
4156</dd>
4157<dt><code>exec</code></dt>
4158<dd><a name="index-exec"></a>
4159<div class="example">
4160<pre class="example">exec [-cl] [-a <var>name</var>] [<var>command</var> [<var>arguments</var>]]
4161</pre></div>
4162
4163<p>If <var>command</var>
17345e5a 4164is supplied, it replaces the shell without creating a new process.
a0c0a00f
CR
4165If the <samp>-l</samp> option is supplied, the shell places a dash at the
4166beginning of the zeroth argument passed to <var>command</var>.
4167This is what the <code>login</code> program does.
4168The <samp>-c</samp> option causes <var>command</var> to be executed with an empty
17345e5a 4169environment.
a0c0a00f
CR
4170If <samp>-a</samp> is supplied, the shell passes <var>name</var> as the zeroth
4171argument to <var>command</var>.
4172If <var>command</var>
ac50fbac 4173cannot be executed for some reason, a non-interactive shell exits,
a0c0a00f 4174unless the <code>execfail</code> shell option
ac50fbac
CR
4175is enabled. In that case, it returns failure.
4176An interactive shell returns failure if the file cannot be executed.
9a51695b 4177A subshell exits unconditionally if <code>exec</code> fails.
a0c0a00f 4178If no <var>command</var> is specified, redirections may be used to affect
17345e5a
JA
4179the current shell environment. If there are no redirection errors, the
4180return status is zero; otherwise the return status is non-zero.
a0c0a00f
CR
4181</p>
4182</dd>
4183<dt><code>exit</code></dt>
4184<dd><a name="index-exit"></a>
4185<div class="example">
4186<pre class="example">exit [<var>n</var>]
4187</pre></div>
4188
4189<p>Exit the shell, returning a status of <var>n</var> to the shell&rsquo;s parent.
4190If <var>n</var> is omitted, the exit status is that of the last command executed.
4191Any trap on <code>EXIT</code> is executed before the shell terminates.
4192</p>
4193</dd>
4194<dt><code>export</code></dt>
4195<dd><a name="index-export"></a>
4196<div class="example">
4197<pre class="example">export [-fn] [-p] [<var>name</var>[=<var>value</var>]]
4198</pre></div>
4199
4200<p>Mark each <var>name</var> to be passed to child processes
4201in the environment. If the <samp>-f</samp> option is supplied, the <var>name</var>s
17345e5a 4202refer to shell functions; otherwise the names refer to shell variables.
a0c0a00f
CR
4203The <samp>-n</samp> option means to no longer mark each <var>name</var> for export.
4204If no <var>names</var> are supplied, or if the <samp>-p</samp> option is given, a
ac50fbac 4205list of names of all exported variables is displayed.
a0c0a00f
CR
4206The <samp>-p</samp> option displays output in a form that may be reused as input.
4207If a variable name is followed by =<var>value</var>, the value of
4208the variable is set to <var>value</var>.
4209</p>
4210<p>The return status is zero unless an invalid option is supplied, one of
4211the names is not a valid shell variable name, or <samp>-f</samp> is supplied
17345e5a 4212with a name that is not a shell function.
a0c0a00f
CR
4213</p>
4214</dd>
4215<dt><code>getopts</code></dt>
4216<dd><a name="index-getopts"></a>
4217<div class="example">
4218<pre class="example">getopts <var>optstring</var> <var>name</var> [<var>args</var>]
4219</pre></div>
4220
4221<p><code>getopts</code> is used by shell scripts to parse positional parameters.
4222<var>optstring</var> contains the option characters to be recognized; if a
17345e5a 4223character is followed by a colon, the option is expected to have an
ac50fbac 4224argument, which should be separated from it by whitespace.
a0c0a00f 4225The colon (&lsquo;<samp>:</samp>&rsquo;) and question mark (&lsquo;<samp>?</samp>&rsquo;) may not be
17345e5a 4226used as option characters.
a0c0a00f
CR
4227Each time it is invoked, <code>getopts</code>
4228places the next option in the shell variable <var>name</var>, initializing
4229<var>name</var> if it does not exist,
17345e5a 4230and the index of the next argument to be processed into the
a0c0a00f
CR
4231variable <code>OPTIND</code>.
4232<code>OPTIND</code> is initialized to 1 each time the shell or a shell script
17345e5a
JA
4233is invoked.
4234When an option requires an argument,
a0c0a00f
CR
4235<code>getopts</code> places that argument into the variable <code>OPTARG</code>.
4236The shell does not reset <code>OPTIND</code> automatically; it must be manually
4237reset between multiple calls to <code>getopts</code> within the same shell
17345e5a 4238invocation if a new set of parameters is to be used.
a0c0a00f
CR
4239</p>
4240<p>When the end of options is encountered, <code>getopts</code> exits with a
17345e5a 4241return value greater than zero.
a0c0a00f
CR
4242<code>OPTIND</code> is set to the index of the first non-option argument,
4243and <var>name</var> is set to &lsquo;<samp>?</samp>&rsquo;.
4244</p>
4245<p><code>getopts</code>
17345e5a 4246normally parses the positional parameters, but if more arguments are
a0c0a00f
CR
4247given in <var>args</var>, <code>getopts</code> parses those instead.
4248</p>
4249<p><code>getopts</code> can report errors in two ways. If the first character of
4250<var>optstring</var> is a colon, <var>silent</var>
ac50fbac 4251error reporting is used. In normal operation, diagnostic messages
17345e5a
JA
4252are printed when invalid options or missing option arguments are
4253encountered.
a0c0a00f 4254If the variable <code>OPTERR</code>
17345e5a 4255is set to 0, no error messages will be displayed, even if the first
a0c0a00f
CR
4256character of <code>optstring</code> is not a colon.
4257</p>
4258<p>If an invalid option is seen,
4259<code>getopts</code> places &lsquo;<samp>?</samp>&rsquo; into <var>name</var> and, if not silent,
4260prints an error message and unsets <code>OPTARG</code>.
4261If <code>getopts</code> is silent, the option character found is placed in
4262<code>OPTARG</code> and no diagnostic message is printed.
4263</p>
4264<p>If a required argument is not found, and <code>getopts</code>
4265is not silent, a question mark (&lsquo;<samp>?</samp>&rsquo;) is placed in <var>name</var>,
4266<code>OPTARG</code> is unset, and a diagnostic message is printed.
4267If <code>getopts</code> is silent, then a colon (&lsquo;<samp>:</samp>&rsquo;) is placed in
4268<var>name</var> and <code>OPTARG</code> is set to the option character found.
4269</p>
4270</dd>
4271<dt><code>hash</code></dt>
4272<dd><a name="index-hash"></a>
4273<div class="example">
4274<pre class="example">hash [-r] [-p <var>filename</var>] [-dt] [<var>name</var>]
4275</pre></div>
4276
4277<p>Each time <code>hash</code> is invoked, it remembers the full pathnames of the
4278commands specified as <var>name</var> arguments,
17345e5a
JA
4279so they need not be searched for on subsequent invocations.
4280The commands are found by searching through the directories listed in
a0c0a00f 4281<code>$PATH</code>.
495aee44 4282Any previously-remembered pathname is discarded.
a0c0a00f
CR
4283The <samp>-p</samp> option inhibits the path search, and <var>filename</var> is
4284used as the location of <var>name</var>.
4285The <samp>-r</samp> option causes the shell to forget all remembered locations.
4286The <samp>-d</samp> option causes the shell to forget the remembered location
4287of each <var>name</var>.
4288If the <samp>-t</samp> option is supplied, the full pathname to which each
4289<var>name</var> corresponds is printed. If multiple <var>name</var> arguments are
9a51695b 4290supplied with <samp>-t</samp>, the <var>name</var> is printed before the hashed
17345e5a 4291full pathname.
a0c0a00f 4292The <samp>-l</samp> option causes output to be displayed in a format
17345e5a 4293that may be reused as input.
a0c0a00f 4294If no arguments are given, or if only <samp>-l</samp> is supplied,
17345e5a 4295information about remembered commands is printed.
a0c0a00f 4296The return status is zero unless a <var>name</var> is not found or an invalid
17345e5a 4297option is supplied.
a0c0a00f
CR
4298</p>
4299</dd>
4300<dt><code>pwd</code></dt>
4301<dd><a name="index-pwd"></a>
4302<div class="example">
4303<pre class="example">pwd [-LP]
4304</pre></div>
4305
4306<p>Print the absolute pathname of the current working directory.
4307If the <samp>-P</samp> option is supplied, the pathname printed will not
17345e5a 4308contain symbolic links.
a0c0a00f 4309If the <samp>-L</samp> option is supplied, the pathname printed may contain
17345e5a
JA
4310symbolic links.
4311The return status is zero unless an error is encountered while
4312determining the name of the current directory or an invalid option
4313is supplied.
a0c0a00f
CR
4314</p>
4315</dd>
4316<dt><code>readonly</code></dt>
4317<dd><a name="index-readonly"></a>
4318<div class="example">
4319<pre class="example">readonly [-aAf] [-p] [<var>name</var>[=<var>value</var>]] &hellip;
4320</pre></div>
4321
4322<p>Mark each <var>name</var> as readonly.
17345e5a 4323The values of these names may not be changed by subsequent assignment.
a0c0a00f 4324If the <samp>-f</samp> option is supplied, each <var>name</var> refers to a shell
17345e5a 4325function.
a0c0a00f
CR
4326The <samp>-a</samp> option means each <var>name</var> refers to an indexed
4327array variable; the <samp>-A</samp> option means each <var>name</var> refers
17345e5a 4328to an associative array variable.
a0c0a00f
CR
4329If both options are supplied, <samp>-A</samp> takes precedence.
4330If no <var>name</var> arguments are given, or if the <samp>-p</samp>
17345e5a 4331option is supplied, a list of all readonly names is printed.
ac50fbac
CR
4332The other options may be used to restrict the output to a subset of
4333the set of readonly names.
a0c0a00f 4334The <samp>-p</samp> option causes output to be displayed in a format that
17345e5a 4335may be reused as input.
a0c0a00f
CR
4336If a variable name is followed by =<var>value</var>, the value of
4337the variable is set to <var>value</var>.
17345e5a 4338The return status is zero unless an invalid option is supplied, one of
a0c0a00f
CR
4339the <var>name</var> arguments is not a valid shell variable or function name,
4340or the <samp>-f</samp> option is supplied with a name that is not a shell function.
4341</p>
4342</dd>
4343<dt><code>return</code></dt>
4344<dd><a name="index-return"></a>
4345<div class="example">
4346<pre class="example">return [<var>n</var>]
4347</pre></div>
4348
4349<p>Cause a shell function to stop executing and return the value <var>n</var>
ac50fbac 4350to its caller.
a0c0a00f 4351If <var>n</var> is not supplied, the return value is the exit status of the
17345e5a 4352last command executed in the function.
a0c0a00f
CR
4353If <code>return</code> is executed by a trap handler, the last command used to
4354determine the status is the last command executed before the trap handler.
9a51695b 4355If <code>return</code> is executed during a <code>DEBUG</code> trap, the last command
a0c0a00f
CR
4356used to determine the status is the last command executed by the trap
4357handler before <code>return</code> was invoked.
4358<code>return</code> may also be used to terminate execution of a script
4359being executed with the <code>.</code> (<code>source</code>) builtin,
4360returning either <var>n</var> or
17345e5a
JA
4361the exit status of the last command executed within the script as the exit
4362status of the script.
a0c0a00f 4363If <var>n</var> is supplied, the return value is its least significant
ac50fbac 43648 bits.
a0c0a00f 4365Any command associated with the <code>RETURN</code> trap is executed
17345e5a 4366before execution resumes after the function or script.
a0c0a00f 4367The return status is non-zero if <code>return</code> is supplied a non-numeric
ac50fbac 4368argument or is used outside a function
a0c0a00f
CR
4369and not during the execution of a script by <code>.</code> or <code>source</code>.
4370</p>
4371</dd>
4372<dt><code>shift</code></dt>
4373<dd><a name="index-shift"></a>
4374<div class="example">
4375<pre class="example">shift [<var>n</var>]
4376</pre></div>
4377
4378<p>Shift the positional parameters to the left by <var>n</var>.
4379The positional parameters from <var>n</var>+1 &hellip; <code>$#</code> are
4380renamed to <code>$1</code> &hellip; <code>$#</code>-<var>n</var>.
4381Parameters represented by the numbers <code>$#</code> to <code>$#</code>-<var>n</var>+1
17345e5a 4382are unset.
a0c0a00f
CR
4383<var>n</var> must be a non-negative number less than or equal to <code>$#</code>.
4384If <var>n</var> is zero or greater than <code>$#</code>, the positional parameters
17345e5a 4385are not changed.
a0c0a00f
CR
4386If <var>n</var> is not supplied, it is assumed to be 1.
4387The return status is zero unless <var>n</var> is greater than <code>$#</code> or
17345e5a 4388less than zero, non-zero otherwise.
a0c0a00f
CR
4389</p>
4390</dd>
4391<dt><code>test</code></dt>
4392<dt><code>[</code></dt>
4393<dd><a name="index-test"></a>
4394<a name="index-_005b"></a>
4395<div class="example">
4396<pre class="example">test <var>expr</var>
4397</pre></div>
4398
4399<p>Evaluate a conditional expression <var>expr</var> and return a status of 0
ac50fbac 4400(true) or 1 (false).
17345e5a
JA
4401Each operator and operand must be a separate argument.
4402Expressions are composed of the primaries described below in
a0c0a00f
CR
4403<a href="#Bash-Conditional-Expressions">Bash Conditional Expressions</a>.
4404<code>test</code> does not accept any options, nor does it accept and ignore
4405an argument of <samp>--</samp> as signifying the end of options.
4406</p>
4407<p>When the <code>[</code> form is used, the last argument to the command must
4408be a <code>]</code>.
4409</p>
4410<p>Expressions may be combined using the following operators, listed in
17345e5a
JA
4411decreasing order of precedence.
4412The evaluation depends on the number of arguments; see below.
495aee44 4413Operator precedence is used when there are five or more arguments.
a0c0a00f
CR
4414</p>
4415<dl compact="compact">
4416<dt><code>! <var>expr</var></code></dt>
4417<dd><p>True if <var>expr</var> is false.
4418</p>
4419</dd>
4420<dt><code>( <var>expr</var> )</code></dt>
4421<dd><p>Returns the value of <var>expr</var>.
17345e5a 4422This may be used to override the normal precedence of operators.
a0c0a00f
CR
4423</p>
4424</dd>
4425<dt><code><var>expr1</var> -a <var>expr2</var></code></dt>
4426<dd><p>True if both <var>expr1</var> and <var>expr2</var> are true.
4427</p>
4428</dd>
4429<dt><code><var>expr1</var> -o <var>expr2</var></code></dt>
4430<dd><p>True if either <var>expr1</var> or <var>expr2</var> is true.
4431</p></dd>
4432</dl>
4433
4434<p>The <code>test</code> and <code>[</code> builtins evaluate conditional
17345e5a 4435expressions using a set of rules based on the number of arguments.
a0c0a00f
CR
4436</p>
4437<dl compact="compact">
4438<dt>0 arguments</dt>
4439<dd><p>The expression is false.
4440</p>
4441</dd>
4442<dt>1 argument</dt>
9a51695b 4443<dd><p>The expression is true if, and only if, the argument is not null.
a0c0a00f
CR
4444</p>
4445</dd>
4446<dt>2 arguments</dt>
4447<dd><p>If the first argument is &lsquo;<samp>!</samp>&rsquo;, the expression is true if and
17345e5a
JA
4448only if the second argument is null.
4449If the first argument is one of the unary conditional operators
a0c0a00f 4450(see <a href="#Bash-Conditional-Expressions">Bash Conditional Expressions</a>), the expression
17345e5a
JA
4451is true if the unary test is true.
4452If the first argument is not a valid unary operator, the expression is
4453false.
a0c0a00f
CR
4454</p>
4455</dd>
4456<dt>3 arguments</dt>
4457<dd><p>The following conditions are applied in the order listed.
495aee44 4458If the second argument is one of the binary conditional
a0c0a00f 4459operators (see <a href="#Bash-Conditional-Expressions">Bash Conditional Expressions</a>), the
17345e5a
JA
4460result of the expression is the result of the binary test using the
4461first and third arguments as operands.
a0c0a00f 4462The &lsquo;<samp>-a</samp>&rsquo; and &lsquo;<samp>-o</samp>&rsquo; operators are considered binary operators
17345e5a 4463when there are three arguments.
a0c0a00f 4464If the first argument is &lsquo;<samp>!</samp>&rsquo;, the value is the negation of
17345e5a 4465the two-argument test using the second and third arguments.
a0c0a00f
CR
4466If the first argument is exactly &lsquo;<samp>(</samp>&rsquo; and the third argument is
4467exactly &lsquo;<samp>)</samp>&rsquo;, the result is the one-argument test of the second
17345e5a
JA
4468argument.
4469Otherwise, the expression is false.
a0c0a00f
CR
4470</p>
4471</dd>
4472<dt>4 arguments</dt>
4473<dd><p>If the first argument is &lsquo;<samp>!</samp>&rsquo;, the result is the negation of
17345e5a 4474the three-argument expression composed of the remaining arguments.
a0c0a00f 4475Otherwise, the expression is parsed and evaluated according to
17345e5a 4476precedence using the rules listed above.
a0c0a00f
CR
4477</p>
4478</dd>
4479<dt>5 or more arguments</dt>
4480<dd><p>The expression is parsed and evaluated according to precedence
17345e5a 4481using the rules listed above.
a0c0a00f
CR
4482</p></dd>
4483</dl>
17345e5a 4484
a0c0a00f 4485<p>When used with <code>test</code> or &lsquo;<samp>[</samp>&rsquo;, the &lsquo;<samp>&lt;</samp>&rsquo; and &lsquo;<samp>&gt;</samp>&rsquo;
495aee44 4486operators sort lexicographically using ASCII ordering.
a0c0a00f
CR
4487</p>
4488</dd>
4489<dt><code>times</code></dt>
4490<dd><a name="index-times"></a>
4491<div class="example">
4492<pre class="example">times
4493</pre></div>
4494
4495<p>Print out the user and system times used by the shell and its children.
17345e5a 4496The return status is zero.
a0c0a00f
CR
4497</p>
4498</dd>
4499<dt><code>trap</code></dt>
4500<dd><a name="index-trap"></a>
4501<div class="example">
4502<pre class="example">trap [-lp] [<var>arg</var>] [<var>sigspec</var> &hellip;]
4503</pre></div>
4504
4505<p>The commands in <var>arg</var> are to be read and executed when the
4506shell receives signal <var>sigspec</var>. If <var>arg</var> is absent (and
4507there is a single <var>sigspec</var>) or
4508equal to &lsquo;<samp>-</samp>&rsquo;, each specified signal&rsquo;s disposition is reset
17345e5a 4509to the value it had when the shell was started.
a0c0a00f
CR
4510If <var>arg</var> is the null string, then the signal specified by
4511each <var>sigspec</var> is ignored by the shell and commands it invokes.
4512If <var>arg</var> is not present and <samp>-p</samp> has been supplied,
4513the shell displays the trap commands associated with each <var>sigspec</var>.
17345e5a 4514If no arguments are supplied, or
a0c0a00f 4515only <samp>-p</samp> is given, <code>trap</code> prints the list of commands
17345e5a
JA
4516associated with each signal number in a form that may be reused as
4517shell input.
a0c0a00f 4518The <samp>-l</samp> option causes the shell to print a list of signal names
17345e5a 4519and their corresponding numbers.
a0c0a00f
CR
4520Each <var>sigspec</var> is either a signal name or a signal number.
4521Signal names are case insensitive and the <code>SIG</code> prefix is optional.
4522</p>
4523<p>If a <var>sigspec</var>
4524is <code>0</code> or <code>EXIT</code>, <var>arg</var> is executed when the shell exits.
4525If a <var>sigspec</var> is <code>DEBUG</code>, the command <var>arg</var> is executed
4526before every simple command, <code>for</code> command, <code>case</code> command,
4527<code>select</code> command, every arithmetic <code>for</code> command, and before
17345e5a 4528the first command executes in a shell function.
a0c0a00f
CR
4529Refer to the description of the <code>extdebug</code> option to the
4530<code>shopt</code> builtin (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>) for details of its
4531effect on the <code>DEBUG</code> trap.
4532If a <var>sigspec</var> is <code>RETURN</code>, the command <var>arg</var> is executed
4533each time a shell function or a script executed with the <code>.</code> or
4534<code>source</code> builtins finishes executing.
4535</p>
4536<p>If a <var>sigspec</var> is <code>ERR</code>, the command <var>arg</var>
ac50fbac
CR
4537is executed whenever
4538a pipeline (which may consist of a single simple
a0c0a00f 4539command), a list, or a compound command returns a
ac50fbac 4540non-zero exit status,
17345e5a 4541subject to the following conditions.
a0c0a00f
CR
4542The <code>ERR</code> trap is not executed if the failed command is part of the
4543command list immediately following an <code>until</code> or <code>while</code> keyword,
4544part of the test following the <code>if</code> or <code>elif</code> reserved words,
4545part of a command executed in a <code>&amp;&amp;</code> or <code>||</code> list
4546except the command following the final <code>&amp;&amp;</code> or <code>||</code>,
ac50fbac 4547any command in a pipeline but the last,
a0c0a00f
CR
4548or if the command&rsquo;s return
4549status is being inverted using <code>!</code>.
4550These are the same conditions obeyed by the <code>errexit</code> (<samp>-e</samp>)
ac50fbac 4551option.
a0c0a00f
CR
4552</p>
4553<p>Signals ignored upon entry to the shell cannot be trapped or reset.
17345e5a 4554Trapped signals that are not being ignored are reset to their original
0001803f 4555values in a subshell or subshell environment when one is created.
a0c0a00f
CR
4556</p>
4557<p>The return status is zero unless a <var>sigspec</var> does not specify a
17345e5a 4558valid signal.
a0c0a00f
CR
4559</p>
4560</dd>
4561<dt><code>umask</code></dt>
4562<dd><a name="index-umask"></a>
4563<div class="example">
4564<pre class="example">umask [-p] [-S] [<var>mode</var>]
4565</pre></div>
4566
4567<p>Set the shell process&rsquo;s file creation mask to <var>mode</var>. If
4568<var>mode</var> begins with a digit, it is interpreted as an octal number;
17345e5a 4569if not, it is interpreted as a symbolic mode mask similar
a0c0a00f
CR
4570to that accepted by the <code>chmod</code> command. If <var>mode</var> is
4571omitted, the current value of the mask is printed. If the <samp>-S</samp>
4572option is supplied without a <var>mode</var> argument, the mask is printed
17345e5a 4573in a symbolic format.
a0c0a00f 4574If the <samp>-p</samp> option is supplied, and <var>mode</var>
17345e5a
JA
4575is omitted, the output is in a form that may be reused as input.
4576The return status is zero if the mode is successfully changed or if
a0c0a00f
CR
4577no <var>mode</var> argument is supplied, and non-zero otherwise.
4578</p>
4579<p>Note that when the mode is interpreted as an octal number, each number
4580of the umask is subtracted from <code>7</code>. Thus, a umask of <code>022</code>
4581results in permissions of <code>755</code>.
4582</p>
4583</dd>
4584<dt><code>unset</code></dt>
4585<dd><a name="index-unset"></a>
4586<div class="example">
4587<pre class="example">unset [-fnv] [<var>name</var>]
4588</pre></div>
4589
4590<p>Remove each variable or function <var>name</var>.
4591If the <samp>-v</samp> option is given, each
4592<var>name</var> refers to a shell variable and that variable is removed.
4593If the <samp>-f</samp> option is given, the <var>name</var>s refer to shell
17345e5a 4594functions, and the function definition is removed.
a0c0a00f
CR
4595If the <samp>-n</samp> option is supplied, and <var>name</var> is a variable with
4596the <var>nameref</var> attribute, <var>name</var> will be unset rather than the
ac50fbac 4597variable it references.
a0c0a00f
CR
4598<samp>-n</samp> has no effect if the <samp>-f</samp> option is supplied.
4599If no options are supplied, each <var>name</var> refers to a variable; if
ac50fbac
CR
4600there is no variable by that name, any function with that name is
4601unset.
17345e5a 4602Readonly variables and functions may not be unset.
a0c0a00f
CR
4603The return status is zero unless a <var>name</var> is readonly.
4604</p></dd>
4605</dl>
4606
4607<hr>
4608<a name="Bash-Builtins"></a>
4609<div class="header">
4610<p>
4611Next: <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>
4612</div>
4613<a name="Bash-Builtin-Commands"></a>
4614<h3 class="section">4.2 Bash Builtin Commands</h3>
4615
4616<p>This section describes builtin commands which are unique to
17345e5a 4617or have been extended in Bash.
a0c0a00f
CR
4618Some of these commands are specified in the <small>POSIX</small> standard.
4619</p>
4620<dl compact="compact">
4621<dt><code>alias</code></dt>
4622<dd><a name="index-alias"></a>
4623<div class="example">
4624<pre class="example">alias [-p] [<var>name</var>[=<var>value</var>] &hellip;]
4625</pre></div>
4626
4627<p>Without arguments or with the <samp>-p</samp> option, <code>alias</code> prints
17345e5a
JA
4628the list of aliases on the standard output in a form that allows
4629them to be reused as input.
a0c0a00f
CR
4630If arguments are supplied, an alias is defined for each <var>name</var>
4631whose <var>value</var> is given. If no <var>value</var> is given, the name
17345e5a 4632and value of the alias is printed.
a0c0a00f
CR
4633Aliases are described in <a href="#Aliases">Aliases</a>.
4634</p>
4635</dd>
4636<dt><code>bind</code></dt>
4637<dd><a name="index-bind"></a>
4638<div class="example">
4639<pre class="example">bind [-m <var>keymap</var>] [-lpsvPSVX]
4640bind [-m <var>keymap</var>] [-q <var>function</var>] [-u <var>function</var>] [-r <var>keyseq</var>]
4641bind [-m <var>keymap</var>] -f <var>filename</var>
4642bind [-m <var>keymap</var>] -x <var>keyseq:shell-command</var>
4643bind [-m <var>keymap</var>] <var>keyseq:function-name</var>
4644bind [-m <var>keymap</var>] <var>keyseq:readline-command</var>
4645</pre></div>
4646
4647<p>Display current Readline (see <a href="#Command-Line-Editing">Command Line Editing</a>)
17345e5a
JA
4648key and function bindings,
4649bind a key sequence to a Readline function or macro,
4650or set a Readline variable.
4651Each non-option argument is a command as it would appear in a
a0c0a00f 4652Readline initialization file (see <a href="#Readline-Init-File">Readline Init File</a>),
17345e5a 4653but each binding or command must be passed as a separate argument; e.g.,
a0c0a00f
CR
4654&lsquo;<samp>&quot;\C-x\C-r&quot;:re-read-init-file</samp>&rsquo;.
4655</p>
4656<p>Options, if supplied, have the following meanings:
4657</p>
4658<dl compact="compact">
4659<dt><code>-m <var>keymap</var></code></dt>
4660<dd><p>Use <var>keymap</var> as the keymap to be affected by
4661the subsequent bindings. Acceptable <var>keymap</var>
17345e5a 4662names are
a0c0a00f
CR
4663<code>emacs</code>,
4664<code>emacs-standard</code>,
4665<code>emacs-meta</code>,
4666<code>emacs-ctlx</code>,
4667<code>vi</code>,
4668<code>vi-move</code>,
4669<code>vi-command</code>, and
4670<code>vi-insert</code>.
4671<code>vi</code> is equivalent to <code>vi-command</code> (<code>vi-move</code> is also a
4672synonym); <code>emacs</code> is equivalent to <code>emacs-standard</code>.
4673</p>
4674</dd>
4675<dt><code>-l</code></dt>
4676<dd><p>List the names of all Readline functions.
4677</p>
4678</dd>
4679<dt><code>-p</code></dt>
4680<dd><p>Display Readline function names and bindings in such a way that they
17345e5a 4681can be used as input or in a Readline initialization file.
a0c0a00f
CR
4682</p>
4683</dd>
4684<dt><code>-P</code></dt>
4685<dd><p>List current Readline function names and bindings.
4686</p>
4687</dd>
4688<dt><code>-v</code></dt>
4689<dd><p>Display Readline variable names and values in such a way that they
17345e5a 4690can be used as input or in a Readline initialization file.
a0c0a00f
CR
4691</p>
4692</dd>
4693<dt><code>-V</code></dt>
4694<dd><p>List current Readline variable names and values.
4695</p>
4696</dd>
4697<dt><code>-s</code></dt>
4698<dd><p>Display Readline key sequences bound to macros and the strings they output
17345e5a
JA
4699in such a way that they can be used as input or in a Readline
4700initialization file.
a0c0a00f
CR
4701</p>
4702</dd>
4703<dt><code>-S</code></dt>
4704<dd><p>Display Readline key sequences bound to macros and the strings they output.
4705</p>
4706</dd>
4707<dt><code>-f <var>filename</var></code></dt>
4708<dd><p>Read key bindings from <var>filename</var>.
4709</p>
4710</dd>
4711<dt><code>-q <var>function</var></code></dt>
4712<dd><p>Query about which keys invoke the named <var>function</var>.
4713</p>
4714</dd>
4715<dt><code>-u <var>function</var></code></dt>
4716<dd><p>Unbind all keys bound to the named <var>function</var>.
4717</p>
4718</dd>
4719<dt><code>-r <var>keyseq</var></code></dt>
4720<dd><p>Remove any current binding for <var>keyseq</var>.
4721</p>
4722</dd>
4723<dt><code>-x <var>keyseq:shell-command</var></code></dt>
4724<dd><p>Cause <var>shell-command</var> to be executed whenever <var>keyseq</var> is
17345e5a 4725entered.
a0c0a00f
CR
4726When <var>shell-command</var> is executed, the shell sets the
4727<code>READLINE_LINE</code> variable to the contents of the Readline line
4728buffer and the <code>READLINE_POINT</code> variable to the current location
17345e5a 4729of the insertion point.
a0c0a00f
CR
4730If the executed command changes the value of <code>READLINE_LINE</code> or
4731<code>READLINE_POINT</code>, those new values will be reflected in the
17345e5a 4732editing state.
a0c0a00f
CR
4733</p>
4734</dd>
4735<dt><code>-X</code></dt>
4736<dd><p>List all key sequences bound to shell commands and the associated commands
ac50fbac 4737in a format that can be reused as input.
a0c0a00f
CR
4738</p></dd>
4739</dl>
17345e5a 4740
a0c0a00f 4741<p>The return status is zero unless an invalid option is supplied or an
17345e5a 4742error occurs.
a0c0a00f
CR
4743</p>
4744</dd>
4745<dt><code>builtin</code></dt>
4746<dd><a name="index-builtin"></a>
4747<div class="example">
4748<pre class="example">builtin [<var>shell-builtin</var> [<var>args</var>]]
4749</pre></div>
4750
4751<p>Run a shell builtin, passing it <var>args</var>, and return its exit status.
17345e5a
JA
4752This is useful when defining a shell function with the same
4753name as a shell builtin, retaining the functionality of the builtin within
4754the function.
a0c0a00f 4755The return status is non-zero if <var>shell-builtin</var> is not a shell
17345e5a 4756builtin command.
a0c0a00f
CR
4757</p>
4758</dd>
4759<dt><code>caller</code></dt>
4760<dd><a name="index-caller"></a>
4761<div class="example">
4762<pre class="example">caller [<var>expr</var>]
4763</pre></div>
4764
4765<p>Returns the context of any active subroutine call (a shell function or
4766a script executed with the <code>.</code> or <code>source</code> builtins).
4767</p>
4768<p>Without <var>expr</var>, <code>caller</code> displays the line number and source
17345e5a 4769filename of the current subroutine call.
a0c0a00f 4770If a non-negative integer is supplied as <var>expr</var>, <code>caller</code>
17345e5a
JA
4771displays the line number, subroutine name, and source file corresponding
4772to that position in the current execution call stack. This extra
4773information may be used, for example, to print a stack trace. The
4774current frame is frame 0.
a0c0a00f
CR
4775</p>
4776<p>The return value is 0 unless the shell is not executing a subroutine
4777call or <var>expr</var> does not correspond to a valid position in the
17345e5a 4778call stack.
a0c0a00f
CR
4779</p>
4780</dd>
4781<dt><code>command</code></dt>
4782<dd><a name="index-command"></a>
4783<div class="example">
4784<pre class="example">command [-pVv] <var>command</var> [<var>arguments</var> &hellip;]
4785</pre></div>
4786
4787<p>Runs <var>command</var> with <var>arguments</var> ignoring any shell function
4788named <var>command</var>.
17345e5a 4789Only shell builtin commands or commands found by searching the
a0c0a00f
CR
4790<code>PATH</code> are executed.
4791If there is a shell function named <code>ls</code>, running &lsquo;<samp>command ls</samp>&rsquo;
4792within the function will execute the external command <code>ls</code>
17345e5a 4793instead of calling the function recursively.
a0c0a00f 4794The <samp>-p</samp> option means to use a default value for <code>PATH</code>
17345e5a 4795that is guaranteed to find all of the standard utilities.
a0c0a00f
CR
4796The return status in this case is 127 if <var>command</var> cannot be
4797found or an error occurred, and the exit status of <var>command</var>
17345e5a 4798otherwise.
a0c0a00f
CR
4799</p>
4800<p>If either the <samp>-V</samp> or <samp>-v</samp> option is supplied, a
4801description of <var>command</var> is printed. The <samp>-v</samp> option
17345e5a 4802causes a single word indicating the command or file name used to
a0c0a00f 4803invoke <var>command</var> to be displayed; the <samp>-V</samp> option produces
17345e5a 4804a more verbose description. In this case, the return status is
a0c0a00f
CR
4805zero if <var>command</var> is found, and non-zero if not.
4806</p>
4807</dd>
4808<dt><code>declare</code></dt>
4809<dd><a name="index-declare"></a>
4810<div class="example">
4811<pre class="example">declare [-aAfFgilnrtux] [-p] [<var>name</var>[=<var>value</var>] &hellip;]
4812</pre></div>
4813
4814<p>Declare variables and give them attributes. If no <var>name</var>s
17345e5a 4815are given, then display the values of variables instead.
a0c0a00f
CR
4816</p>
4817<p>The <samp>-p</samp> option will display the attributes and values of each
4818<var>name</var>.
4819When <samp>-p</samp> is used with <var>name</var> arguments, additional options,
4820other than <samp>-f</samp> and <samp>-F</samp>, are ignored.
4821</p>
4822<p>When <samp>-p</samp> is supplied without <var>name</var> arguments, <code>declare</code>
17345e5a
JA
4823will display the attributes and values of all variables having the
4824attributes specified by the additional options.
a0c0a00f
CR
4825If no other options are supplied with <samp>-p</samp>, <code>declare</code> will
4826display the attributes and values of all shell variables. The <samp>-f</samp>
17345e5a 4827option will restrict the display to shell functions.
a0c0a00f
CR
4828</p>
4829<p>The <samp>-F</samp> option inhibits the display of function definitions;
17345e5a 4830only the function name and attributes are printed.
a0c0a00f
CR
4831If the <code>extdebug</code> shell option is enabled using <code>shopt</code>
4832(see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), the source file name and line number where
4833each <var>name</var> is defined are displayed as well.
4834<samp>-F</samp> implies <samp>-f</samp>.
4835</p>
4836<p>The <samp>-g</samp> option forces variables to be created or modified at
4837the global scope, even when <code>declare</code> is executed in a shell function.
495aee44 4838It is ignored in all other cases.
a0c0a00f
CR
4839</p>
4840<p>The following options can be used to restrict output to variables with
17345e5a 4841the specified attributes or to give variables attributes:
a0c0a00f
CR
4842</p>
4843<dl compact="compact">
4844<dt><code>-a</code></dt>
4845<dd><p>Each <var>name</var> is an indexed array variable (see <a href="#Arrays">Arrays</a>).
4846</p>
4847</dd>
4848<dt><code>-A</code></dt>
4849<dd><p>Each <var>name</var> is an associative array variable (see <a href="#Arrays">Arrays</a>).
4850</p>
4851</dd>
4852<dt><code>-f</code></dt>
4853<dd><p>Use function names only.
4854</p>
4855</dd>
4856<dt><code>-i</code></dt>
4857<dd><p>The variable is to be treated as
4858an integer; arithmetic evaluation (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>) is
17345e5a 4859performed when the variable is assigned a value.
a0c0a00f
CR
4860</p>
4861</dd>
4862<dt><code>-l</code></dt>
4863<dd><p>When the variable is assigned a value, all upper-case characters are
17345e5a
JA
4864converted to lower-case.
4865The upper-case attribute is disabled.
a0c0a00f
CR
4866</p>
4867</dd>
4868<dt><code>-n</code></dt>
4869<dd><p>Give each <var>name</var> the <var>nameref</var> attribute, making
ac50fbac 4870it a name reference to another variable.
a0c0a00f
CR
4871That other variable is defined by the value of <var>name</var>.
4872All references, assignments, and attribute modifications
4873to <var>name</var>, except for those using or changing the
4874<samp>-n</samp> attribute itself, are performed on the variable referenced by
4875<var>name</var>&rsquo;s value.
4876The nameref attribute cannot be applied to array variables.
4877</p>
4878</dd>
4879<dt><code>-r</code></dt>
4880<dd><p>Make <var>name</var>s readonly. These names cannot then be assigned values
17345e5a 4881by subsequent assignment statements or unset.
a0c0a00f
CR
4882</p>
4883</dd>
4884<dt><code>-t</code></dt>
4885<dd><p>Give each <var>name</var> the <code>trace</code> attribute.
4886Traced functions inherit the <code>DEBUG</code> and <code>RETURN</code> traps from
17345e5a
JA
4887the calling shell.
4888The trace attribute has no special meaning for variables.
a0c0a00f
CR
4889</p>
4890</dd>
4891<dt><code>-u</code></dt>
4892<dd><p>When the variable is assigned a value, all lower-case characters are
17345e5a
JA
4893converted to upper-case.
4894The lower-case attribute is disabled.
a0c0a00f
CR
4895</p>
4896</dd>
4897<dt><code>-x</code></dt>
4898<dd><p>Mark each <var>name</var> for export to subsequent commands via
17345e5a 4899the environment.
a0c0a00f
CR
4900</p></dd>
4901</dl>
17345e5a 4902
a0c0a00f
CR
4903<p>Using &lsquo;<samp>+</samp>&rsquo; instead of &lsquo;<samp>-</samp>&rsquo; turns off the attribute instead,
4904with the exceptions that &lsquo;<samp>+a</samp>&rsquo;
4905may not be used to destroy an array variable and &lsquo;<samp>+r</samp>&rsquo; will not
17345e5a 4906remove the readonly attribute.
a0c0a00f
CR
4907When used in a function, <code>declare</code> makes each <var>name</var> local,
4908as with the <code>local</code> command, unless the <samp>-g</samp> option is used.
4909If a variable name is followed by =<var>value</var>, the value of the variable
4910is set to <var>value</var>.
4911</p>
4912<p>When using <samp>-a</samp> or <samp>-A</samp> and the compound assignment syntax to
ac50fbac
CR
4913create array variables, additional attributes do not take effect until
4914subsequent assignments.
a0c0a00f
CR
4915</p>
4916<p>The return status is zero unless an invalid option is encountered,
4917an attempt is made to define a function using &lsquo;<samp>-f foo=bar</samp>&rsquo;,
17345e5a
JA
4918an attempt is made to assign a value to a readonly variable,
4919an attempt is made to assign a value to an array variable without
a0c0a00f
CR
4920using the compound assignment syntax (see <a href="#Arrays">Arrays</a>),
4921one of the <var>names</var> is not a valid shell variable name,
17345e5a
JA
4922an attempt is made to turn off readonly status for a readonly variable,
4923an attempt is made to turn off array status for an array variable,
a0c0a00f
CR
4924or an attempt is made to display a non-existent function with <samp>-f</samp>.
4925</p>
4926</dd>
4927<dt><code>echo</code></dt>
4928<dd><a name="index-echo"></a>
4929<div class="example">
4930<pre class="example">echo [-neE] [<var>arg</var> &hellip;]
4931</pre></div>
4932
4933<p>Output the <var>arg</var>s, separated by spaces, terminated with a
17345e5a 4934newline.
ac50fbac 4935The return status is 0 unless a write error occurs.
a0c0a00f
CR
4936If <samp>-n</samp> is specified, the trailing newline is suppressed.
4937If the <samp>-e</samp> option is given, interpretation of the following
17345e5a 4938backslash-escaped characters is enabled.
a0c0a00f 4939The <samp>-E</samp> option disables the interpretation of these escape characters,
17345e5a 4940even on systems where they are interpreted by default.
a0c0a00f
CR
4941The <code>xpg_echo</code> shell option may be used to
4942dynamically determine whether or not <code>echo</code> expands these
17345e5a 4943escape characters by default.
a0c0a00f
CR
4944<code>echo</code> does not interpret <samp>--</samp> to mean the end of options.
4945</p>
4946<p><code>echo</code> interprets the following escape sequences:
4947</p><dl compact="compact">
4948<dt><code>\a</code></dt>
4949<dd><p>alert (bell)
4950</p></dd>
4951<dt><code>\b</code></dt>
4952<dd><p>backspace
4953</p></dd>
4954<dt><code>\c</code></dt>
4955<dd><p>suppress further output
4956</p></dd>
4957<dt><code>\e</code></dt>
4958<dt><code>\E</code></dt>
4959<dd><p>escape
4960</p></dd>
4961<dt><code>\f</code></dt>
4962<dd><p>form feed
4963</p></dd>
4964<dt><code>\n</code></dt>
4965<dd><p>new line
4966</p></dd>
4967<dt><code>\r</code></dt>
4968<dd><p>carriage return
4969</p></dd>
4970<dt><code>\t</code></dt>
4971<dd><p>horizontal tab
4972</p></dd>
4973<dt><code>\v</code></dt>
4974<dd><p>vertical tab
4975</p></dd>
4976<dt><code>\\</code></dt>
4977<dd><p>backslash
4978</p></dd>
4979<dt><code>\0<var>nnn</var></code></dt>
4980<dd><p>the eight-bit character whose value is the octal value <var>nnn</var>
17345e5a 4981(zero to three octal digits)
a0c0a00f
CR
4982</p></dd>
4983<dt><code>\x<var>HH</var></code></dt>
4984<dd><p>the eight-bit character whose value is the hexadecimal value <var>HH</var>
17345e5a 4985(one or two hex digits)
a0c0a00f
CR
4986</p></dd>
4987<dt><code>\u<var>HHHH</var></code></dt>
4988<dd><p>the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
4989<var>HHHH</var> (one to four hex digits)
4990</p></dd>
4991<dt><code>\U<var>HHHHHHHH</var></code></dt>
4992<dd><p>the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
4993<var>HHHHHHHH</var> (one to eight hex digits)
4994</p></dd>
4995</dl>
4996
4997</dd>
4998<dt><code>enable</code></dt>
4999<dd><a name="index-enable"></a>
5000<div class="example">
5001<pre class="example">enable [-a] [-dnps] [-f <var>filename</var>] [<var>name</var> &hellip;]
5002</pre></div>
5003
5004<p>Enable and disable builtin shell commands.
17345e5a
JA
5005Disabling a builtin allows a disk command which has the same name
5006as a shell builtin to be executed without specifying a full pathname,
5007even though the shell normally searches for builtins before disk commands.
a0c0a00f
CR
5008If <samp>-n</samp> is used, the <var>name</var>s become disabled. Otherwise
5009<var>name</var>s are enabled. For example, to use the <code>test</code> binary
5010found via <code>$PATH</code> instead of the shell builtin version, type
5011&lsquo;<samp>enable -n test</samp>&rsquo;.
5012</p>
5013<p>If the <samp>-p</samp> option is supplied, or no <var>name</var> arguments appear,
17345e5a
JA
5014a list of shell builtins is printed. With no other arguments, the list
5015consists of all enabled shell builtins.
a0c0a00f 5016The <samp>-a</samp> option means to list
17345e5a 5017each builtin with an indication of whether or not it is enabled.
a0c0a00f
CR
5018</p>
5019<p>The <samp>-f</samp> option means to load the new builtin command <var>name</var>
5020from shared object <var>filename</var>, on systems that support dynamic loading.
5021The <samp>-d</samp> option will delete a builtin loaded with <samp>-f</samp>.
5022</p>
5023<p>If there are no options, a list of the shell builtins is displayed.
5024The <samp>-s</samp> option restricts <code>enable</code> to the <small>POSIX</small> special
5025builtins. If <samp>-s</samp> is used with <samp>-f</samp>, the new builtin becomes
5026a special builtin (see <a href="#Special-Builtins">Special Builtins</a>).
5027</p>
5028<p>The return status is zero unless a <var>name</var> is not a shell builtin
17345e5a 5029or there is an error loading a new builtin from a shared object.
a0c0a00f
CR
5030</p>
5031</dd>
5032<dt><code>help</code></dt>
5033<dd><a name="index-help"></a>
5034<div class="example">
5035<pre class="example">help [-dms] [<var>pattern</var>]
5036</pre></div>
5037
5038<p>Display helpful information about builtin commands.
5039If <var>pattern</var> is specified, <code>help</code> gives detailed help
5040on all commands matching <var>pattern</var>, otherwise a list of
17345e5a 5041the builtins is printed.
a0c0a00f
CR
5042</p>
5043<p>Options, if supplied, have the following meanings:
5044</p>
5045<dl compact="compact">
5046<dt><code>-d</code></dt>
5047<dd><p>Display a short description of each <var>pattern</var>
5048</p></dd>
5049<dt><code>-m</code></dt>
5050<dd><p>Display the description of each <var>pattern</var> in a manpage-like format
5051</p></dd>
5052<dt><code>-s</code></dt>
5053<dd><p>Display only a short usage synopsis for each <var>pattern</var>
5054</p></dd>
5055</dl>
5056
5057<p>The return status is zero unless no command matches <var>pattern</var>.
5058</p>
5059</dd>
5060<dt><code>let</code></dt>
5061<dd><a name="index-let"></a>
5062<div class="example">
5063<pre class="example">let <var>expression</var> [<var>expression</var> &hellip;]
5064</pre></div>
5065
5066<p>The <code>let</code> builtin allows arithmetic to be performed on shell
5067variables. Each <var>expression</var> is evaluated according to the
5068rules given below in <a href="#Shell-Arithmetic">Shell Arithmetic</a>. If the
5069last <var>expression</var> evaluates to 0, <code>let</code> returns 1;
17345e5a 5070otherwise 0 is returned.
a0c0a00f
CR
5071</p>
5072</dd>
5073<dt><code>local</code></dt>
5074<dd><a name="index-local"></a>
5075<div class="example">
5076<pre class="example">local [<var>option</var>] <var>name</var>[=<var>value</var>] &hellip;
5077</pre></div>
5078
5079<p>For each argument, a local variable named <var>name</var> is created,
5080and assigned <var>value</var>.
5081The <var>option</var> can be any of the options accepted by <code>declare</code>.
5082<code>local</code> can only be used within a function; it makes the variable
5083<var>name</var> have a visible scope restricted to that function and its
5084children.
5085If <var>name</var> is &lsquo;<samp>-</samp>&rsquo;, the set of shell options is made local to the
5086function in which <code>local</code> is invoked: shell options changed using
5087the <code>set</code> builtin inside the function are restored to their original
5088values when the function returns.
5089The return status is zero unless <code>local</code> is used outside
5090a function, an invalid <var>name</var> is supplied, or <var>name</var> is a
17345e5a 5091readonly variable.
a0c0a00f
CR
5092</p>
5093</dd>
5094<dt><code>logout</code></dt>
5095<dd><a name="index-logout"></a>
5096<div class="example">
5097<pre class="example">logout [<var>n</var>]
5098</pre></div>
5099
5100<p>Exit a login shell, returning a status of <var>n</var> to the shell&rsquo;s
17345e5a 5101parent.
a0c0a00f
CR
5102</p>
5103</dd>
5104<dt><code>mapfile</code></dt>
5105<dd><a name="index-mapfile"></a>
5106<div class="example">
2f5dfe5a
CR
5107<pre class="example">mapfile [-d <var>delim</var>] [-n <var>count</var>] [-O <var>origin</var>] [-s <var>count</var>]
5108 [-t] [-u <var>fd</var>] [-C <var>callback</var>] [-c <var>quantum</var>] [<var>array</var>]
a0c0a00f
CR
5109</pre></div>
5110
5111<p>Read lines from the standard input into the indexed array variable <var>array</var>,
5112or from file descriptor <var>fd</var>
5113if the <samp>-u</samp> option is supplied.
5114The variable <code>MAPFILE</code> is the default <var>array</var>.
17345e5a 5115Options, if supplied, have the following meanings:
a0c0a00f
CR
5116</p>
5117<dl compact="compact">
5118<dt><code>-d</code></dt>
5119<dd><p>The first character of <var>delim</var> is used to terminate each input line,
5120rather than newline.
9a51695b
CR
5121If <var>delim</var> is the empty string, <code>mapfile</code> will terminate a line
5122when it reads a NUL character.
a0c0a00f
CR
5123</p></dd>
5124<dt><code>-n</code></dt>
5125<dd><p>Copy at most <var>count</var> lines. If <var>count</var> is 0, all lines are copied.
5126</p></dd>
5127<dt><code>-O</code></dt>
5128<dd><p>Begin assigning to <var>array</var> at index <var>origin</var>.
17345e5a 5129The default index is 0.
a0c0a00f
CR
5130</p></dd>
5131<dt><code>-s</code></dt>
5132<dd><p>Discard the first <var>count</var> lines read.
5133</p></dd>
5134<dt><code>-t</code></dt>
5135<dd><p>Remove a trailing <var>delim</var> (default newline) from each line read.
5136</p></dd>
5137<dt><code>-u</code></dt>
5138<dd><p>Read lines from file descriptor <var>fd</var> instead of the standard input.
5139</p></dd>
5140<dt><code>-C</code></dt>
9a51695b 5141<dd><p>Evaluate <var>callback</var> each time <var>quantum</var> lines are read.
a0c0a00f
CR
5142The <samp>-c</samp> option specifies <var>quantum</var>.
5143</p></dd>
5144<dt><code>-c</code></dt>
5145<dd><p>Specify the number of lines read between each call to <var>callback</var>.
5146</p></dd>
5147</dl>
5148
5149<p>If <samp>-C</samp> is specified without <samp>-c</samp>,
17345e5a 5150the default quantum is 5000.
a0c0a00f 5151When <var>callback</var> is evaluated, it is supplied the index of the next
495aee44
CR
5152array element to be assigned and the line to be assigned to that element
5153as additional arguments.
a0c0a00f 5154<var>callback</var> is evaluated after the line is read but before the
17345e5a 5155array element is assigned.
a0c0a00f
CR
5156</p>
5157<p>If not supplied with an explicit origin, <code>mapfile</code> will clear <var>array</var>
17345e5a 5158before assigning to it.
a0c0a00f
CR
5159</p>
5160<p><code>mapfile</code> returns successfully unless an invalid option or option
5161argument is supplied, <var>array</var> is invalid or unassignable, or <var>array</var>
0001803f 5162is not an indexed array.
a0c0a00f
CR
5163</p>
5164</dd>
5165<dt><code>printf</code></dt>
5166<dd><a name="index-printf"></a>
5167<div class="example">
5168<pre class="example">printf [-v <var>var</var>] <var>format</var> [<var>arguments</var>]
5169</pre></div>
5170
5171<p>Write the formatted <var>arguments</var> to the standard output under the
5172control of the <var>format</var>.
5173The <samp>-v</samp> option causes the output to be assigned to the variable
5174<var>var</var> rather than being printed to the standard output.
5175</p>
5176<p>The <var>format</var> is a character string which contains three types of objects:
17345e5a
JA
5177plain characters, which are simply copied to standard output, character
5178escape sequences, which are converted and copied to the standard output, and
5179format specifications, each of which causes printing of the next successive
a0c0a00f
CR
5180<var>argument</var>.
5181In addition to the standard <code>printf(1)</code> formats, <code>printf</code>
495aee44 5182interprets the following extensions:
a0c0a00f
CR
5183</p>
5184<dl compact="compact">
5185<dt><code>%b</code></dt>
5186<dd><p>Causes <code>printf</code> to expand backslash escape sequences in the
5187corresponding <var>argument</var> in the same way as <code>echo -e</code>
5188(see <a href="#Bash-Builtins">Bash Builtins</a>).
5189</p></dd>
5190<dt><code>%q</code></dt>
5191<dd><p>Causes <code>printf</code> to output the
5192corresponding <var>argument</var> in a format that can be reused as shell input.
5193</p></dd>
5194<dt><code>%(<var>datefmt</var>)T</code></dt>
5195<dd><p>Causes <code>printf</code> to output the date-time string resulting from using
5196<var>datefmt</var> as a format string for <code>strftime</code>(3).
5197The corresponding <var>argument</var> is an integer representing the number of
ac50fbac
CR
5198seconds since the epoch.
5199Two special argument values may be used: -1 represents the current
495aee44 5200time, and -2 represents the time the shell was invoked.
ac50fbac 5201If no argument is specified, conversion behaves as if -1 had been given.
a0c0a00f
CR
5202This is an exception to the usual <code>printf</code> behavior.
5203</p></dd>
5204</dl>
17345e5a 5205
a0c0a00f 5206<p>Arguments to non-string format specifiers are treated as C language constants,
495aee44
CR
5207except that a leading plus or minus sign is allowed, and if the leading
5208character is a single or double quote, the value is the ASCII value of
5209the following character.
a0c0a00f
CR
5210</p>
5211<p>The <var>format</var> is reused as necessary to consume all of the <var>arguments</var>.
5212If the <var>format</var> requires more <var>arguments</var> than are supplied, the
17345e5a
JA
5213extra format specifications behave as if a zero value or null string, as
5214appropriate, had been supplied. The return value is zero on success,
5215non-zero on failure.
a0c0a00f
CR
5216</p>
5217</dd>
5218<dt><code>read</code></dt>
5219<dd><a name="index-read"></a>
5220<div class="example">
5221<pre class="example">read [-ers] [-a <var>aname</var>] [-d <var>delim</var>] [-i <var>text</var>] [-n <var>nchars</var>]
5222 [-N <var>nchars</var>] [-p <var>prompt</var>] [-t <var>timeout</var>] [-u <var>fd</var>] [<var>name</var> &hellip;]
5223</pre></div>
5224
5225<p>One line is read from the standard input, or from the file descriptor
5226<var>fd</var> supplied as an argument to the <samp>-u</samp> option,
5227split into words as described above in <a href="#Word-Splitting">Word Splitting</a>,
5228and the first word
5229is assigned to the first <var>name</var>, the second word to the second <var>name</var>,
5230and so on.
5231If there are more words than names,
5232the remaining words and their intervening delimiters are assigned
5233to the last <var>name</var>.
17345e5a
JA
5234If there are fewer words read from the input stream than names,
5235the remaining names are assigned empty values.
a0c0a00f 5236The characters in the value of the <code>IFS</code> variable
ac50fbac 5237are used to split the line into words using the same rules the shell
a0c0a00f
CR
5238uses for expansion (described above in <a href="#Word-Splitting">Word Splitting</a>).
5239The backslash character &lsquo;<samp>\</samp>&rsquo; may be used to remove any special
17345e5a
JA
5240meaning for the next character read and for line continuation.
5241If no names are supplied, the line read is assigned to the
a0c0a00f
CR
5242variable <code>REPLY</code>.
5243The exit status is zero, unless end-of-file is encountered, <code>read</code>
5244times out (in which case the status is greater than 128),
ac50fbac 5245a variable assignment error (such as assigning to a readonly variable) occurs,
a0c0a00f
CR
5246or an invalid file descriptor is supplied as the argument to <samp>-u</samp>.
5247</p>
5248<p>Options, if supplied, have the following meanings:
5249</p>
5250<dl compact="compact">
5251<dt><code>-a <var>aname</var></code></dt>
5252<dd><p>The words are assigned to sequential indices of the array variable
5253<var>aname</var>, starting at 0.
5254All elements are removed from <var>aname</var> before the assignment.
5255Other <var>name</var> arguments are ignored.
5256</p>
5257</dd>
5258<dt><code>-d <var>delim</var></code></dt>
5259<dd><p>The first character of <var>delim</var> is used to terminate the input line,
17345e5a 5260rather than newline.
9a51695b
CR
5261If <var>delim</var> is the empty string, <code>read</code> will terminate a line
5262when it reads a NUL character.
a0c0a00f
CR
5263</p>
5264</dd>
5265<dt><code>-e</code></dt>
5266<dd><p>Readline (see <a href="#Command-Line-Editing">Command Line Editing</a>) is used to obtain the line.
17345e5a 5267Readline uses the current (or default, if line editing was not previously
9a51695b 5268active) editing settings, but uses Readline&rsquo;s default filename completion.
a0c0a00f
CR
5269</p>
5270</dd>
5271<dt><code>-i <var>text</var></code></dt>
5272<dd><p>If Readline is being used to read the line, <var>text</var> is placed into
17345e5a 5273the editing buffer before editing begins.
a0c0a00f
CR
5274</p>
5275</dd>
5276<dt><code>-n <var>nchars</var></code></dt>
5277<dd><p><code>read</code> returns after reading <var>nchars</var> characters rather than
5278waiting for a complete line of input, but honors a delimiter if fewer
5279than <var>nchars</var> characters are read before the delimiter.
5280</p>
5281</dd>
5282<dt><code>-N <var>nchars</var></code></dt>
5283<dd><p><code>read</code> returns after reading exactly <var>nchars</var> characters rather
0001803f 5284than waiting for a complete line of input, unless EOF is encountered or
a0c0a00f 5285<code>read</code> times out.
0001803f 5286Delimiter characters encountered in the input are
a0c0a00f
CR
5287not treated specially and do not cause <code>read</code> to return until
5288<var>nchars</var> characters are read.
5289The result is not split on the characters in <code>IFS</code>; the intent is
5290that the variable is assigned exactly the characters read
5291(with the exception of backslash; see the <samp>-r</samp> option below).
5292</p>
5293</dd>
5294<dt><code>-p <var>prompt</var></code></dt>
5295<dd><p>Display <var>prompt</var>, without a trailing newline, before attempting
17345e5a
JA
5296to read any input.
5297The prompt is displayed only if input is coming from a terminal.
a0c0a00f
CR
5298</p>
5299</dd>
5300<dt><code>-r</code></dt>
5301<dd><p>If this option is given, backslash does not act as an escape character.
17345e5a
JA
5302The backslash is considered to be part of the line.
5303In particular, a backslash-newline pair may not be used as a line
5304continuation.
a0c0a00f
CR
5305</p>
5306</dd>
5307<dt><code>-s</code></dt>
5308<dd><p>Silent mode. If input is coming from a terminal, characters are
17345e5a 5309not echoed.
a0c0a00f
CR
5310</p>
5311</dd>
5312<dt><code>-t <var>timeout</var></code></dt>
5313<dd><p>Cause <code>read</code> to time out and return failure if a complete line of
ac50fbac 5314input (or a specified number of characters)
a0c0a00f
CR
5315is not read within <var>timeout</var> seconds.
5316<var>timeout</var> may be a decimal number with a fractional portion following
17345e5a 5317the decimal point.
a0c0a00f 5318This option is only effective if <code>read</code> is reading input from a
17345e5a
JA
5319terminal, pipe, or other special file; it has no effect when reading
5320from regular files.
a0c0a00f
CR
5321If <code>read</code> times out, <code>read</code> saves any partial input read into
5322the specified variable <var>name</var>.
5323If <var>timeout</var> is 0, <code>read</code> returns immediately, without trying to
ac50fbac
CR
5324read and data. The exit status is 0 if input is available on
5325the specified file descriptor, non-zero otherwise.
17345e5a 5326The exit status is greater than 128 if the timeout is exceeded.
a0c0a00f
CR
5327</p>
5328</dd>
5329<dt><code>-u <var>fd</var></code></dt>
5330<dd><p>Read input from file descriptor <var>fd</var>.
5331</p></dd>
5332</dl>
5333
5334</dd>
5335<dt><code>readarray</code></dt>
5336<dd><a name="index-readarray"></a>
5337<div class="example">
2f5dfe5a
CR
5338<pre class="example">readarray [-d <var>delim</var>] [-n <var>count</var>] [-O <var>origin</var>] [-s <var>count</var>]
5339 [-t] [-u <var>fd</var>] [-C <var>callback</var>] [-c <var>quantum</var>] [<var>array</var>]
a0c0a00f
CR
5340</pre></div>
5341
5342<p>Read lines from the standard input into the indexed array variable <var>array</var>,
5343or from file descriptor <var>fd</var>
5344if the <samp>-u</samp> option is supplied.
5345</p>
5346<p>A synonym for <code>mapfile</code>.
5347</p>
5348</dd>
5349<dt><code>source</code></dt>
5350<dd><a name="index-source"></a>
5351<div class="example">
5352<pre class="example">source <var>filename</var>
5353</pre></div>
5354
5355<p>A synonym for <code>.</code> (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
5356</p>
5357</dd>
5358<dt><code>type</code></dt>
5359<dd><a name="index-type"></a>
5360<div class="example">
5361<pre class="example">type [-afptP] [<var>name</var> &hellip;]
5362</pre></div>
5363
5364<p>For each <var>name</var>, indicate how it would be interpreted if used as a
17345e5a 5365command name.
a0c0a00f
CR
5366</p>
5367<p>If the <samp>-t</samp> option is used, <code>type</code> prints a single word
5368which is one of &lsquo;<samp>alias</samp>&rsquo;, &lsquo;<samp>function</samp>&rsquo;, &lsquo;<samp>builtin</samp>&rsquo;,
5369&lsquo;<samp>file</samp>&rsquo; or &lsquo;<samp>keyword</samp>&rsquo;,
5370if <var>name</var> is an alias, shell function, shell builtin,
17345e5a 5371disk file, or shell reserved word, respectively.
a0c0a00f
CR
5372If the <var>name</var> is not found, then nothing is printed, and
5373<code>type</code> returns a failure status.
5374</p>
5375<p>If the <samp>-p</samp> option is used, <code>type</code> either returns the name
5376of the disk file that would be executed, or nothing if <samp>-t</samp>
5377would not return &lsquo;<samp>file</samp>&rsquo;.
5378</p>
5379<p>The <samp>-P</samp> option forces a path search for each <var>name</var>, even if
5380<samp>-t</samp> would not return &lsquo;<samp>file</samp>&rsquo;.
5381</p>
5382<p>If a command is hashed, <samp>-p</samp> and <samp>-P</samp> print the hashed value,
5383which is not necessarily the file that appears first in <code>$PATH</code>.
5384</p>
5385<p>If the <samp>-a</samp> option is used, <code>type</code> returns all of the places
5386that contain an executable named <var>file</var>.
5387This includes aliases and functions, if and only if the <samp>-p</samp> option
17345e5a 5388is not also used.
a0c0a00f
CR
5389</p>
5390<p>If the <samp>-f</samp> option is used, <code>type</code> does not attempt to find
5391shell functions, as with the <code>command</code> builtin.
5392</p>
5393<p>The return status is zero if all of the <var>names</var> are found, non-zero
17345e5a 5394if any are not found.
a0c0a00f
CR
5395</p>
5396</dd>
5397<dt><code>typeset</code></dt>
5398<dd><a name="index-typeset"></a>
5399<div class="example">
5400<pre class="example">typeset [-afFgrxilnrtux] [-p] [<var>name</var>[=<var>value</var>] &hellip;]
5401</pre></div>
5402
5403<p>The <code>typeset</code> command is supplied for compatibility with the Korn
ac50fbac 5404shell.
a0c0a00f
CR
5405It is a synonym for the <code>declare</code> builtin command.
5406</p>
5407</dd>
5408<dt><code>ulimit</code></dt>
5409<dd><a name="index-ulimit"></a>
5410<div class="example">
5411<pre class="example">ulimit [-HSabcdefiklmnpqrstuvxPT] [<var>limit</var>]
5412</pre></div>
5413
5414<p><code>ulimit</code> provides control over the resources available to processes
17345e5a
JA
5415started by the shell, on systems that allow such control. If an
5416option is given, it is interpreted as follows:
a0c0a00f
CR
5417</p>
5418<dl compact="compact">
5419<dt><code>-S</code></dt>
5420<dd><p>Change and report the soft limit associated with a resource.
5421</p>
5422</dd>
5423<dt><code>-H</code></dt>
5424<dd><p>Change and report the hard limit associated with a resource.
5425</p>
5426</dd>
5427<dt><code>-a</code></dt>
5428<dd><p>All current limits are reported.
5429</p>
5430</dd>
5431<dt><code>-b</code></dt>
5432<dd><p>The maximum socket buffer size.
5433</p>
5434</dd>
5435<dt><code>-c</code></dt>
5436<dd><p>The maximum size of core files created.
5437</p>
5438</dd>
5439<dt><code>-d</code></dt>
5440<dd><p>The maximum size of a process&rsquo;s data segment.
5441</p>
5442</dd>
5443<dt><code>-e</code></dt>
5444<dd><p>The maximum scheduling priority (&quot;nice&quot;).
5445</p>
5446</dd>
5447<dt><code>-f</code></dt>
5448<dd><p>The maximum size of files written by the shell and its children.
5449</p>
5450</dd>
5451<dt><code>-i</code></dt>
5452<dd><p>The maximum number of pending signals.
5453</p>
5454</dd>
5455<dt><code>-k</code></dt>
5456<dd><p>The maximum number of kqueues that may be allocated.
5457</p>
5458</dd>
5459<dt><code>-l</code></dt>
5460<dd><p>The maximum size that may be locked into memory.
5461</p>
5462</dd>
5463<dt><code>-m</code></dt>
5464<dd><p>The maximum resident set size (many systems do not honor this limit).
5465</p>
5466</dd>
5467<dt><code>-n</code></dt>
5468<dd><p>The maximum number of open file descriptors (most systems do not
0001803f 5469allow this value to be set).
a0c0a00f
CR
5470</p>
5471</dd>
5472<dt><code>-p</code></dt>
5473<dd><p>The pipe buffer size.
5474</p>
5475</dd>
5476<dt><code>-q</code></dt>
5477<dd><p>The maximum number of bytes in POSIX message queues.
5478</p>
5479</dd>
5480<dt><code>-r</code></dt>
5481<dd><p>The maximum real-time scheduling priority.
5482</p>
5483</dd>
5484<dt><code>-s</code></dt>
5485<dd><p>The maximum stack size.
5486</p>
5487</dd>
5488<dt><code>-t</code></dt>
5489<dd><p>The maximum amount of cpu time in seconds.
5490</p>
5491</dd>
5492<dt><code>-u</code></dt>
5493<dd><p>The maximum number of processes available to a single user.
5494</p>
5495</dd>
5496<dt><code>-v</code></dt>
5497<dd><p>The maximum amount of virtual memory available to the shell, and, on
495aee44 5498some systems, to its children.
a0c0a00f
CR
5499</p>
5500</dd>
5501<dt><code>-x</code></dt>
5502<dd><p>The maximum number of file locks.
5503</p>
5504</dd>
5505<dt><code>-P</code></dt>
5506<dd><p>The maximum number of pseudoterminals.
5507</p>
5508</dd>
5509<dt><code>-T</code></dt>
5510<dd><p>The maximum number of threads.
5511</p></dd>
5512</dl>
5513
5514<p>If <var>limit</var> is given, and the <samp>-a</samp> option is not used,
5515<var>limit</var> is the new value of the specified resource.
5516The special <var>limit</var> values <code>hard</code>, <code>soft</code>, and
5517<code>unlimited</code> stand for the current hard limit, the current soft limit,
17345e5a
JA
5518and no limit, respectively.
5519A hard limit cannot be increased by a non-root user once it is set;
5520a soft limit may be increased up to the value of the hard limit.
5521Otherwise, the current value of the soft limit for the specified resource
a0c0a00f
CR
5522is printed, unless the <samp>-H</samp> option is supplied.
5523When setting new limits, if neither <samp>-H</samp> nor <samp>-S</samp> is supplied,
17345e5a 5524both the hard and soft limits are set.
a0c0a00f
CR
5525If no option is given, then <samp>-f</samp> is assumed. Values are in 1024-byte
5526increments, except for <samp>-t</samp>, which is in seconds; <samp>-p</samp>,
5527which is in units of 512-byte blocks;
5528<samp>-P</samp>,
5529<samp>-T</samp>,
5530<samp>-b</samp>,
5531<samp>-k</samp>,
5532<samp>-n</samp> and <samp>-u</samp>, which are unscaled values;
5533and, when in <small>POSIX</small> Mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>),
5534<samp>-c</samp> and <samp>-f</samp>, which are in 512-byte increments.
5535</p>
5536<p>The return status is zero unless an invalid option or argument is supplied,
17345e5a 5537or an error occurs while setting a new limit.
a0c0a00f
CR
5538</p>
5539</dd>
5540<dt><code>unalias</code></dt>
5541<dd><a name="index-unalias"></a>
5542<div class="example">
5543<pre class="example">unalias [-a] [<var>name</var> &hellip; ]
5544</pre></div>
5545
5546<p>Remove each <var>name</var> from the list of aliases. If <samp>-a</samp> is
17345e5a 5547supplied, all aliases are removed.
a0c0a00f
CR
5548Aliases are described in <a href="#Aliases">Aliases</a>.
5549</p></dd>
5550</dl>
5551
5552<hr>
5553<a name="Modifying-Shell-Behavior"></a>
5554<div class="header">
5555<p>
5556Next: <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>
5557</div>
5558<a name="Modifying-Shell-Behavior-1"></a>
5559<h3 class="section">4.3 Modifying Shell Behavior</h3>
17345e5a 5560
a0c0a00f
CR
5561<table class="menu" border="0" cellspacing="0">
5562<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
5563 positional parameters.
5564</td></tr>
5565<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.
5566</td></tr>
5567</table>
5568
5569<hr>
5570<a name="The-Set-Builtin"></a>
5571<div class="header">
5572<p>
5573Next: <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>
5574</div>
5575<a name="The-Set-Builtin-1"></a>
5576<h4 class="subsection">4.3.1 The Set Builtin</h4>
5577
5578<p>This builtin is so complicated that it deserves its own section. <code>set</code>
17345e5a
JA
5579allows you to change the values of shell options and set the positional
5580parameters, or to display the names and values of shell variables.
a0c0a00f
CR
5581</p>
5582<dl compact="compact">
5583<dt><code>set</code></dt>
5584<dd><a name="index-set"></a>
5585<div class="example">
5586<pre class="example">set [--abefhkmnptuvxBCEHPT] [-o <var>option-name</var>] [<var>argument</var> &hellip;]
5587set [+abefhkmnptuvxBCEHPT] [+o <var>option-name</var>] [<var>argument</var> &hellip;]
5588</pre></div>
5589
5590<p>If no options or arguments are supplied, <code>set</code> displays the names
17345e5a
JA
5591and values of all shell variables and functions, sorted according to the
5592current locale, in a format that may be reused as input
5593for setting or resetting the currently-set variables.
5594Read-only variables cannot be reset.
a0c0a00f
CR
5595In <small>POSIX</small> mode, only shell variables are listed.
5596</p>
5597<p>When options are supplied, they set or unset shell attributes.
17345e5a 5598Options, if specified, have the following meanings:
a0c0a00f
CR
5599</p>
5600<dl compact="compact">
5601<dt><code>-a</code></dt>
5602<dd><p>Each variable or function that is created or modified is given the
5603export attribute and marked for export to the environment of
5604subsequent commands.
5605</p>
5606</dd>
5607<dt><code>-b</code></dt>
5608<dd><p>Cause the status of terminated background jobs to be reported
17345e5a 5609immediately, rather than before printing the next primary prompt.
a0c0a00f
CR
5610</p>
5611</dd>
5612<dt><code>-e</code></dt>
5613<dd><p>Exit immediately if
5614a pipeline (see <a href="#Pipelines">Pipelines</a>), which may consist of a single simple command
5615(see <a href="#Simple-Commands">Simple Commands</a>),
5616a list (see <a href="#Lists">Lists</a>),
5617or a compound command (see <a href="#Compound-Commands">Compound Commands</a>)
0001803f
CR
5618returns a non-zero status.
5619The shell does not exit if the command that fails is part of the
a0c0a00f
CR
5620command list immediately following a <code>while</code> or <code>until</code> keyword,
5621part of the test in an <code>if</code> statement,
5622part of any command executed in a <code>&amp;&amp;</code> or <code>||</code> list except
5623the command following the final <code>&amp;&amp;</code> or <code>||</code>,
17345e5a 5624any command in a pipeline but the last,
a0c0a00f 5625or if the command&rsquo;s return status is being inverted with <code>!</code>.
ac50fbac
CR
5626If a compound command other than a subshell
5627returns a non-zero status because a command failed
a0c0a00f
CR
5628while <samp>-e</samp> was being ignored, the shell does not exit.
5629A trap on <code>ERR</code>, if set, is executed before the shell exits.
5630</p>
5631<p>This option applies to the shell environment and each subshell environment
5632separately (see <a href="#Command-Execution-Environment">Command Execution Environment</a>), and may cause
0001803f 5633subshells to exit before executing all the commands in the subshell.
a0c0a00f
CR
5634</p>
5635<p>If a compound command or shell function executes in a context where
5636<samp>-e</samp> is being ignored,
ac50fbac 5637none of the commands executed within the compound command or function body
a0c0a00f 5638will be affected by the <samp>-e</samp> setting, even if <samp>-e</samp> is set
ac50fbac 5639and a command returns a failure status.
a0c0a00f
CR
5640If a compound command or shell function sets <samp>-e</samp> while executing in
5641a context where <samp>-e</samp> is ignored, that setting will not have any
ac50fbac
CR
5642effect until the compound command or the command containing the function
5643call completes.
a0c0a00f
CR
5644</p>
5645</dd>
5646<dt><code>-f</code></dt>
5647<dd><p>Disable filename expansion (globbing).
5648</p>
5649</dd>
5650<dt><code>-h</code></dt>
5651<dd><p>Locate and remember (hash) commands as they are looked up for execution.
17345e5a 5652This option is enabled by default.
a0c0a00f
CR
5653</p>
5654</dd>
5655<dt><code>-k</code></dt>
5656<dd><p>All arguments in the form of assignment statements are placed
17345e5a
JA
5657in the environment for a command, not just those that precede
5658the command name.
a0c0a00f
CR
5659</p>
5660</dd>
5661<dt><code>-m</code></dt>
5662<dd><p>Job control is enabled (see <a href="#Job-Control">Job Control</a>).
ac50fbac
CR
5663All processes run in a separate process group.
5664When a background job completes, the shell prints a line
5665containing its exit status.
a0c0a00f
CR
5666</p>
5667</dd>
5668<dt><code>-n</code></dt>
5669<dd><p>Read commands but do not execute them.
5670This may be used to check a script for syntax errors.
17345e5a 5671This option is ignored by interactive shells.
a0c0a00f
CR
5672</p>
5673</dd>
5674<dt><code>-o <var>option-name</var></code></dt>
5675<dd>
5676<p>Set the option corresponding to <var>option-name</var>:
5677</p>
5678<dl compact="compact">
5679<dt><code>allexport</code></dt>
5680<dd><p>Same as <code>-a</code>.
5681</p>
5682</dd>
5683<dt><code>braceexpand</code></dt>
5684<dd><p>Same as <code>-B</code>.
5685</p>
5686</dd>
5687<dt><code>emacs</code></dt>
5688<dd><p>Use an <code>emacs</code>-style line editing interface (see <a href="#Command-Line-Editing">Command Line Editing</a>).
5689This also affects the editing interface used for <code>read -e</code>.
5690</p>
5691</dd>
5692<dt><code>errexit</code></dt>
5693<dd><p>Same as <code>-e</code>.
5694</p>
5695</dd>
5696<dt><code>errtrace</code></dt>
5697<dd><p>Same as <code>-E</code>.
5698</p>
5699</dd>
5700<dt><code>functrace</code></dt>
5701<dd><p>Same as <code>-T</code>.
5702</p>
5703</dd>
5704<dt><code>hashall</code></dt>
5705<dd><p>Same as <code>-h</code>.
5706</p>
5707</dd>
5708<dt><code>histexpand</code></dt>
5709<dd><p>Same as <code>-H</code>.
5710</p>
5711</dd>
5712<dt><code>history</code></dt>
5713<dd><p>Enable command history, as described in <a href="#Bash-History-Facilities">Bash History Facilities</a>.
17345e5a 5714This option is on by default in interactive shells.
a0c0a00f
CR
5715</p>
5716</dd>
5717<dt><code>ignoreeof</code></dt>
5718<dd><p>An interactive shell will not exit upon reading EOF.
5719</p>
5720</dd>
5721<dt><code>keyword</code></dt>
5722<dd><p>Same as <code>-k</code>.
5723</p>
5724</dd>
5725<dt><code>monitor</code></dt>
5726<dd><p>Same as <code>-m</code>.
5727</p>
5728</dd>
5729<dt><code>noclobber</code></dt>
5730<dd><p>Same as <code>-C</code>.
5731</p>
5732</dd>
5733<dt><code>noexec</code></dt>
5734<dd><p>Same as <code>-n</code>.
5735</p>
5736</dd>
5737<dt><code>noglob</code></dt>
5738<dd><p>Same as <code>-f</code>.
5739</p>
5740</dd>
5741<dt><code>nolog</code></dt>
5742<dd><p>Currently ignored.
5743</p>
5744</dd>
5745<dt><code>notify</code></dt>
5746<dd><p>Same as <code>-b</code>.
5747</p>
5748</dd>
5749<dt><code>nounset</code></dt>
5750<dd><p>Same as <code>-u</code>.
5751</p>
5752</dd>
5753<dt><code>onecmd</code></dt>
5754<dd><p>Same as <code>-t</code>.
5755</p>
5756</dd>
5757<dt><code>physical</code></dt>
5758<dd><p>Same as <code>-P</code>.
5759</p>
5760</dd>
5761<dt><code>pipefail</code></dt>
5762<dd><p>If set, the return value of a pipeline is the value of the last
17345e5a
JA
5763(rightmost) command to exit with a non-zero status, or zero if all
5764commands in the pipeline exit successfully.
5765This option is disabled by default.
a0c0a00f
CR
5766</p>
5767</dd>
5768<dt><code>posix</code></dt>
5769<dd><p>Change the behavior of Bash where the default operation differs
5770from the <small>POSIX</small> standard to match the standard
5771(see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>).
17345e5a
JA
5772This is intended to make Bash behave as a strict superset of that
5773standard.
a0c0a00f
CR
5774</p>
5775</dd>
5776<dt><code>privileged</code></dt>
5777<dd><p>Same as <code>-p</code>.
5778</p>
5779</dd>
5780<dt><code>verbose</code></dt>
5781<dd><p>Same as <code>-v</code>.
5782</p>
5783</dd>
5784<dt><code>vi</code></dt>
5785<dd><p>Use a <code>vi</code>-style line editing interface.
5786This also affects the editing interface used for <code>read -e</code>.
5787</p>
5788</dd>
5789<dt><code>xtrace</code></dt>
5790<dd><p>Same as <code>-x</code>.
5791</p></dd>
5792</dl>
5793
5794</dd>
5795<dt><code>-p</code></dt>
5796<dd><p>Turn on privileged mode.
5797In this mode, the <code>$BASH_ENV</code> and <code>$ENV</code> files are not
17345e5a 5798processed, shell functions are not inherited from the environment,
a0c0a00f 5799and the <code>SHELLOPTS</code>, <code>BASHOPTS</code>, <code>CDPATH</code> and <code>GLOBIGNORE</code>
0001803f 5800variables, if they appear in the environment, are ignored.
17345e5a 5801If the shell is started with the effective user (group) id not equal to the
a0c0a00f 5802real user (group) id, and the <samp>-p</samp> option is not supplied, these actions
17345e5a 5803are taken and the effective user id is set to the real user id.
a0c0a00f 5804If the <samp>-p</samp> option is supplied at startup, the effective user id is
17345e5a
JA
5805not reset.
5806Turning this option off causes the effective user
5807and group ids to be set to the real user and group ids.
a0c0a00f
CR
5808</p>
5809</dd>
5810<dt><code>-t</code></dt>
5811<dd><p>Exit after reading and executing one command.
5812</p>
5813</dd>
5814<dt><code>-u</code></dt>
5815<dd><p>Treat unset variables and parameters other than the special parameters
5816&lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo; as an error when performing parameter expansion.
17345e5a
JA
5817An error message will be written to the standard error, and a non-interactive
5818shell will exit.
a0c0a00f
CR
5819</p>
5820</dd>
5821<dt><code>-v</code></dt>
5822<dd><p>Print shell input lines as they are read.
5823</p>
5824</dd>
5825<dt><code>-x</code></dt>
5826<dd><p>Print a trace of simple commands, <code>for</code> commands, <code>case</code>
5827commands, <code>select</code> commands, and arithmetic <code>for</code> commands
17345e5a 5828and their arguments or associated word lists after they are
a0c0a00f 5829expanded and before they are executed. The value of the <code>PS4</code>
17345e5a
JA
5830variable is expanded and the resultant value is printed before
5831the command and its expanded arguments.
a0c0a00f
CR
5832</p>
5833</dd>
5834<dt><code>-B</code></dt>
5835<dd><p>The shell will perform brace expansion (see <a href="#Brace-Expansion">Brace Expansion</a>).
17345e5a 5836This option is on by default.
a0c0a00f
CR
5837</p>
5838</dd>
5839<dt><code>-C</code></dt>
5840<dd><p>Prevent output redirection using &lsquo;<samp>&gt;</samp>&rsquo;, &lsquo;<samp>&gt;&amp;</samp>&rsquo;, and &lsquo;<samp>&lt;&gt;</samp>&rsquo;
17345e5a 5841from overwriting existing files.
a0c0a00f
CR
5842</p>
5843</dd>
5844<dt><code>-E</code></dt>
5845<dd><p>If set, any trap on <code>ERR</code> is inherited by shell functions, command
17345e5a 5846substitutions, and commands executed in a subshell environment.
a0c0a00f
CR
5847The <code>ERR</code> trap is normally not inherited in such cases.
5848</p>
5849</dd>
5850<dt><code>-H</code></dt>
5851<dd><p>Enable &lsquo;<samp>!</samp>&rsquo; style history substitution (see <a href="#History-Interaction">History Interaction</a>).
17345e5a 5852This option is on by default for interactive shells.
a0c0a00f
CR
5853</p>
5854</dd>
5855<dt><code>-P</code></dt>
5856<dd><p>If set, do not resolve symbolic links when performing commands such as
5857<code>cd</code> which change the current directory. The physical directory
17345e5a
JA
5858is used instead. By default, Bash follows
5859the logical chain of directories when performing commands
5860which change the current directory.
a0c0a00f
CR
5861</p>
5862<p>For example, if <samp>/usr/sys</samp> is a symbolic link to <samp>/usr/local/sys</samp>
17345e5a 5863then:
a0c0a00f
CR
5864</p><div class="example">
5865<pre class="example">$ cd /usr/sys; echo $PWD
17345e5a
JA
5866/usr/sys
5867$ cd ..; pwd
5868/usr
a0c0a00f 5869</pre></div>
17345e5a 5870
a0c0a00f
CR
5871<p>If <code>set -P</code> is on, then:
5872</p><div class="example">
5873<pre class="example">$ cd /usr/sys; echo $PWD
17345e5a
JA
5874/usr/local/sys
5875$ cd ..; pwd
5876/usr/local
a0c0a00f 5877</pre></div>
17345e5a 5878
a0c0a00f
CR
5879</dd>
5880<dt><code>-T</code></dt>
5881<dd><p>If set, any trap on <code>DEBUG</code> and <code>RETURN</code> are inherited by
17345e5a
JA
5882shell functions, command substitutions, and commands executed
5883in a subshell environment.
a0c0a00f 5884The <code>DEBUG</code> and <code>RETURN</code> traps are normally not inherited
17345e5a 5885in such cases.
a0c0a00f
CR
5886</p>
5887</dd>
5888<dt><code>--</code></dt>
5889<dd><p>If no arguments follow this option, then the positional parameters are
17345e5a 5890unset. Otherwise, the positional parameters are set to the
a0c0a00f
CR
5891<var>arguments</var>, even if some of them begin with a &lsquo;<samp>-</samp>&rsquo;.
5892</p>
5893</dd>
5894<dt><code>-</code></dt>
5895<dd><p>Signal the end of options, cause all remaining <var>arguments</var>
5896to be assigned to the positional parameters. The <samp>-x</samp>
5897and <samp>-v</samp> options are turned off.
17345e5a 5898If there are no arguments, the positional parameters remain unchanged.
a0c0a00f
CR
5899</p></dd>
5900</dl>
17345e5a 5901
a0c0a00f 5902<p>Using &lsquo;<samp>+</samp>&rsquo; rather than &lsquo;<samp>-</samp>&rsquo; causes these options to be
17345e5a 5903turned off. The options can also be used upon invocation of the
a0c0a00f
CR
5904shell. The current set of options may be found in <code>$-</code>.
5905</p>
5906<p>The remaining N <var>arguments</var> are positional parameters and are
5907assigned, in order, to <code>$1</code>, <code>$2</code>, &hellip; <code>$N</code>.
5908The special parameter <code>#</code> is set to N.
5909</p>
5910<p>The return status is always zero unless an invalid option is supplied.
5911</p></dd>
5912</dl>
5913
5914<hr>
5915<a name="The-Shopt-Builtin"></a>
5916<div class="header">
5917<p>
5918Previous: <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>
5919</div>
5920<a name="The-Shopt-Builtin-1"></a>
5921<h4 class="subsection">4.3.2 The Shopt Builtin</h4>
5922
5923<p>This builtin allows you to change additional shell optional behavior.
5924</p>
5925<dl compact="compact">
5926<dt><code>shopt</code></dt>
5927<dd><a name="index-shopt"></a>
5928<div class="example">
5929<pre class="example">shopt [-pqsu] [-o] [<var>optname</var> &hellip;]
5930</pre></div>
5931
5932<p>Toggle the values of settings controlling optional shell behavior.
ac50fbac 5933The settings can be either those listed below, or, if the
a0c0a00f
CR
5934<samp>-o</samp> option is used, those available with the <samp>-o</samp>
5935option to the <code>set</code> builtin command (see <a href="#The-Set-Builtin">The Set Builtin</a>).
5936With no options, or with the <samp>-p</samp> option, a list of all settable
9a51695b
CR
5937options is displayed, with an indication of whether or not each is set;
5938if <var>optnames</var> are supplied, the output is restricted to those options.
a0c0a00f 5939The <samp>-p</samp> option causes output to be displayed in a form that
17345e5a
JA
5940may be reused as input.
5941Other options have the following meanings:
a0c0a00f
CR
5942</p>
5943<dl compact="compact">
5944<dt><code>-s</code></dt>
5945<dd><p>Enable (set) each <var>optname</var>.
5946</p>
5947</dd>
5948<dt><code>-u</code></dt>
5949<dd><p>Disable (unset) each <var>optname</var>.
5950</p>
5951</dd>
5952<dt><code>-q</code></dt>
5953<dd><p>Suppresses normal output; the return status
5954indicates whether the <var>optname</var> is set or unset.
5955If multiple <var>optname</var> arguments are given with <samp>-q</samp>,
5956the return status is zero if all <var>optnames</var> are enabled;
17345e5a 5957non-zero otherwise.
a0c0a00f
CR
5958</p>
5959</dd>
5960<dt><code>-o</code></dt>
5961<dd><p>Restricts the values of
5962<var>optname</var> to be those defined for the <samp>-o</samp> option to the
5963<code>set</code> builtin (see <a href="#The-Set-Builtin">The Set Builtin</a>).
5964</p></dd>
5965</dl>
5966
5967<p>If either <samp>-s</samp> or <samp>-u</samp>
5968is used with no <var>optname</var> arguments, <code>shopt</code> shows only
17345e5a 5969those options which are set or unset, respectively.
a0c0a00f
CR
5970</p>
5971<p>Unless otherwise noted, the <code>shopt</code> options are disabled (off)
17345e5a 5972by default.
a0c0a00f
CR
5973</p>
5974<p>The return status when listing options is zero if all <var>optnames</var>
17345e5a 5975are enabled, non-zero otherwise. When setting or unsetting options,
a0c0a00f 5976the return status is zero unless an <var>optname</var> is not a valid shell
17345e5a 5977option.
a0c0a00f
CR
5978</p>
5979<p>The list of <code>shopt</code> options is:
5980</p><dl compact="compact">
9a51695b
CR
5981<dt><code>assoc_expand_once</code></dt>
5982<dd><p>If set, the shell suppresses multiple evaluation of associative array
5983subscripts during arithmetic expression evaluation and while executing
5984builtins that can perform variable assignments.
5985</p>
5986</dd>
a0c0a00f
CR
5987<dt><code>autocd</code></dt>
5988<dd><p>If set, a command name that is the name of a directory is executed as if
5989it were the argument to the <code>cd</code> command.
17345e5a 5990This option is only used by interactive shells.
a0c0a00f
CR
5991</p>
5992</dd>
5993<dt><code>cdable_vars</code></dt>
5994<dd><p>If this is set, an argument to the <code>cd</code> builtin command that
17345e5a
JA
5995is not a directory is assumed to be the name of a variable whose
5996value is the directory to change to.
a0c0a00f
CR
5997</p>
5998</dd>
5999<dt><code>cdspell</code></dt>
6000<dd><p>If set, minor errors in the spelling of a directory component in a
6001<code>cd</code> command will be corrected.
17345e5a
JA
6002The errors checked for are transposed characters,
6003a missing character, and a character too many.
6004If a correction is found, the corrected path is printed,
6005and the command proceeds.
6006This option is only used by interactive shells.
a0c0a00f
CR
6007</p>
6008</dd>
6009<dt><code>checkhash</code></dt>
6010<dd><p>If this is set, Bash checks that a command found in the hash
17345e5a
JA
6011table exists before trying to execute it. If a hashed command no
6012longer exists, a normal path search is performed.
a0c0a00f
CR
6013</p>
6014</dd>
6015<dt><code>checkjobs</code></dt>
6016<dd><p>If set, Bash lists the status of any stopped and running jobs before
17345e5a
JA
6017exiting an interactive shell. If any jobs are running, this causes
6018the exit to be deferred until a second exit is attempted without an
a0c0a00f 6019intervening command (see <a href="#Job-Control">Job Control</a>).
17345e5a 6020The shell always postpones exiting if any jobs are stopped.
a0c0a00f
CR
6021</p>
6022</dd>
6023<dt><code>checkwinsize</code></dt>
9a51695b
CR
6024<dd><p>If set, Bash checks the window size after each external (non-builtin)
6025command and, if necessary, updates the values of
a0c0a00f
CR
6026<code>LINES</code> and <code>COLUMNS</code>.
6027</p>
6028</dd>
6029<dt><code>cmdhist</code></dt>
6030<dd><p>If set, Bash
17345e5a
JA
6031attempts to save all lines of a multiple-line
6032command in the same history entry. This allows
6033easy re-editing of multi-line commands.
9a51695b
CR
6034This option is enabled by default, but only has an effect if command
6035history is enabled (see <a href="#Bash-History-Facilities">Bash History Facilities</a>).
a0c0a00f
CR
6036</p>
6037</dd>
6038<dt><code>compat31</code></dt>
6039<dd><p>If set, Bash
17345e5a 6040changes its behavior to that of version 3.1 with respect to quoted
a0c0a00f 6041arguments to the conditional command&rsquo;s &lsquo;<samp>=~</samp>&rsquo; operator
ac50fbac 6042and with respect to locale-specific
a0c0a00f
CR
6043string comparison when using the <code>[[</code>
6044conditional command&rsquo;s &lsquo;<samp>&lt;</samp>&rsquo; and &lsquo;<samp>&gt;</samp>&rsquo; operators.
ac50fbac 6045Bash versions prior to bash-4.1 use ASCII collation and strcmp(3);
a0c0a00f
CR
6046bash-4.1 and later use the current locale&rsquo;s collation sequence and strcoll(3).
6047</p>
6048</dd>
6049<dt><code>compat32</code></dt>
6050<dd><p>If set, Bash
495aee44 6051changes its behavior to that of version 3.2 with respect to locale-specific
a0c0a00f
CR
6052string comparison when using the <code>[[</code>
6053conditional command&rsquo;s &lsquo;<samp>&lt;</samp>&rsquo; and &lsquo;<samp>&gt;</samp>&rsquo; operators (see previous item)
6054and the effect of interrupting a command list.
6055Bash versions 3.2 and earlier continue with the next command in the list
6056after one terminates due to an interrupt.
6057</p>
6058</dd>
6059<dt><code>compat40</code></dt>
6060<dd><p>If set, Bash
495aee44 6061changes its behavior to that of version 4.0 with respect to locale-specific
a0c0a00f
CR
6062string comparison when using the <code>[[</code>
6063conditional command&rsquo;s &lsquo;<samp>&lt;</samp>&rsquo; and &lsquo;<samp>&gt;</samp>&rsquo; operators (see description
6064of <code>compat31</code>)
495aee44 6065and the effect of interrupting a command list.
ac50fbac
CR
6066Bash versions 4.0 and later interrupt the list as if the shell received the
6067interrupt; previous versions continue with the next command in the list.
a0c0a00f
CR
6068</p>
6069</dd>
6070<dt><code>compat41</code></dt>
6071<dd><p>If set, Bash, when in <small>POSIX</small> mode, treats a single quote in a double-quoted
495aee44
CR
6072parameter expansion as a special character. The single quotes must match
6073(an even number) and the characters between the single quotes are considered
a0c0a00f 6074quoted. This is the behavior of <small>POSIX</small> mode through version 4.1.
495aee44 6075The default Bash behavior remains as in previous versions.
a0c0a00f
CR
6076</p>
6077</dd>
6078<dt><code>compat42</code></dt>
6079<dd><p>If set, Bash
ac50fbac
CR
6080does not process the replacement string in the pattern substitution word
6081expansion using quote removal.
a0c0a00f
CR
6082</p>
6083</dd>
6084<dt><code>compat43</code></dt>
6085<dd><p>If set, Bash
6086does not print a warning message if an attempt is made to use a quoted compound
6087array assignment as an argument to <code>declare</code>,
6088makes word expansion errors
6089non-fatal errors that cause the current command to fail (the default behavior is
6090to make them fatal errors that cause the shell to exit),
6091and does not reset the
6092loop state when a shell function is executed (this allows <code>break</code> or
6093<code>continue</code> in a shell function to affect loops in the caller&rsquo;s context).
6094</p>
6095</dd>
9a51695b
CR
6096<dt><code>compat44</code></dt>
6097<dd><p>If set, Bash
6098saves the positional parameters to BASH_ARGV and BASH_ARGC before they are
6099used, regardless of whether or not extended debugging mode is enabled.
6100</p>
6101</dd>
a0c0a00f
CR
6102<dt><code>complete_fullquote</code></dt>
6103<dd><p>If set, Bash
ac50fbac
CR
6104quotes all shell metacharacters in filenames and directory names when
6105performing completion.
6106If not set, Bash
6107removes metacharacters such as the dollar sign from the set of
6108characters that will be quoted in completed filenames
6109when these metacharacters appear in shell variable references in words to be
6110completed.
6111This means that dollar signs in variable names that expand to directories
6112will not be quoted;
6113however, any dollar signs appearing in filenames will not be quoted, either.
6114This is active only when bash is using backslashes to quote completed
6115filenames.
6116This variable is set by default, which is the default Bash behavior in
6117versions through 4.2.
a0c0a00f
CR
6118</p>
6119</dd>
6120<dt><code>direxpand</code></dt>
6121<dd><p>If set, Bash
ac50fbac
CR
6122replaces directory names with the results of word expansion when performing
6123filename completion. This changes the contents of the readline editing
6124buffer.
6125If not set, Bash attempts to preserve what the user typed.
a0c0a00f
CR
6126</p>
6127</dd>
6128<dt><code>dirspell</code></dt>
6129<dd><p>If set, Bash
17345e5a
JA
6130attempts spelling correction on directory names during word completion
6131if the directory name initially supplied does not exist.
a0c0a00f
CR
6132</p>
6133</dd>
6134<dt><code>dotglob</code></dt>
6135<dd><p>If set, Bash includes filenames beginning with a &lsquo;.&rsquo; in
17345e5a 6136the results of filename expansion.
9a51695b
CR
6137The filenames &lsquo;<samp>.</samp>&rsquo; and &lsquo;<samp>..</samp>&rsquo; must always be matched explicitly,
6138even if <code>dotglob</code> is set.
a0c0a00f
CR
6139</p>
6140</dd>
6141<dt><code>execfail</code></dt>
6142<dd><p>If this is set, a non-interactive shell will not exit if
6143it cannot execute the file specified as an argument to the <code>exec</code>
6144builtin command. An interactive shell does not exit if <code>exec</code>
17345e5a 6145fails.
a0c0a00f
CR
6146</p>
6147</dd>
6148<dt><code>expand_aliases</code></dt>
6149<dd><p>If set, aliases are expanded as described below under Aliases,
6150<a href="#Aliases">Aliases</a>.
17345e5a 6151This option is enabled by default for interactive shells.
a0c0a00f
CR
6152</p>
6153</dd>
6154<dt><code>extdebug</code></dt>
6155<dd><p>If set at shell invocation, arrange to execute the debugger profile
6156before the shell starts, identical to the <samp>--debugger</samp> option.
6157If set after invocation, behavior intended for use by debuggers is enabled:
6158</p>
6159<ol>
6160<li> The <samp>-F</samp> option to the <code>declare</code> builtin (see <a href="#Bash-Builtins">Bash Builtins</a>)
17345e5a
JA
6161displays the source file name and line number corresponding to each function
6162name supplied as an argument.
17345e5a 6163
a0c0a00f 6164</li><li> If the command run by the <code>DEBUG</code> trap returns a non-zero value, the
17345e5a 6165next command is skipped and not executed.
17345e5a 6166
a0c0a00f 6167</li><li> If the command run by the <code>DEBUG</code> trap returns a value of 2, and the
17345e5a 6168shell is executing in a subroutine (a shell function or a shell script
a0c0a00f
CR
6169executed by the <code>.</code> or <code>source</code> builtins), the shell simulates
6170a call to <code>return</code>.
6171
6172</li><li> <code>BASH_ARGC</code> and <code>BASH_ARGV</code> are updated as described in their
6173descriptions (see <a href="#Bash-Variables">Bash Variables</a>).
6174
6175</li><li> Function tracing is enabled: command substitution, shell functions, and
6176subshells invoked with <code>( <var>command</var> )</code> inherit the
6177<code>DEBUG</code> and <code>RETURN</code> traps.
6178
6179</li><li> Error tracing is enabled: command substitution, shell functions, and
6180subshells invoked with <code>( <var>command</var> )</code> inherit the
6181<code>ERR</code> trap.
6182</li></ol>
6183
6184</dd>
6185<dt><code>extglob</code></dt>
6186<dd><p>If set, the extended pattern matching features described above
6187(see <a href="#Pattern-Matching">Pattern Matching</a>) are enabled.
6188</p>
6189</dd>
6190<dt><code>extquote</code></dt>
6191<dd><p>If set, <code>$'<var>string</var>'</code> and <code>$&quot;<var>string</var>&quot;</code> quoting is
6192performed within <code>${<var>parameter</var>}</code> expansions
17345e5a 6193enclosed in double quotes. This option is enabled by default.
a0c0a00f
CR
6194</p>
6195</dd>
6196<dt><code>failglob</code></dt>
6197<dd><p>If set, patterns which fail to match filenames during filename expansion
17345e5a 6198result in an expansion error.
a0c0a00f
CR
6199</p>
6200</dd>
6201<dt><code>force_fignore</code></dt>
6202<dd><p>If set, the suffixes specified by the <code>FIGNORE</code> shell variable
17345e5a
JA
6203cause words to be ignored when performing word completion even if
6204the ignored words are the only possible completions.
a0c0a00f 6205See <a href="#Bash-Variables">Bash Variables</a>, for a description of <code>FIGNORE</code>.
17345e5a 6206This option is enabled by default.
a0c0a00f
CR
6207</p>
6208</dd>
6209<dt><code>globasciiranges</code></dt>
6210<dd><p>If set, range expressions used in pattern matching bracket expressions
6211(see <a href="#Pattern-Matching">Pattern Matching</a>)
ac50fbac 6212behave as if in the traditional C locale when performing
a0c0a00f 6213comparisons. That is, the current locale&rsquo;s collating sequence
ac50fbac 6214is not taken into account, so
a0c0a00f 6215&lsquo;<samp>b</samp>&rsquo; will not collate between &lsquo;<samp>A</samp>&rsquo; and &lsquo;<samp>B</samp>&rsquo;,
ac50fbac 6216and upper-case and lower-case ASCII characters will collate together.
a0c0a00f
CR
6217</p>
6218</dd>
6219<dt><code>globstar</code></dt>
6220<dd><p>If set, the pattern &lsquo;<samp>**</samp>&rsquo; used in a filename expansion context will
ac50fbac 6221match all files and zero or more directories and subdirectories.
a0c0a00f 6222If the pattern is followed by a &lsquo;<samp>/</samp>&rsquo;, only directories and
17345e5a 6223subdirectories match.
a0c0a00f
CR
6224</p>
6225</dd>
6226<dt><code>gnu_errfmt</code></dt>
6227<dd><p>If set, shell error messages are written in the standard <small>GNU</small> error
17345e5a 6228message format.
a0c0a00f
CR
6229</p>
6230</dd>
6231<dt><code>histappend</code></dt>
6232<dd><p>If set, the history list is appended to the file named by the value
6233of the <code>HISTFILE</code>
17345e5a 6234variable when the shell exits, rather than overwriting the file.
a0c0a00f
CR
6235</p>
6236</dd>
6237<dt><code>histreedit</code></dt>
6238<dd><p>If set, and Readline
17345e5a
JA
6239is being used, a user is given the opportunity to re-edit a
6240failed history substitution.
a0c0a00f
CR
6241</p>
6242</dd>
6243<dt><code>histverify</code></dt>
6244<dd><p>If set, and Readline
17345e5a
JA
6245is being used, the results of history substitution are not immediately
6246passed to the shell parser. Instead, the resulting line is loaded into
6247the Readline editing buffer, allowing further modification.
a0c0a00f
CR
6248</p>
6249</dd>
6250<dt><code>hostcomplete</code></dt>
6251<dd><p>If set, and Readline is being used, Bash will attempt to perform
6252hostname completion when a word containing a &lsquo;<samp>@</samp>&rsquo; is being
6253completed (see <a href="#Commands-For-Completion">Commands For Completion</a>). This option is enabled
17345e5a 6254by default.
a0c0a00f
CR
6255</p>
6256</dd>
6257<dt><code>huponexit</code></dt>
6258<dd><p>If set, Bash will send <code>SIGHUP</code> to all jobs when an interactive
6259login shell exits (see <a href="#Signals">Signals</a>).
6260</p>
6261</dd>
6262<dt><code>inherit_errexit</code></dt>
6263<dd><p>If set, command substitution inherits the value of the <code>errexit</code> option,
6264instead of unsetting it in the subshell environment.
6265This option is enabled when <small>POSIX</small> mode is enabled.
6266</p>
6267</dd>
6268<dt><code>interactive_comments</code></dt>
6269<dd><p>Allow a word beginning with &lsquo;<samp>#</samp>&rsquo;
17345e5a
JA
6270to cause that word and all remaining characters on that
6271line to be ignored in an interactive shell.
6272This option is enabled by default.
a0c0a00f
CR
6273</p>
6274</dd>
6275<dt><code>lastpipe</code></dt>
6276<dd><p>If set, and job control is not active, the shell runs the last command of
495aee44 6277a pipeline not executed in the background in the current shell environment.
a0c0a00f
CR
6278</p>
6279</dd>
6280<dt><code>lithist</code></dt>
6281<dd><p>If enabled, and the <code>cmdhist</code>
17345e5a
JA
6282option is enabled, multi-line commands are saved to the history with
6283embedded newlines rather than using semicolon separators where possible.
a0c0a00f
CR
6284</p>
6285</dd>
9a51695b
CR
6286<dt><code>localvar_inherit</code></dt>
6287<dd><p>If set, local variables inherit the value and attributes of a variable of
6288the same name that exists at a previous scope before any new value is
6289assigned. The <var>nameref</var> attribute is not inherited.
6290</p>
6291</dd>
a0c0a00f
CR
6292<dt><code>login_shell</code></dt>
6293<dd><p>The shell sets this option if it is started as a login shell
6294(see <a href="#Invoking-Bash">Invoking Bash</a>).
17345e5a 6295The value may not be changed.
a0c0a00f
CR
6296</p>
6297</dd>
6298<dt><code>mailwarn</code></dt>
6299<dd><p>If set, and a file that Bash is checking for mail has been
17345e5a 6300accessed since the last time it was checked, the message
a0c0a00f
CR
6301<code>&quot;The mail in <var>mailfile</var> has been read&quot;</code> is displayed.
6302</p>
6303</dd>
6304<dt><code>no_empty_cmd_completion</code></dt>
6305<dd><p>If set, and Readline is being used, Bash will not attempt to search
6306the <code>PATH</code> for possible completions when completion is attempted
17345e5a 6307on an empty line.
a0c0a00f
CR
6308</p>
6309</dd>
6310<dt><code>nocaseglob</code></dt>
6311<dd><p>If set, Bash matches filenames in a case-insensitive fashion when
17345e5a 6312performing filename expansion.
a0c0a00f
CR
6313</p>
6314</dd>
6315<dt><code>nocasematch</code></dt>
6316<dd><p>If set, Bash matches patterns in a case-insensitive fashion when
6317performing matching while executing <code>case</code> or <code>[[</code>
6318conditional commands,
6319when performing pattern substitution word expansions,
6320or when filtering possible completions as part of programmable completion.
6321</p>
6322</dd>
6323<dt><code>nullglob</code></dt>
6324<dd><p>If set, Bash allows filename patterns which match no
17345e5a 6325files to expand to a null string, rather than themselves.
a0c0a00f
CR
6326</p>
6327</dd>
6328<dt><code>progcomp</code></dt>
6329<dd><p>If set, the programmable completion facilities
6330(see <a href="#Programmable-Completion">Programmable Completion</a>) are enabled.
17345e5a 6331This option is enabled by default.
a0c0a00f
CR
6332</p>
6333</dd>
6334<dt><code>promptvars</code></dt>
6335<dd><p>If set, prompt strings undergo
17345e5a
JA
6336parameter expansion, command substitution, arithmetic
6337expansion, and quote removal after being expanded
a0c0a00f 6338as described below (see <a href="#Controlling-the-Prompt">Controlling the Prompt</a>).
17345e5a 6339This option is enabled by default.
a0c0a00f
CR
6340</p>
6341</dd>
6342<dt><code>restricted_shell</code></dt>
6343<dd><p>The shell sets this option if it is started in restricted mode
6344(see <a href="#The-Restricted-Shell">The Restricted Shell</a>).
17345e5a
JA
6345The value may not be changed.
6346This is not reset when the startup files are executed, allowing
6347the startup files to discover whether or not a shell is restricted.
a0c0a00f
CR
6348</p>
6349</dd>
6350<dt><code>shift_verbose</code></dt>
6351<dd><p>If this is set, the <code>shift</code>
17345e5a
JA
6352builtin prints an error message when the shift count exceeds the
6353number of positional parameters.
a0c0a00f
CR
6354</p>
6355</dd>
6356<dt><code>sourcepath</code></dt>
6357<dd><p>If set, the <code>source</code> builtin uses the value of <code>PATH</code>
17345e5a
JA
6358to find the directory containing the file supplied as an argument.
6359This option is enabled by default.
a0c0a00f
CR
6360</p>
6361</dd>
6362<dt><code>xpg_echo</code></dt>
6363<dd><p>If set, the <code>echo</code> builtin expands backslash-escape sequences
17345e5a 6364by default.
a0c0a00f
CR
6365</p>
6366</dd>
6367</dl>
17345e5a 6368
a0c0a00f 6369<p>The return status when listing options is zero if all <var>optnames</var>
17345e5a
JA
6370are enabled, non-zero otherwise.
6371When setting or unsetting options, the return status is zero unless an
a0c0a00f
CR
6372<var>optname</var> is not a valid shell option.
6373</p></dd>
6374</dl>
6375
6376<hr>
6377<a name="Special-Builtins"></a>
6378<div class="header">
6379<p>
6380Previous: <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>
6381</div>
6382<a name="Special-Builtins-1"></a>
6383<h3 class="section">4.4 Special Builtins</h3>
6384<a name="index-special-builtin-1"></a>
6385
6386<p>For historical reasons, the <small>POSIX</small> standard has classified
6387several builtin commands as <em>special</em>.
6388When Bash is executing in <small>POSIX</small> mode, the special builtins
17345e5a 6389differ from other builtin commands in three respects:
a0c0a00f
CR
6390</p>
6391<ol>
6392<li> Special builtins are found before shell functions during command lookup.
17345e5a 6393
a0c0a00f 6394</li><li> If a special builtin returns an error status, a non-interactive shell exits.
17345e5a 6395
a0c0a00f 6396</li><li> Assignment statements preceding the command stay in effect in the shell
17345e5a 6397environment after the command completes.
a0c0a00f 6398</li></ol>
17345e5a 6399
a0c0a00f 6400<p>When Bash is not executing in <small>POSIX</small> mode, these builtins behave no
17345e5a 6401differently than the rest of the Bash builtin commands.
a0c0a00f
CR
6402The Bash <small>POSIX</small> mode is described in <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>.
6403</p>
6404<p>These are the <small>POSIX</small> special builtins:
6405</p><div class="example">
6406<pre class="example">break : . continue eval exec exit export readonly return set<!-- /@w -->
6407shift trap unset<!-- /@w -->
6408</pre></div>
6409
6410<hr>
6411<a name="Shell-Variables"></a>
6412<div class="header">
6413<p>
6414Next: <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>
6415</div>
6416<a name="Shell-Variables-1"></a>
6417<h2 class="chapter">5 Shell Variables</h2>
6418
6419<table class="menu" border="0" cellspacing="0">
6420<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
6421 as the Bourne Shell.
6422</td></tr>
6423<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.
6424</td></tr>
6425</table>
6426
6427<p>This chapter describes the shell variables that Bash uses.
17345e5a 6428Bash automatically assigns default values to a number of variables.
a0c0a00f
CR
6429</p>
6430<hr>
6431<a name="Bourne-Shell-Variables"></a>
6432<div class="header">
6433<p>
6434Next: <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>
6435</div>
6436<a name="Bourne-Shell-Variables-1"></a>
6437<h3 class="section">5.1 Bourne Shell Variables</h3>
6438
6439<p>Bash uses certain shell variables in the same way as the Bourne shell.
17345e5a 6440In some cases, Bash assigns a default value to the variable.
a0c0a00f
CR
6441</p>
6442<dl compact="compact">
6443<dt><code>CDPATH</code>
6444<a name="index-CDPATH"></a>
6445</dt>
6446<dd><p>A colon-separated list of directories used as a search path for
6447the <code>cd</code> builtin command.
6448</p>
6449</dd>
6450<dt><code>HOME</code>
6451<a name="index-HOME"></a>
6452</dt>
6453<dd><p>The current user&rsquo;s home directory; the default for the <code>cd</code> builtin
17345e5a
JA
6454command.
6455The value of this variable is also used by tilde expansion
a0c0a00f
CR
6456(see <a href="#Tilde-Expansion">Tilde Expansion</a>).
6457</p>
6458</dd>
6459<dt><code>IFS</code>
6460<a name="index-IFS"></a>
6461</dt>
6462<dd><p>A list of characters that separate fields; used when the shell splits
17345e5a 6463words as part of expansion.
a0c0a00f
CR
6464</p>
6465</dd>
6466<dt><code>MAIL</code>
6467<a name="index-MAIL"></a>
6468</dt>
6469<dd><p>If this parameter is set to a filename or directory name
6470and the <code>MAILPATH</code> variable
17345e5a 6471is not set, Bash informs the user of the arrival of mail in
495aee44 6472the specified file or Maildir-format directory.
a0c0a00f
CR
6473</p>
6474</dd>
6475<dt><code>MAILPATH</code>
6476<a name="index-MAILPATH"></a>
6477</dt>
6478<dd><p>A colon-separated list of filenames which the shell periodically checks
17345e5a
JA
6479for new mail.
6480Each list entry can specify the message that is printed when new mail
ac50fbac 6481arrives in the mail file by separating the filename from the message with
a0c0a00f
CR
6482a &lsquo;<samp>?</samp>&rsquo;.
6483When used in the text of the message, <code>$_</code> expands to the name of
17345e5a 6484the current mail file.
a0c0a00f
CR
6485</p>
6486</dd>
6487<dt><code>OPTARG</code>
6488<a name="index-OPTARG"></a>
6489</dt>
6490<dd><p>The value of the last option argument processed by the <code>getopts</code> builtin.
6491</p>
6492</dd>
6493<dt><code>OPTIND</code>
6494<a name="index-OPTIND"></a>
6495</dt>
6496<dd><p>The index of the last option argument processed by the <code>getopts</code> builtin.
6497</p>
6498</dd>
6499<dt><code>PATH</code>
6500<a name="index-PATH"></a>
6501</dt>
6502<dd><p>A colon-separated list of directories in which the shell looks for
17345e5a 6503commands.
a0c0a00f 6504A zero-length (null) directory name in the value of <code>PATH</code> indicates the
17345e5a
JA
6505current directory.
6506A null directory name may appear as two adjacent colons, or as an initial
6507or trailing colon.
a0c0a00f
CR
6508</p>
6509</dd>
6510<dt><code>PS1</code>
6511<a name="index-PS1"></a>
6512</dt>
6513<dd><p>The primary prompt string. The default value is &lsquo;<samp>\s-\v\$ </samp>&rsquo;.
6514See <a href="#Controlling-the-Prompt">Controlling the Prompt</a>, for the complete list of escape
6515sequences that are expanded before <code>PS1</code> is displayed.
6516</p>
6517</dd>
6518<dt><code>PS2</code>
6519<a name="index-PS2"></a>
6520</dt>
6521<dd><p>The secondary prompt string. The default value is &lsquo;<samp>&gt; </samp>&rsquo;.
9a51695b
CR
6522<code>PS2</code> is expanded in the same way as <code>PS1</code> before being
6523displayed.
a0c0a00f
CR
6524</p>
6525</dd>
6526</dl>
6527
6528<hr>
6529<a name="Bash-Variables"></a>
6530<div class="header">
6531<p>
6532Previous: <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>
6533</div>
6534<a name="Bash-Variables-1"></a>
6535<h3 class="section">5.2 Bash Variables</h3>
6536
6537<p>These variables are set or used by Bash, but other shells
17345e5a 6538do not normally treat them specially.
a0c0a00f
CR
6539</p>
6540<p>A few variables used by Bash are described in different chapters:
17345e5a 6541variables for controlling the job control facilities
a0c0a00f
CR
6542(see <a href="#Job-Control-Variables">Job Control Variables</a>).
6543</p>
6544<dl compact="compact">
6545<dt><code>BASH</code>
6546<a name="index-BASH"></a>
6547</dt>
6548<dd><p>The full pathname used to execute the current instance of Bash.
6549</p>
6550</dd>
6551<dt><code>BASHOPTS</code>
6552<a name="index-BASHOPTS"></a>
6553</dt>
6554<dd><p>A colon-separated list of enabled shell options. Each word in
6555the list is a valid argument for the <samp>-s</samp> option to the
6556<code>shopt</code> builtin command (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>).
6557The options appearing in <code>BASHOPTS</code> are those reported
6558as &lsquo;<samp>on</samp>&rsquo; by &lsquo;<samp>shopt</samp>&rsquo;.
0001803f
CR
6559If this variable is in the environment when Bash
6560starts up, each shell option in the list will be enabled before
6561reading any startup files. This variable is readonly.
a0c0a00f
CR
6562</p>
6563</dd>
6564<dt><code>BASHPID</code>
6565<a name="index-BASHPID"></a>
6566</dt>
6567<dd><p>Expands to the process ID of the current Bash process.
6568This differs from <code>$$</code> under certain circumstances, such as subshells
17345e5a 6569that do not require Bash to be re-initialized.
9a51695b
CR
6570Assignments to <code>BASHPID</code> have no effect.
6571If <code>BASHPID</code>
6572is unset, it loses its special properties, even if it is
6573subsequently reset.
a0c0a00f
CR
6574</p>
6575</dd>
6576<dt><code>BASH_ALIASES</code>
6577<a name="index-BASH_005fALIASES"></a>
6578</dt>
6579<dd><p>An associative array variable whose members correspond to the internal
6580list of aliases as maintained by the <code>alias</code> builtin.
6581(see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
6582Elements added to this array appear in the alias list; however,
6583unsetting array elements currently does not cause aliases to be removed
6584from the alias list.
6585If <code>BASH_ALIASES</code>
6586is unset, it loses its special properties, even if it is
6587subsequently reset.
6588</p>
6589</dd>
6590<dt><code>BASH_ARGC</code>
6591<a name="index-BASH_005fARGC"></a>
6592</dt>
6593<dd><p>An array variable whose values are the number of parameters in each
17345e5a
JA
6594frame of the current bash execution call stack. The number of
6595parameters to the current subroutine (shell function or script executed
a0c0a00f 6596with <code>.</code> or <code>source</code>) is at the top of the stack. When a
17345e5a 6597subroutine is executed, the number of parameters passed is pushed onto
a0c0a00f
CR
6598<code>BASH_ARGC</code>.
6599The shell sets <code>BASH_ARGC</code> only when in extended debugging mode
6600(see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>
6601for a description of the <code>extdebug</code> option to the <code>shopt</code>
17345e5a 6602builtin).
2f5dfe5a
CR
6603Setting <code>extdebug</code> after the shell has started to execute a script,
6604or referencing this variable when <code>extdebug</code> is not set,
9a51695b 6605may result in inconsistent values.
a0c0a00f
CR
6606</p>
6607</dd>
6608<dt><code>BASH_ARGV</code>
6609<a name="index-BASH_005fARGV"></a>
6610</dt>
6611<dd><p>An array variable containing all of the parameters in the current bash
17345e5a
JA
6612execution call stack. The final parameter of the last subroutine call
6613is at the top of the stack; the first parameter of the initial call is
6614at the bottom. When a subroutine is executed, the parameters supplied
a0c0a00f
CR
6615are pushed onto <code>BASH_ARGV</code>.
6616The shell sets <code>BASH_ARGV</code> only when in extended debugging mode
6617(see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>
6618for a description of the <code>extdebug</code> option to the <code>shopt</code>
17345e5a 6619builtin).
2f5dfe5a
CR
6620Setting <code>extdebug</code> after the shell has started to execute a script,
6621or referencing this variable when <code>extdebug</code> is not set,
9a51695b
CR
6622may result in inconsistent values.
6623</p>
6624</dd>
6625<dt><code>BASH_ARGV0</code>
6626<a name="index-BASH_005fARGV0"></a>
6627</dt>
6628<dd><p>When referenced, this variable expands to the name of the shell or shell
6629script (identical to <code>$0</code>; See <a href="#Special-Parameters">Special Parameters</a>,
6630for the description of special parameter 0).
6631Assignment to <code>BASH_ARGV0</code>
6632causes the value assigned to also be assigned to <code>$0</code>.
6633If <code>BASH_ARGV0</code>
6634is unset, it loses its special properties, even if it is
6635subsequently reset.
a0c0a00f
CR
6636</p>
6637</dd>
6638<dt><code>BASH_CMDS</code>
6639<a name="index-BASH_005fCMDS"></a>
6640</dt>
6641<dd><p>An associative array variable whose members correspond to the internal
6642hash table of commands as maintained by the <code>hash</code> builtin
6643(see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
6644Elements added to this array appear in the hash table; however,
6645unsetting array elements currently does not cause command names to be removed
6646from the hash table.
6647If <code>BASH_CMDS</code>
6648is unset, it loses its special properties, even if it is
6649subsequently reset.
6650</p>
6651</dd>
6652<dt><code>BASH_COMMAND</code>
6653<a name="index-BASH_005fCOMMAND"></a>
6654</dt>
6655<dd><p>The command currently being executed or about to be executed, unless the
17345e5a
JA
6656shell is executing a command as the result of a trap,
6657in which case it is the command executing at the time of the trap.
a0c0a00f
CR
6658</p>
6659</dd>
6660<dt><code>BASH_COMPAT</code>
6661<a name="index-BASH_005fCOMPAT"></a>
6662</dt>
6663<dd><p>The value is used to set the shell&rsquo;s compatibility level.
6664See <a href="#The-Shopt-Builtin">The Shopt Builtin</a>, for a description of the various compatibility
ac50fbac
CR
6665levels and their effects.
6666The value may be a decimal number (e.g., 4.2) or an integer (e.g., 42)
6667corresponding to the desired compatibility level.
a0c0a00f 6668If <code>BASH_COMPAT</code> is unset or set to the empty string, the compatibility
ac50fbac 6669level is set to the default for the current version.
a0c0a00f 6670If <code>BASH_COMPAT</code> is set to a value that is not one of the valid
ac50fbac
CR
6671compatibility levels, the shell prints an error message and sets the
6672compatibility level to the default for the current version.
6673The valid compatibility levels correspond to the compatibility options
a0c0a00f
CR
6674accepted by the <code>shopt</code> builtin described above (for example,
6675<var>compat42</var> means that 4.2 and 42 are valid values).
ac50fbac 6676The current version is also a valid value.
a0c0a00f
CR
6677</p>
6678</dd>
6679<dt><code>BASH_ENV</code>
6680<a name="index-BASH_005fENV"></a>
6681</dt>
6682<dd><p>If this variable is set when Bash is invoked to execute a shell
17345e5a 6683script, its value is expanded and used as the name of a startup file
a0c0a00f
CR
6684to read before executing the script. See <a href="#Bash-Startup-Files">Bash Startup Files</a>.
6685</p>
6686</dd>
6687<dt><code>BASH_EXECUTION_STRING</code>
6688<a name="index-BASH_005fEXECUTION_005fSTRING"></a>
6689</dt>
6690<dd><p>The command argument to the <samp>-c</samp> invocation option.
6691</p>
6692</dd>
6693<dt><code>BASH_LINENO</code>
6694<a name="index-BASH_005fLINENO"></a>
6695</dt>
6696<dd><p>An array variable whose members are the line numbers in source files
6697where each corresponding member of <var>FUNCNAME</var> was invoked.
6698<code>${BASH_LINENO[$i]}</code> is the line number in the source file
6699(<code>${BASH_SOURCE[$i+1]}</code>) where
6700<code>${FUNCNAME[$i]}</code> was called (or <code>${BASH_LINENO[$i-1]}</code> if
495aee44 6701referenced within another shell function).
a0c0a00f
CR
6702Use <code>LINENO</code> to obtain the current line number.
6703</p>
6704</dd>
6705<dt><code>BASH_LOADABLES_PATH</code>
6706<a name="index-BASH_005fLOADABLES_005fPATH"></a>
6707</dt>
6708<dd><p>A colon-separated list of directories in which the shell looks for
6709dynamically loadable builtins specified by the
6710<code>enable</code> command.
6711</p>
6712</dd>
6713<dt><code>BASH_REMATCH</code>
6714<a name="index-BASH_005fREMATCH"></a>
6715</dt>
6716<dd><p>An array variable whose members are assigned by the &lsquo;<samp>=~</samp>&rsquo; binary
6717operator to the <code>[[</code> conditional command
6718(see <a href="#Conditional-Constructs">Conditional Constructs</a>).
17345e5a
JA
6719The element with index 0 is the portion of the string
6720matching the entire regular expression.
a0c0a00f
CR
6721The element with index <var>n</var> is the portion of the
6722string matching the <var>n</var>th parenthesized subexpression.
17345e5a 6723This variable is read-only.
a0c0a00f
CR
6724</p>
6725</dd>
6726<dt><code>BASH_SOURCE</code>
6727<a name="index-BASH_005fSOURCE"></a>
6728</dt>
6729<dd><p>An array variable whose members are the source filenames where the
6730corresponding shell function names in the <code>FUNCNAME</code> array
495aee44 6731variable are defined.
a0c0a00f
CR
6732The shell function <code>${FUNCNAME[$i]}</code> is defined in the file
6733<code>${BASH_SOURCE[$i]}</code> and called from <code>${BASH_SOURCE[$i+1]}</code>
6734</p>
6735</dd>
6736<dt><code>BASH_SUBSHELL</code>
6737<a name="index-BASH_005fSUBSHELL"></a>
6738</dt>
6739<dd><p>Incremented by one within each subshell or subshell environment when
ac50fbac 6740the shell begins executing in that environment.
17345e5a 6741The initial value is 0.
a0c0a00f
CR
6742</p>
6743</dd>
6744<dt><code>BASH_VERSINFO</code>
6745<a name="index-BASH_005fVERSINFO"></a>
6746</dt>
6747<dd><p>A readonly array variable (see <a href="#Arrays">Arrays</a>)
17345e5a
JA
6748whose members hold version information for this instance of Bash.
6749The values assigned to the array members are as follows:
a0c0a00f
CR
6750</p>
6751<dl compact="compact">
6752<dt><code>BASH_VERSINFO[0]</code></dt>
6753<dd><p>The major version number (the <var>release</var>).
6754</p>
6755</dd>
6756<dt><code>BASH_VERSINFO[1]</code></dt>
6757<dd><p>The minor version number (the <var>version</var>).
6758</p>
6759</dd>
6760<dt><code>BASH_VERSINFO[2]</code></dt>
6761<dd><p>The patch level.
6762</p>
6763</dd>
6764<dt><code>BASH_VERSINFO[3]</code></dt>
6765<dd><p>The build version.
6766</p>
6767</dd>
6768<dt><code>BASH_VERSINFO[4]</code></dt>
6769<dd><p>The release status (e.g., <var>beta1</var>).
6770</p>
6771</dd>
6772<dt><code>BASH_VERSINFO[5]</code></dt>
6773<dd><p>The value of <code>MACHTYPE</code>.
6774</p></dd>
6775</dl>
6776
6777</dd>
6778<dt><code>BASH_VERSION</code>
6779<a name="index-BASH_005fVERSION"></a>
6780</dt>
6781<dd><p>The version number of the current instance of Bash.
6782</p>
6783</dd>
6784<dt><code>BASH_XTRACEFD</code>
6785<a name="index-BASH_005fXTRACEFD"></a>
6786</dt>
6787<dd><p>If set to an integer corresponding to a valid file descriptor, Bash
6788will write the trace output generated when &lsquo;<samp>set -x</samp>&rsquo;
0001803f
CR
6789is enabled to that file descriptor.
6790This allows tracing output to be separated from diagnostic and error
6791messages.
a0c0a00f 6792The file descriptor is closed when <code>BASH_XTRACEFD</code> is unset or assigned
0001803f 6793a new value.
a0c0a00f 6794Unsetting <code>BASH_XTRACEFD</code> or assigning it the empty string causes the
0001803f 6795trace output to be sent to the standard error.
a0c0a00f 6796Note that setting <code>BASH_XTRACEFD</code> to 2 (the standard error file
0001803f
CR
6797descriptor) and then unsetting it will result in the standard error
6798being closed.
a0c0a00f
CR
6799</p>
6800</dd>
6801<dt><code>CHILD_MAX</code>
6802<a name="index-CHILD_005fMAX"></a>
6803</dt>
6804<dd><p>Set the number of exited child status values for the shell to remember.
6805Bash will not allow this value to be decreased below a <small>POSIX</small>-mandated
ac50fbac
CR
6806minimum, and there is a maximum value (currently 8192) that this may
6807not exceed.
6808The minimum value is system-dependent.
a0c0a00f
CR
6809</p>
6810</dd>
6811<dt><code>COLUMNS</code>
6812<a name="index-COLUMNS"></a>
6813</dt>
6814<dd><p>Used by the <code>select</code> command to determine the terminal width
ac50fbac 6815when printing selection lists.
a0c0a00f
CR
6816Automatically set if the <code>checkwinsize</code> option is enabled
6817(see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), or in an interactive shell upon receipt of a
6818<code>SIGWINCH</code>.
6819</p>
6820</dd>
6821<dt><code>COMP_CWORD</code>
6822<a name="index-COMP_005fCWORD"></a>
6823</dt>
6824<dd><p>An index into <code>${COMP_WORDS}</code> of the word containing the current
17345e5a
JA
6825cursor position.
6826This variable is available only in shell functions invoked by the
a0c0a00f
CR
6827programmable completion facilities (see <a href="#Programmable-Completion">Programmable Completion</a>).
6828</p>
6829</dd>
6830<dt><code>COMP_LINE</code>
6831<a name="index-COMP_005fLINE"></a>
6832</dt>
6833<dd><p>The current command line.
17345e5a
JA
6834This variable is available only in shell functions and external
6835commands invoked by the
a0c0a00f
CR
6836programmable completion facilities (see <a href="#Programmable-Completion">Programmable Completion</a>).
6837</p>
6838</dd>
6839<dt><code>COMP_POINT</code>
6840<a name="index-COMP_005fPOINT"></a>
6841</dt>
6842<dd><p>The index of the current cursor position relative to the beginning of
17345e5a
JA
6843the current command.
6844If the current cursor position is at the end of the current command,
a0c0a00f 6845the value of this variable is equal to <code>${#COMP_LINE}</code>.
17345e5a
JA
6846This variable is available only in shell functions and external
6847commands invoked by the
a0c0a00f
CR
6848programmable completion facilities (see <a href="#Programmable-Completion">Programmable Completion</a>).
6849</p>
6850</dd>
6851<dt><code>COMP_TYPE</code>
6852<a name="index-COMP_005fTYPE"></a>
6853</dt>
6854<dd><p>Set to an integer value corresponding to the type of completion attempted
17345e5a 6855that caused a completion function to be called:
a0c0a00f
CR
6856<var>TAB</var>, for normal completion,
6857&lsquo;<samp>?</samp>&rsquo;, for listing completions after successive tabs,
6858&lsquo;<samp>!</samp>&rsquo;, for listing alternatives on partial word completion,
6859&lsquo;<samp>@</samp>&rsquo;, to list completions if the word is not unmodified,
17345e5a 6860or
a0c0a00f 6861&lsquo;<samp>%</samp>&rsquo;, for menu completion.
17345e5a
JA
6862This variable is available only in shell functions and external
6863commands invoked by the
a0c0a00f
CR
6864programmable completion facilities (see <a href="#Programmable-Completion">Programmable Completion</a>).
6865</p>
6866</dd>
6867<dt><code>COMP_KEY</code>
6868<a name="index-COMP_005fKEY"></a>
6869</dt>
6870<dd><p>The key (or final key of a key sequence) used to invoke the current
17345e5a 6871completion function.
a0c0a00f
CR
6872</p>
6873</dd>
6874<dt><code>COMP_WORDBREAKS</code>
6875<a name="index-COMP_005fWORDBREAKS"></a>
6876</dt>
6877<dd><p>The set of characters that the Readline library treats as word
17345e5a 6878separators when performing word completion.
a0c0a00f 6879If <code>COMP_WORDBREAKS</code> is unset, it loses its special properties,
17345e5a 6880even if it is subsequently reset.
a0c0a00f
CR
6881</p>
6882</dd>
6883<dt><code>COMP_WORDS</code>
6884<a name="index-COMP_005fWORDS"></a>
6885</dt>
6886<dd><p>An array variable consisting of the individual
17345e5a 6887words in the current command line.
0001803f 6888The line is split into words as Readline would split it, using
a0c0a00f 6889<code>COMP_WORDBREAKS</code> as described above.
17345e5a 6890This variable is available only in shell functions invoked by the
a0c0a00f
CR
6891programmable completion facilities (see <a href="#Programmable-Completion">Programmable Completion</a>).
6892</p>
6893</dd>
6894<dt><code>COMPREPLY</code>
6895<a name="index-COMPREPLY"></a>
6896</dt>
6897<dd><p>An array variable from which Bash reads the possible completions
17345e5a 6898generated by a shell function invoked by the programmable completion
a0c0a00f 6899facility (see <a href="#Programmable-Completion">Programmable Completion</a>).
ac50fbac 6900Each array element contains one possible completion.
a0c0a00f
CR
6901</p>
6902</dd>
6903<dt><code>COPROC</code>
6904<a name="index-COPROC"></a>
6905</dt>
6906<dd><p>An array variable created to hold the file descriptors
6907for output from and input to an unnamed coprocess (see <a href="#Coprocesses">Coprocesses</a>).
6908</p>
6909</dd>
6910<dt><code>DIRSTACK</code>
6911<a name="index-DIRSTACK"></a>
6912</dt>
6913<dd><p>An array variable containing the current contents of the directory stack.
17345e5a 6914Directories appear in the stack in the order they are displayed by the
a0c0a00f 6915<code>dirs</code> builtin.
17345e5a 6916Assigning to members of this array variable may be used to modify
a0c0a00f 6917directories already in the stack, but the <code>pushd</code> and <code>popd</code>
17345e5a
JA
6918builtins must be used to add and remove directories.
6919Assignment to this variable will not change the current directory.
a0c0a00f 6920If <code>DIRSTACK</code> is unset, it loses its special properties, even if
17345e5a 6921it is subsequently reset.
a0c0a00f
CR
6922</p>
6923</dd>
6924<dt><code>EMACS</code>
6925<a name="index-EMACS"></a>
6926</dt>
6927<dd><p>If Bash finds this variable in the environment when the shell
6928starts with value &lsquo;<samp>t</samp>&rsquo;, it assumes that the shell is running in an
495aee44 6929Emacs shell buffer and disables line editing.
a0c0a00f
CR
6930</p>
6931</dd>
6932<dt><code>ENV</code>
6933<a name="index-ENV"></a>
6934</dt>
6935<dd><p>Similar to <code>BASH_ENV</code>; used when the shell is invoked in
6936<small>POSIX</small> Mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>).
6937</p>
6938</dd>
9a51695b
CR
6939<dt><code>EPOCHREALTIME</code>
6940<a name="index-EPOCHREALTIME"></a>
6941</dt>
6942<dd><p>Each time this parameter is referenced, it expands to the number of seconds
6943since the Unix Epoch as a floating point value with micro-second granularity
6944(see the documentation for the C library function <var>time</var> for the
6945definition of Epoch).
6946Assignments to <code>EPOCHREALTIME</code> are ignored.
6947If <code>EPOCHREALTIME</code> is unset, it loses its special properties, even if
6948it is subsequently reset.
6949</p>
6950</dd>
6951<dt><code>EPOCHSECONDS</code>
6952<a name="index-EPOCHSECONDS"></a>
6953</dt>
6954<dd><p>Each time this parameter is referenced, it expands to the number of seconds
6955since the Unix Epoch (see the documentation for the C library function
6956<var>time</var> for the definition of Epoch).
6957Assignments to <code>EPOCHSECONDS</code> are ignored.
6958If <code>EPOCHSECONDS</code> is unset, it loses its special properties, even if
6959it is subsequently reset.
6960</p>
6961</dd>
a0c0a00f
CR
6962<dt><code>EUID</code>
6963<a name="index-EUID"></a>
6964</dt>
6965<dd><p>The numeric effective user id of the current user. This variable
495aee44 6966is readonly.
a0c0a00f
CR
6967</p>
6968</dd>
6969<dt><code>EXECIGNORE</code>
6970<a name="index-EXECIGNORE"></a>
6971</dt>
6972<dd><p>A colon-separated list of shell patterns (see <a href="#Pattern-Matching">Pattern Matching</a>)
6973defining the list of filenames to be ignored by command search using
6974<code>PATH</code>.
6975Files whose full pathnames match one of these patterns are not considered
6976executable files for the purposes of completion and command execution
6977via <code>PATH</code> lookup.
6978This does not affect the behavior of the <code>[</code>, <code>test</code>, and <code>[[</code>
6979commands.
6980Full pathnames in the command hash table are not subject to <code>EXECIGNORE</code>.
6981Use this variable to ignore shared library files that have the executable
6982bit set, but are not executable files.
6983The pattern matching honors the setting of the <code>extglob</code> shell
6984option.
6985</p>
6986</dd>
6987<dt><code>FCEDIT</code>
6988<a name="index-FCEDIT"></a>
6989</dt>
6990<dd><p>The editor used as a default by the <samp>-e</samp> option to the <code>fc</code>
17345e5a 6991builtin command.
a0c0a00f
CR
6992</p>
6993</dd>
6994<dt><code>FIGNORE</code>
6995<a name="index-FIGNORE"></a>
6996</dt>
6997<dd><p>A colon-separated list of suffixes to ignore when performing
17345e5a 6998filename completion.
ac50fbac 6999A filename whose suffix matches one of the entries in
a0c0a00f 7000<code>FIGNORE</code>
ac50fbac 7001is excluded from the list of matched filenames. A sample
a0c0a00f
CR
7002value is &lsquo;<samp>.o:~</samp>&rsquo;
7003</p>
7004</dd>
7005<dt><code>FUNCNAME</code>
7006<a name="index-FUNCNAME"></a>
7007</dt>
7008<dd><p>An array variable containing the names of all shell functions
17345e5a
JA
7009currently in the execution call stack.
7010The element with index 0 is the name of any currently-executing
7011shell function.
495aee44 7012The bottom-most element (the one with the highest index)
a0c0a00f 7013is <code>&quot;main&quot;</code>.
17345e5a 7014This variable exists only when a shell function is executing.
a0c0a00f
CR
7015Assignments to <code>FUNCNAME</code> have no effect.
7016If <code>FUNCNAME</code> is unset, it loses its special properties, even if
17345e5a 7017it is subsequently reset.
a0c0a00f
CR
7018</p>
7019<p>This variable can be used with <code>BASH_LINENO</code> and <code>BASH_SOURCE</code>.
7020Each element of <code>FUNCNAME</code> has corresponding elements in
7021<code>BASH_LINENO</code> and <code>BASH_SOURCE</code> to describe the call stack.
7022For instance, <code>${FUNCNAME[$i]}</code> was called from the file
7023<code>${BASH_SOURCE[$i+1]}</code> at line number <code>${BASH_LINENO[$i]}</code>.
7024The <code>caller</code> builtin displays the current call stack using this
495aee44 7025information.
a0c0a00f
CR
7026</p>
7027</dd>
7028<dt><code>FUNCNEST</code>
7029<a name="index-FUNCNEST"></a>
7030</dt>
7031<dd><p>If set to a numeric value greater than 0, defines a maximum function
495aee44
CR
7032nesting level. Function invocations that exceed this nesting level
7033will cause the current command to abort.
a0c0a00f
CR
7034</p>
7035</dd>
7036<dt><code>GLOBIGNORE</code>
7037<a name="index-GLOBIGNORE"></a>
7038</dt>
9a51695b 7039<dd><p>A colon-separated list of patterns defining the set of file names to
17345e5a 7040be ignored by filename expansion.
9a51695b 7041If a file name matched by a filename expansion pattern also matches one
a0c0a00f 7042of the patterns in <code>GLOBIGNORE</code>, it is removed from the list
17345e5a 7043of matches.
a0c0a00f
CR
7044The pattern matching honors the setting of the <code>extglob</code> shell
7045option.
7046</p>
7047</dd>
7048<dt><code>GROUPS</code>
7049<a name="index-GROUPS"></a>
7050</dt>
7051<dd><p>An array variable containing the list of groups of which the current
17345e5a 7052user is a member.
a0c0a00f
CR
7053Assignments to <code>GROUPS</code> have no effect.
7054If <code>GROUPS</code> is unset, it loses its special properties, even if it is
17345e5a 7055subsequently reset.
a0c0a00f
CR
7056</p>
7057</dd>
7058<dt><code>histchars</code>
7059<a name="index-histchars"></a>
7060</dt>
7061<dd><p>Up to three characters which control history expansion, quick
7062substitution, and tokenization (see <a href="#History-Interaction">History Interaction</a>).
17345e5a 7063The first character is the
a0c0a00f
CR
7064<var>history expansion</var> character, that is, the character which signifies the
7065start of a history expansion, normally &lsquo;<samp>!</samp>&rsquo;. The second character is the
7066character which signifies &lsquo;quick substitution&rsquo; when seen as the first
7067character on a line, normally &lsquo;<samp>^</samp>&rsquo;. The optional third character is the
17345e5a 7068character which indicates that the remainder of the line is a comment when
a0c0a00f 7069found as the first character of a word, usually &lsquo;<samp>#</samp>&rsquo;. The history
17345e5a
JA
7070comment character causes history substitution to be skipped for the
7071remaining words on the line. It does not necessarily cause the shell
7072parser to treat the rest of the line as a comment.
a0c0a00f
CR
7073</p>
7074</dd>
7075<dt><code>HISTCMD</code>
7076<a name="index-HISTCMD"></a>
7077</dt>
7078<dd><p>The history number, or index in the history list, of the current
7079command. If <code>HISTCMD</code> is unset, it loses its special properties,
17345e5a 7080even if it is subsequently reset.
a0c0a00f
CR
7081</p>
7082</dd>
7083<dt><code>HISTCONTROL</code>
7084<a name="index-HISTCONTROL"></a>
7085</dt>
7086<dd><p>A colon-separated list of values controlling how commands are saved on
17345e5a 7087the history list.
a0c0a00f 7088If the list of values includes &lsquo;<samp>ignorespace</samp>&rsquo;, lines which begin
17345e5a 7089with a space character are not saved in the history list.
a0c0a00f 7090A value of &lsquo;<samp>ignoredups</samp>&rsquo; causes lines which match the previous
17345e5a 7091history entry to not be saved.
a0c0a00f
CR
7092A value of &lsquo;<samp>ignoreboth</samp>&rsquo; is shorthand for
7093&lsquo;<samp>ignorespace</samp>&rsquo; and &lsquo;<samp>ignoredups</samp>&rsquo;.
7094A value of &lsquo;<samp>erasedups</samp>&rsquo; causes all previous lines matching the
17345e5a
JA
7095current line to be removed from the history list before that line
7096is saved.
7097Any value not in the above list is ignored.
a0c0a00f 7098If <code>HISTCONTROL</code> is unset, or does not include a valid value,
17345e5a 7099all lines read by the shell parser are saved on the history list,
a0c0a00f 7100subject to the value of <code>HISTIGNORE</code>.
17345e5a
JA
7101The second and subsequent lines of a multi-line compound command are
7102not tested, and are added to the history regardless of the value of
a0c0a00f
CR
7103<code>HISTCONTROL</code>.
7104</p>
7105</dd>
7106<dt><code>HISTFILE</code>
7107<a name="index-HISTFILE"></a>
7108</dt>
7109<dd><p>The name of the file to which the command history is saved. The
7110default value is <samp>~/.bash_history</samp>.
7111</p>
7112</dd>
7113<dt><code>HISTFILESIZE</code>
7114<a name="index-HISTFILESIZE"></a>
7115</dt>
7116<dd><p>The maximum number of lines contained in the history file.
ac50fbac
CR
7117When this variable is assigned a value, the history file is truncated,
7118if necessary, to contain no more than that number of lines
7119by removing the oldest entries.
17345e5a 7120The history file is also truncated to this size after
ac50fbac
CR
7121writing it when a shell exits.
7122If the value is 0, the history file is truncated to zero size.
7123Non-numeric values and numeric values less than zero inhibit truncation.
a0c0a00f 7124The shell sets the default value to the value of <code>HISTSIZE</code>
ac50fbac 7125after reading any startup files.
a0c0a00f
CR
7126</p>
7127</dd>
7128<dt><code>HISTIGNORE</code>
7129<a name="index-HISTIGNORE"></a>
7130</dt>
7131<dd><p>A colon-separated list of patterns used to decide which command
17345e5a
JA
7132lines should be saved on the history list. Each pattern is
7133anchored at the beginning of the line and must match the complete
a0c0a00f
CR
7134line (no implicit &lsquo;<samp>*</samp>&rsquo; is appended). Each pattern is tested
7135against the line after the checks specified by <code>HISTCONTROL</code>
17345e5a 7136are applied. In addition to the normal shell pattern matching
a0c0a00f 7137characters, &lsquo;<samp>&amp;</samp>&rsquo; matches the previous history line. &lsquo;<samp>&amp;</samp>&rsquo;
17345e5a
JA
7138may be escaped using a backslash; the backslash is removed
7139before attempting a match.
7140The second and subsequent lines of a multi-line compound command are
7141not tested, and are added to the history regardless of the value of
a0c0a00f
CR
7142<code>HISTIGNORE</code>.
7143The pattern matching honors the setting of the <code>extglob</code> shell
7144option.
7145</p>
7146<p><code>HISTIGNORE</code> subsumes the function of <code>HISTCONTROL</code>. A
7147pattern of &lsquo;<samp>&amp;</samp>&rsquo; is identical to <code>ignoredups</code>, and a
7148pattern of &lsquo;<samp>[ ]*</samp>&rsquo; is identical to <code>ignorespace</code>.
17345e5a 7149Combining these two patterns, separating them with a colon,
a0c0a00f
CR
7150provides the functionality of <code>ignoreboth</code>.
7151</p>
7152</dd>
7153<dt><code>HISTSIZE</code>
7154<a name="index-HISTSIZE"></a>
7155</dt>
7156<dd><p>The maximum number of commands to remember on the history list.
ac50fbac
CR
7157If the value is 0, commands are not saved in the history list.
7158Numeric values less than zero result in every command being saved
7159on the history list (there is no limit).
7160The shell sets the default value to 500 after reading any startup files.
a0c0a00f
CR
7161</p>
7162</dd>
7163<dt><code>HISTTIMEFORMAT</code>
7164<a name="index-HISTTIMEFORMAT"></a>
7165</dt>
7166<dd><p>If this variable is set and not null, its value is used as a format string
7167for <var>strftime</var> to print the time stamp associated with each history
7168entry displayed by the <code>history</code> builtin.
17345e5a
JA
7169If this variable is set, time stamps are written to the history file so
7170they may be preserved across shell sessions.
7171This uses the history comment character to distinguish timestamps from
7172other history lines.
a0c0a00f
CR
7173</p>
7174</dd>
7175<dt><code>HOSTFILE</code>
7176<a name="index-HOSTFILE"></a>
7177</dt>
7178<dd><p>Contains the name of a file in the same format as <samp>/etc/hosts</samp> that
17345e5a
JA
7179should be read when the shell needs to complete a hostname.
7180The list of possible hostname completions may be changed while the shell
7181is running;
7182the next time hostname completion is attempted after the
7183value is changed, Bash adds the contents of the new file to the
7184existing list.
a0c0a00f 7185If <code>HOSTFILE</code> is set, but has no value, or does not name a readable file,
0001803f 7186Bash attempts to read
a0c0a00f
CR
7187<samp>/etc/hosts</samp> to obtain the list of possible hostname completions.
7188When <code>HOSTFILE</code> is unset, the hostname list is cleared.
7189</p>
7190</dd>
7191<dt><code>HOSTNAME</code>
7192<a name="index-HOSTNAME"></a>
7193</dt>
7194<dd><p>The name of the current host.
7195</p>
7196</dd>
7197<dt><code>HOSTTYPE</code>
7198<a name="index-HOSTTYPE"></a>
7199</dt>
7200<dd><p>A string describing the machine Bash is running on.
7201</p>
7202</dd>
7203<dt><code>IGNOREEOF</code>
7204<a name="index-IGNOREEOF"></a>
7205</dt>
7206<dd><p>Controls the action of the shell on receipt of an <code>EOF</code> character
17345e5a 7207as the sole input. If set, the value denotes the number
a0c0a00f 7208of consecutive <code>EOF</code> characters that can be read as the
17345e5a
JA
7209first character on an input line
7210before the shell will exit. If the variable exists but does not
2f5dfe5a 7211have a numeric value, or has no value, then the default is 10.
a0c0a00f 7212If the variable does not exist, then <code>EOF</code> signifies the end of
17345e5a 7213input to the shell. This is only in effect for interactive shells.
a0c0a00f
CR
7214</p>
7215</dd>
7216<dt><code>INPUTRC</code>
7217<a name="index-INPUTRC"></a>
7218</dt>
7219<dd><p>The name of the Readline initialization file, overriding the default
7220of <samp>~/.inputrc</samp>.
7221</p>
7222</dd>
2f5dfe5a
CR
7223<dt><code>INSIDE_EMACS</code>
7224<a name="index-INSIDE_005fEMACS"></a>
7225</dt>
7226<dd><p>If Bash finds this variable in the environment when the shell
7227starts, it assumes that the shell is running in an Emacs shell buffer
7228and may disable line editing depending on the value of <code>TERM</code>.
7229</p>
7230</dd>
a0c0a00f
CR
7231<dt><code>LANG</code>
7232<a name="index-LANG"></a>
7233</dt>
7234<dd><p>Used to determine the locale category for any category not specifically
7235selected with a variable starting with <code>LC_</code>.
7236</p>
7237</dd>
7238<dt><code>LC_ALL</code>
7239<a name="index-LC_005fALL"></a>
7240</dt>
7241<dd><p>This variable overrides the value of <code>LANG</code> and any other
7242<code>LC_</code> variable specifying a locale category.
7243</p>
7244</dd>
7245<dt><code>LC_COLLATE</code>
7246<a name="index-LC_005fCOLLATE"></a>
7247</dt>
7248<dd><p>This variable determines the collation order used when sorting the
17345e5a
JA
7249results of filename expansion, and
7250determines the behavior of range expressions, equivalence classes,
7251and collating sequences within filename expansion and pattern matching
a0c0a00f
CR
7252(see <a href="#Filename-Expansion">Filename Expansion</a>).
7253</p>
7254</dd>
7255<dt><code>LC_CTYPE</code>
7256<a name="index-LC_005fCTYPE"></a>
7257</dt>
7258<dd><p>This variable determines the interpretation of characters and the
17345e5a 7259behavior of character classes within filename expansion and pattern
a0c0a00f
CR
7260matching (see <a href="#Filename-Expansion">Filename Expansion</a>).
7261</p>
7262</dd>
7263<dt><code>LC_MESSAGES</code>
7264<a name="index-LC_005fMESSAGES-1"></a>
7265</dt>
7266<dd><p>This variable determines the locale used to translate double-quoted
7267strings preceded by a &lsquo;<samp>$</samp>&rsquo; (see <a href="#Locale-Translation">Locale Translation</a>).
7268</p>
7269</dd>
7270<dt><code>LC_NUMERIC</code>
7271<a name="index-LC_005fNUMERIC"></a>
7272</dt>
7273<dd><p>This variable determines the locale category used for number formatting.
7274</p>
7275</dd>
7276<dt><code>LC_TIME</code>
7277<a name="index-LC_005fTIME"></a>
7278</dt>
7279<dd><p>This variable determines the locale category used for data and time
7280formatting.
7281</p>
7282</dd>
7283<dt><code>LINENO</code>
7284<a name="index-LINENO"></a>
7285</dt>
7286<dd><p>The line number in the script or shell function currently executing.
7287</p>
7288</dd>
7289<dt><code>LINES</code>
7290<a name="index-LINES"></a>
7291</dt>
7292<dd><p>Used by the <code>select</code> command to determine the column length
ac50fbac 7293for printing selection lists.
a0c0a00f
CR
7294Automatically set if the <code>checkwinsize</code> option is enabled
7295(see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), or in an interactive shell upon receipt of a
7296<code>SIGWINCH</code>.
7297</p>
7298</dd>
7299<dt><code>MACHTYPE</code>
7300<a name="index-MACHTYPE"></a>
7301</dt>
7302<dd><p>A string that fully describes the system type on which Bash
7303is executing, in the standard <small>GNU</small> <var>cpu-company-system</var> format.
7304</p>
7305</dd>
7306<dt><code>MAILCHECK</code>
7307<a name="index-MAILCHECK"></a>
7308</dt>
7309<dd><p>How often (in seconds) that the shell should check for mail in the
7310files specified in the <code>MAILPATH</code> or <code>MAIL</code> variables.
17345e5a
JA
7311The default is 60 seconds. When it is time to check
7312for mail, the shell does so before displaying the primary prompt.
7313If this variable is unset, or set to a value that is not a number
7314greater than or equal to zero, the shell disables mail checking.
a0c0a00f
CR
7315</p>
7316</dd>
7317<dt><code>MAPFILE</code>
7318<a name="index-MAPFILE"></a>
7319</dt>
7320<dd><p>An array variable created to hold the text read by the
7321<code>mapfile</code> builtin when no variable name is supplied.
7322</p>
7323</dd>
7324<dt><code>OLDPWD</code>
7325<a name="index-OLDPWD"></a>
7326</dt>
7327<dd><p>The previous working directory as set by the <code>cd</code> builtin.
7328</p>
7329</dd>
7330<dt><code>OPTERR</code>
7331<a name="index-OPTERR"></a>
7332</dt>
7333<dd><p>If set to the value 1, Bash displays error messages
7334generated by the <code>getopts</code> builtin command.
7335</p>
7336</dd>
7337<dt><code>OSTYPE</code>
7338<a name="index-OSTYPE"></a>
7339</dt>
7340<dd><p>A string describing the operating system Bash is running on.
7341</p>
7342</dd>
7343<dt><code>PIPESTATUS</code>
7344<a name="index-PIPESTATUS"></a>
7345</dt>
7346<dd><p>An array variable (see <a href="#Arrays">Arrays</a>)
17345e5a
JA
7347containing a list of exit status values from the processes
7348in the most-recently-executed foreground pipeline (which may
7349contain only a single command).
a0c0a00f
CR
7350</p>
7351</dd>
7352<dt><code>POSIXLY_CORRECT</code>
7353<a name="index-POSIXLY_005fCORRECT"></a>
7354</dt>
7355<dd><p>If this variable is in the environment when Bash starts, the shell
7356enters <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>) before reading the
7357startup files, as if the <samp>--posix</samp> invocation option had been supplied.
7358If it is set while the shell is running, Bash enables <small>POSIX</small> mode,
17345e5a 7359as if the command
a0c0a00f
CR
7360</p><div class="example">
7361<pre class="example"><code>set -o posix</code>
7362</pre></div>
2f5dfe5a
CR
7363<p>had been executed.
7364When the shell enters <small>POSIX</small> mode, it sets this variable if it was
7365not already set.
a0c0a00f
CR
7366</p>
7367</dd>
7368<dt><code>PPID</code>
7369<a name="index-PPID"></a>
7370</dt>
7371<dd><p>The process <small>ID</small> of the shell&rsquo;s parent process. This variable
17345e5a 7372is readonly.
a0c0a00f
CR
7373</p>
7374</dd>
7375<dt><code>PROMPT_COMMAND</code>
7376<a name="index-PROMPT_005fCOMMAND"></a>
7377</dt>
7378<dd><p>If set, the value is interpreted as a command to execute
7379before the printing of each primary prompt (<code>$PS1</code>).
7380</p>
7381</dd>
7382<dt><code>PROMPT_DIRTRIM</code>
7383<a name="index-PROMPT_005fDIRTRIM"></a>
7384</dt>
7385<dd><p>If set to a number greater than zero, the value is used as the number of
7386trailing directory components to retain when expanding the <code>\w</code> and
7387<code>\W</code> prompt string escapes (see <a href="#Controlling-the-Prompt">Controlling the Prompt</a>).
17345e5a 7388Characters removed are replaced with an ellipsis.
a0c0a00f
CR
7389</p>
7390</dd>
7391<dt><code>PS0</code>
7392<a name="index-PS0"></a>
7393</dt>
7394<dd><p>The value of this parameter is expanded like <var>PS1</var>
7395and displayed by interactive shells after reading a command
7396and before the command is executed.
7397</p>
7398</dd>
7399<dt><code>PS3</code>
7400<a name="index-PS3"></a>
7401</dt>
7402<dd><p>The value of this variable is used as the prompt for the
7403<code>select</code> command. If this variable is not set, the
7404<code>select</code> command prompts with &lsquo;<samp>#? </samp>&rsquo;
7405</p>
7406</dd>
7407<dt><code>PS4</code>
7408<a name="index-PS4"></a>
7409</dt>
9a51695b
CR
7410<dd><p>The value of this parameter is expanded like <var>PS1</var>
7411and the expanded value is the prompt printed before the command line
7412is echoed when the <samp>-x</samp> option is set (see <a href="#The-Set-Builtin">The Set Builtin</a>).
7413The first character of the expanded value is replicated multiple times,
7414as necessary, to indicate multiple levels of indirection.
a0c0a00f
CR
7415The default is &lsquo;<samp>+ </samp>&rsquo;.
7416</p>
7417</dd>
7418<dt><code>PWD</code>
7419<a name="index-PWD"></a>
7420</dt>
7421<dd><p>The current working directory as set by the <code>cd</code> builtin.
7422</p>
7423</dd>
7424<dt><code>RANDOM</code>
7425<a name="index-RANDOM"></a>
7426</dt>
7427<dd><p>Each time this parameter is referenced, a random integer
17345e5a
JA
7428between 0 and 32767 is generated. Assigning a value to this
7429variable seeds the random number generator.
a0c0a00f
CR
7430</p>
7431</dd>
7432<dt><code>READLINE_LINE</code>
7433<a name="index-READLINE_005fLINE"></a>
7434</dt>
7435<dd><p>The contents of the Readline line buffer, for use
7436with &lsquo;<samp>bind -x</samp>&rsquo; (see <a href="#Bash-Builtins">Bash Builtins</a>).
7437</p>
7438</dd>
7439<dt><code>READLINE_POINT</code>
7440<a name="index-READLINE_005fPOINT"></a>
7441</dt>
7442<dd><p>The position of the insertion point in the Readline line buffer, for use
7443with &lsquo;<samp>bind -x</samp>&rsquo; (see <a href="#Bash-Builtins">Bash Builtins</a>).
7444</p>
7445</dd>
7446<dt><code>REPLY</code>
7447<a name="index-REPLY"></a>
7448</dt>
7449<dd><p>The default variable for the <code>read</code> builtin.
7450</p>
7451</dd>
7452<dt><code>SECONDS</code>
7453<a name="index-SECONDS"></a>
7454</dt>
7455<dd><p>This variable expands to the number of seconds since the
17345e5a
JA
7456shell was started. Assignment to this variable resets
7457the count to the value assigned, and the expanded value
7458becomes the value assigned plus the number of seconds
7459since the assignment.
a0c0a00f
CR
7460</p>
7461</dd>
7462<dt><code>SHELL</code>
7463<a name="index-SHELL"></a>
7464</dt>
7465<dd><p>The full pathname to the shell is kept in this environment variable.
17345e5a 7466If it is not set when the shell starts,
a0c0a00f
CR
7467Bash assigns to it the full pathname of the current user&rsquo;s login shell.
7468</p>
7469</dd>
7470<dt><code>SHELLOPTS</code>
7471<a name="index-SHELLOPTS"></a>
7472</dt>
7473<dd><p>A colon-separated list of enabled shell options. Each word in
7474the list is a valid argument for the <samp>-o</samp> option to the
7475<code>set</code> builtin command (see <a href="#The-Set-Builtin">The Set Builtin</a>).
7476The options appearing in <code>SHELLOPTS</code> are those reported
7477as &lsquo;<samp>on</samp>&rsquo; by &lsquo;<samp>set -o</samp>&rsquo;.
17345e5a
JA
7478If this variable is in the environment when Bash
7479starts up, each shell option in the list will be enabled before
7480reading any startup files. This variable is readonly.
a0c0a00f
CR
7481</p>
7482</dd>
7483<dt><code>SHLVL</code>
7484<a name="index-SHLVL"></a>
7485</dt>
7486<dd><p>Incremented by one each time a new instance of Bash is started. This is
17345e5a 7487intended to be a count of how deeply your Bash shells are nested.
a0c0a00f
CR
7488</p>
7489</dd>
7490<dt><code>TIMEFORMAT</code>
7491<a name="index-TIMEFORMAT"></a>
7492</dt>
7493<dd><p>The value of this parameter is used as a format string specifying
7494how the timing information for pipelines prefixed with the <code>time</code>
17345e5a 7495reserved word should be displayed.
a0c0a00f 7496The &lsquo;<samp>%</samp>&rsquo; character introduces an
17345e5a
JA
7497escape sequence that is expanded to a time value or other
7498information.
7499The escape sequences and their meanings are as
7500follows; the braces denote optional portions.
a0c0a00f
CR
7501</p>
7502<dl compact="compact">
7503<dt><code>%%</code></dt>
7504<dd><p>A literal &lsquo;<samp>%</samp>&rsquo;.
7505</p>
7506</dd>
7507<dt><code>%[<var>p</var>][l]R</code></dt>
7508<dd><p>The elapsed time in seconds.
7509</p>
7510</dd>
7511<dt><code>%[<var>p</var>][l]U</code></dt>
7512<dd><p>The number of CPU seconds spent in user mode.
7513</p>
7514</dd>
7515<dt><code>%[<var>p</var>][l]S</code></dt>
7516<dd><p>The number of CPU seconds spent in system mode.
7517</p>
7518</dd>
7519<dt><code>%P</code></dt>
7520<dd><p>The CPU percentage, computed as (%U + %S) / %R.
7521</p></dd>
7522</dl>
7523
7524<p>The optional <var>p</var> is a digit specifying the precision, the number of
17345e5a
JA
7525fractional digits after a decimal point.
7526A value of 0 causes no decimal point or fraction to be output.
7527At most three places after the decimal point may be specified; values
a0c0a00f
CR
7528of <var>p</var> greater than 3 are changed to 3.
7529If <var>p</var> is not specified, the value 3 is used.
7530</p>
7531<p>The optional <code>l</code> specifies a longer format, including minutes, of
7532the form <var>MM</var>m<var>SS</var>.<var>FF</var>s.
7533The value of <var>p</var> determines whether or not the fraction is included.
7534</p>
7535<p>If this variable is not set, Bash acts as if it had the value
7536</p><div class="example">
7537<pre class="example"><code>$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS'</code>
7538</pre></div>
7539<p>If the value is null, no timing information is displayed.
17345e5a 7540A trailing newline is added when the format string is displayed.
a0c0a00f
CR
7541</p>
7542</dd>
7543<dt><code>TMOUT</code>
7544<a name="index-TMOUT"></a>
7545</dt>
7546<dd><p>If set to a value greater than zero, <code>TMOUT</code> is treated as the
7547default timeout for the <code>read</code> builtin (see <a href="#Bash-Builtins">Bash Builtins</a>).
7548The <code>select</code> command (see <a href="#Conditional-Constructs">Conditional Constructs</a>) terminates
7549if input does not arrive after <code>TMOUT</code> seconds when input is coming
17345e5a 7550from a terminal.
a0c0a00f
CR
7551</p>
7552<p>In an interactive shell, the value is interpreted as
ac50fbac
CR
7553the number of seconds to wait for a line of input after issuing
7554the primary prompt.
7555Bash
7556terminates after waiting for that number of seconds if a complete
7557line of input does not arrive.
a0c0a00f
CR
7558</p>
7559</dd>
7560<dt><code>TMPDIR</code>
7561<a name="index-TMPDIR"></a>
7562</dt>
7563<dd><p>If set, Bash uses its value as the name of a directory in which
7564Bash creates temporary files for the shell&rsquo;s use.
7565</p>
7566</dd>
7567<dt><code>UID</code>
7568<a name="index-UID"></a>
7569</dt>
7570<dd><p>The numeric real user id of the current user. This variable is readonly.
7571</p>
7572</dd>
7573</dl>
7574
7575<hr>
7576<a name="Bash-Features"></a>
7577<div class="header">
7578<p>
7579Next: <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>
7580</div>
7581<a name="Bash-Features-2"></a>
7582<h2 class="chapter">6 Bash Features</h2>
7583
7584<p>This chapter describes features unique to Bash.
7585</p>
7586<table class="menu" border="0" cellspacing="0">
7587<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
7588 to Bash.
7589</td></tr>
7590<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.
7591</td></tr>
7592<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.
7593</td></tr>
7594<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
7595 the <code>test</code> builtin.
7596</td></tr>
7597<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.
7598</td></tr>
7599<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.
7600</td></tr>
7601<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.
7602</td></tr>
7603<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.
7604</td></tr>
7605<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.
7606</td></tr>
7607<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.
7608</td></tr>
7609<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
7610 the POSIX standard specifies.
7611</td></tr>
7612</table>
7613
7614<hr>
7615<a name="Invoking-Bash"></a>
7616<div class="header">
7617<p>
7618Next: <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>
7619</div>
7620<a name="Invoking-Bash-1"></a>
7621<h3 class="section">6.1 Invoking Bash</h3>
7622
7623<div class="example">
2f5dfe5a
CR
7624<pre class="example">bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o <var>option</var>]
7625 [-O <var>shopt_option</var>] [<var>argument</var> &hellip;]
7626bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o <var>option</var>]
7627 [-O <var>shopt_option</var>] -c <var>string</var> [<var>argument</var> &hellip;]
7628bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o <var>option</var>]
7629 [-O <var>shopt_option</var>] [<var>argument</var> &hellip;]
a0c0a00f
CR
7630</pre></div>
7631
7632<p>All of the single-character options used with the <code>set</code> builtin
7633(see <a href="#The-Set-Builtin">The Set Builtin</a>) can be used as options when the shell is invoked.
495aee44 7634In addition, there are several multi-character
17345e5a
JA
7635options that you can use. These options must appear on the command
7636line before the single-character options to be recognized.
a0c0a00f
CR
7637</p>
7638<dl compact="compact">
7639<dt><code>--debugger</code></dt>
7640<dd><p>Arrange for the debugger profile to be executed before the shell
7641starts. Turns on extended debugging mode (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>
7642for a description of the <code>extdebug</code> option to the <code>shopt</code>
495aee44 7643builtin).
a0c0a00f
CR
7644</p>
7645</dd>
7646<dt><code>--dump-po-strings</code></dt>
7647<dd><p>A list of all double-quoted strings preceded by &lsquo;<samp>$</samp>&rsquo;
17345e5a 7648is printed on the standard output
a0c0a00f
CR
7649in the <small>GNU</small> <code>gettext</code> PO (portable object) file format.
7650Equivalent to <samp>-D</samp> except for the output format.
7651</p>
7652</dd>
7653<dt><code>--dump-strings</code></dt>
7654<dd><p>Equivalent to <samp>-D</samp>.
7655</p>
7656</dd>
7657<dt><code>--help</code></dt>
7658<dd><p>Display a usage message on standard output and exit successfully.
7659</p>
7660</dd>
7661<dt><code>--init-file <var>filename</var></code></dt>
7662<dt><code>--rcfile <var>filename</var></code></dt>
7663<dd><p>Execute commands from <var>filename</var> (instead of <samp>~/.bashrc</samp>)
17345e5a 7664in an interactive shell.
a0c0a00f
CR
7665</p>
7666</dd>
7667<dt><code>--login</code></dt>
7668<dd><p>Equivalent to <samp>-l</samp>.
7669</p>
7670</dd>
7671<dt><code>--noediting</code></dt>
7672<dd><p>Do not use the <small>GNU</small> Readline library (see <a href="#Command-Line-Editing">Command Line Editing</a>)
17345e5a 7673to read command lines when the shell is interactive.
a0c0a00f
CR
7674</p>
7675</dd>
7676<dt><code>--noprofile</code></dt>
7677<dd><p>Don&rsquo;t load the system-wide startup file <samp>/etc/profile</samp>
17345e5a 7678or any of the personal initialization files
a0c0a00f 7679<samp>~/.bash_profile</samp>, <samp>~/.bash_login</samp>, or <samp>~/.profile</samp>
17345e5a 7680when Bash is invoked as a login shell.
a0c0a00f
CR
7681</p>
7682</dd>
7683<dt><code>--norc</code></dt>
7684<dd><p>Don&rsquo;t read the <samp>~/.bashrc</samp> initialization file in an
17345e5a 7685interactive shell. This is on by default if the shell is
a0c0a00f
CR
7686invoked as <code>sh</code>.
7687</p>
7688</dd>
7689<dt><code>--posix</code></dt>
7690<dd><p>Change the behavior of Bash where the default operation differs
7691from the <small>POSIX</small> standard to match the standard. This
17345e5a 7692is intended to make Bash behave as a strict superset of that
a0c0a00f
CR
7693standard. See <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>, for a description of the Bash
7694<small>POSIX</small> mode.
7695</p>
7696</dd>
7697<dt><code>--restricted</code></dt>
7698<dd><p>Make the shell a restricted shell (see <a href="#The-Restricted-Shell">The Restricted Shell</a>).
7699</p>
7700</dd>
7701<dt><code>--verbose</code></dt>
7702<dd><p>Equivalent to <samp>-v</samp>. Print shell input lines as they&rsquo;re read.
7703</p>
7704</dd>
7705<dt><code>--version</code></dt>
7706<dd><p>Show version information for this instance of
17345e5a 7707Bash on the standard output and exit successfully.
a0c0a00f
CR
7708</p></dd>
7709</dl>
7710
7711<p>There are several single-character options that may be supplied at
7712invocation which are not available with the <code>set</code> builtin.
7713</p>
7714<dl compact="compact">
7715<dt><code>-c</code></dt>
7716<dd><p>Read and execute commands from the first non-option argument
7717<var>command_string</var>, then exit.
7718If there are arguments after the <var>command_string</var>,
7719the first argument is assigned to <code>$0</code>
7720and any remaining arguments are assigned to the positional parameters.
7721The assignment to <code>$0</code> sets the name of the shell, which is used
7722in warning and error messages.
7723</p>
7724</dd>
7725<dt><code>-i</code></dt>
7726<dd><p>Force the shell to run interactively. Interactive shells are
7727described in <a href="#Interactive-Shells">Interactive Shells</a>.
7728</p>
7729</dd>
7730<dt><code>-l</code></dt>
7731<dd><p>Make this shell act as if it had been directly invoked by login.
17345e5a 7732When the shell is interactive, this is equivalent to starting a
a0c0a00f 7733login shell with &lsquo;<samp>exec -l bash</samp>&rsquo;.
17345e5a
JA
7734When the shell is not interactive, the login shell startup files will
7735be executed.
a0c0a00f 7736&lsquo;<samp>exec bash -l</samp>&rsquo; or &lsquo;<samp>exec bash --login</samp>&rsquo;
17345e5a 7737will replace the current shell with a Bash login shell.
a0c0a00f 7738See <a href="#Bash-Startup-Files">Bash Startup Files</a>, for a description of the special behavior
17345e5a 7739of a login shell.
a0c0a00f
CR
7740</p>
7741</dd>
7742<dt><code>-r</code></dt>
7743<dd><p>Make the shell a restricted shell (see <a href="#The-Restricted-Shell">The Restricted Shell</a>).
7744</p>
7745</dd>
7746<dt><code>-s</code></dt>
7747<dd><p>If this option is present, or if no arguments remain after option
17345e5a
JA
7748processing, then commands are read from the standard input.
7749This option allows the positional parameters to be set
9a51695b
CR
7750when invoking an interactive shell or when reading input
7751through a pipe.
a0c0a00f
CR
7752</p>
7753</dd>
7754<dt><code>-D</code></dt>
7755<dd><p>A list of all double-quoted strings preceded by &lsquo;<samp>$</samp>&rsquo;
17345e5a
JA
7756is printed on the standard output.
7757These are the strings that
7758are subject to language translation when the current locale
a0c0a00f
CR
7759is not <code>C</code> or <code>POSIX</code> (see <a href="#Locale-Translation">Locale Translation</a>).
7760This implies the <samp>-n</samp> option; no commands will be executed.
7761</p>
7762</dd>
7763<dt><code>[-+]O [<var>shopt_option</var>]</code></dt>
7764<dd><p><var>shopt_option</var> is one of the shell options accepted by the
7765<code>shopt</code> builtin (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>).
7766If <var>shopt_option</var> is present, <samp>-O</samp> sets the value of that option;
7767<samp>+O</samp> unsets it.
7768If <var>shopt_option</var> is not supplied, the names and values of the shell
7769options accepted by <code>shopt</code> are printed on the standard output.
7770If the invocation option is <samp>+O</samp>, the output is displayed in a format
17345e5a 7771that may be reused as input.
a0c0a00f
CR
7772</p>
7773</dd>
7774<dt><code>--</code></dt>
7775<dd><p>A <code>--</code> signals the end of options and disables further option
17345e5a 7776processing.
a0c0a00f
CR
7777Any arguments after the <code>--</code> are treated as filenames and arguments.
7778</p></dd>
7779</dl>
7780
7781<a name="index-login-shell"></a>
7782<p>A <em>login</em> shell is one whose first character of argument zero is
7783&lsquo;<samp>-</samp>&rsquo;, or one invoked with the <samp>--login</samp> option.
7784</p>
7785<a name="index-interactive-shell"></a>
7786<p>An <em>interactive</em> shell is one started without non-option arguments,
7787unless <samp>-s</samp> is specified,
7788without specifying the <samp>-c</samp> option, and whose input and output are both
7789connected to terminals (as determined by <code>isatty(3)</code>), or one
7790started with the <samp>-i</samp> option. See <a href="#Interactive-Shells">Interactive Shells</a>, for more
17345e5a 7791information.
a0c0a00f
CR
7792</p>
7793<p>If arguments remain after option processing, and neither the
7794<samp>-c</samp> nor the <samp>-s</samp>
17345e5a 7795option has been supplied, the first argument is assumed to
a0c0a00f
CR
7796be the name of a file containing shell commands (see <a href="#Shell-Scripts">Shell Scripts</a>).
7797When Bash is invoked in this fashion, <code>$0</code>
17345e5a
JA
7798is set to the name of the file, and the positional parameters
7799are set to the remaining arguments.
7800Bash reads and executes commands from this file, then exits.
a0c0a00f 7801Bash&rsquo;s exit status is the exit status of the last command executed
17345e5a 7802in the script. If no commands are executed, the exit status is 0.
a0c0a00f
CR
7803</p>
7804<hr>
7805<a name="Bash-Startup-Files"></a>
7806<div class="header">
7807<p>
7808Next: <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>
7809</div>
7810<a name="Bash-Startup-Files-1"></a>
7811<h3 class="section">6.2 Bash Startup Files</h3>
7812<a name="index-startup-files"></a>
7813
7814<p>This section describes how Bash executes its startup files.
17345e5a 7815If any of the files exist but cannot be read, Bash reports an error.
ac50fbac 7816Tildes are expanded in filenames as described above under
a0c0a00f
CR
7817Tilde Expansion (see <a href="#Tilde-Expansion">Tilde Expansion</a>).
7818</p>
7819<p>Interactive shells are described in <a href="#Interactive-Shells">Interactive Shells</a>.
7820</p>
7821<a name="Invoked-as-an-interactive-login-shell_002c-or-with-_002d_002dlogin"></a>
7822<h4 class="subsubheading">Invoked as an interactive login shell, or with <samp>--login</samp></h4>
7823
7824<p>When Bash is invoked as an interactive login shell, or as a
7825non-interactive shell with the <samp>--login</samp> option, it first reads and
7826executes commands from the file <samp>/etc/profile</samp>, if that file exists.
7827After reading that file, it looks for <samp>~/.bash_profile</samp>,
7828<samp>~/.bash_login</samp>, and <samp>~/.profile</samp>, in that order, and reads
17345e5a 7829and executes commands from the first one that exists and is readable.
a0c0a00f 7830The <samp>--noprofile</samp> option may be used when the shell is started to
17345e5a 7831inhibit this behavior.
a0c0a00f
CR
7832</p>
7833<p>When an interactive login shell exits,
7834or a non-interactive login shell executes the <code>exit</code> builtin command,
7835Bash reads and executes commands from
7836the file <samp>~/.bash_logout</samp>, if it exists.
7837</p>
7838<a name="Invoked-as-an-interactive-non_002dlogin-shell"></a>
7839<h4 class="subsubheading">Invoked as an interactive non-login shell</h4>
7840
7841<p>When an interactive shell that is not a login shell is started, Bash
7842reads and executes commands from <samp>~/.bashrc</samp>, if that file exists.
7843This may be inhibited by using the <samp>--norc</samp> option.
7844The <samp>--rcfile <var>file</var></samp> option will force Bash to read and
7845execute commands from <var>file</var> instead of <samp>~/.bashrc</samp>.
7846</p>
7847<p>So, typically, your <samp>~/.bash_profile</samp> contains the line
7848</p><div class="example">
7849<pre class="example"><code>if [ -f ~/.bashrc ]; then . ~/.bashrc; fi</code>
7850</pre></div>
7851<p>after (or before) any login-specific initializations.
7852</p>
7853<a name="Invoked-non_002dinteractively"></a>
7854<h4 class="subsubheading">Invoked non-interactively</h4>
7855
7856<p>When Bash is started non-interactively, to run a shell script,
7857for example, it looks for the variable <code>BASH_ENV</code> in the environment,
17345e5a
JA
7858expands its value if it appears there, and uses the expanded value as
7859the name of a file to read and execute. Bash behaves as if the
7860following command were executed:
a0c0a00f
CR
7861</p><div class="example">
7862<pre class="example"><code>if [ -n &quot;$BASH_ENV&quot; ]; then . &quot;$BASH_ENV&quot;; fi</code>
7863</pre></div>
7864<p>but the value of the <code>PATH</code> variable is not used to search for the
ac50fbac 7865filename.
a0c0a00f
CR
7866</p>
7867<p>As noted above, if a non-interactive shell is invoked with the
7868<samp>--login</samp> option, Bash attempts to read and execute commands from the
17345e5a 7869login shell startup files.
a0c0a00f
CR
7870</p>
7871<a name="Invoked-with-name-sh"></a>
7872<h4 class="subsubheading">Invoked with name <code>sh</code></h4>
7873
7874<p>If Bash is invoked with the name <code>sh</code>, it tries to mimic the
7875startup behavior of historical versions of <code>sh</code> as closely as
7876possible, while conforming to the <small>POSIX</small> standard as well.
7877</p>
7878<p>When invoked as an interactive login shell, or as a non-interactive
7879shell with the <samp>--login</samp> option, it first attempts to read
7880and execute commands from <samp>/etc/profile</samp> and <samp>~/.profile</samp>, in
17345e5a 7881that order.
a0c0a00f
CR
7882The <samp>--noprofile</samp> option may be used to inhibit this behavior.
7883When invoked as an interactive shell with the name <code>sh</code>, Bash
7884looks for the variable <code>ENV</code>, expands its value if it is defined,
17345e5a 7885and uses the expanded value as the name of a file to read and execute.
a0c0a00f
CR
7886Since a shell invoked as <code>sh</code> does not attempt to read and execute
7887commands from any other startup files, the <samp>--rcfile</samp> option has
17345e5a 7888no effect.
a0c0a00f 7889A non-interactive shell invoked with the name <code>sh</code> does not attempt
17345e5a 7890to read any other startup files.
a0c0a00f
CR
7891</p>
7892<p>When invoked as <code>sh</code>, Bash enters <small>POSIX</small> mode after
17345e5a 7893the startup files are read.
a0c0a00f
CR
7894</p>
7895<a name="Invoked-in-POSIX-mode"></a>
7896<h4 class="subsubheading">Invoked in <small>POSIX</small> mode</h4>
17345e5a 7897
a0c0a00f
CR
7898<p>When Bash is started in <small>POSIX</small> mode, as with the
7899<samp>--posix</samp> command line option, it follows the <small>POSIX</small> standard
17345e5a 7900for startup files.
a0c0a00f 7901In this mode, interactive shells expand the <code>ENV</code> variable
17345e5a
JA
7902and commands are read and executed from the file whose name is the
7903expanded value.
7904No other startup files are read.
a0c0a00f
CR
7905</p>
7906<a name="Invoked-by-remote-shell-daemon"></a>
7907<h4 class="subsubheading">Invoked by remote shell daemon</h4>
17345e5a 7908
a0c0a00f 7909<p>Bash attempts to determine when it is being run with its standard input
495aee44 7910connected to a network connection, as when executed by the remote shell
a0c0a00f 7911daemon, usually <code>rshd</code>, or the secure shell daemon <code>sshd</code>.
17345e5a 7912If Bash determines it is being run in
a0c0a00f 7913this fashion, it reads and executes commands from <samp>~/.bashrc</samp>, if that
17345e5a 7914file exists and is readable.
a0c0a00f
CR
7915It will not do this if invoked as <code>sh</code>.
7916The <samp>--norc</samp> option may be used to inhibit this behavior, and the
7917<samp>--rcfile</samp> option may be used to force another file to be read, but
7918neither <code>rshd</code> nor <code>sshd</code> generally invoke the shell with those
ac50fbac 7919options or allow them to be specified.
a0c0a00f
CR
7920</p>
7921<a name="Invoked-with-unequal-effective-and-real-UID_002fGIDs"></a>
7922<h4 class="subsubheading">Invoked with unequal effective and real <small>UID/GID</small>s</h4>
17345e5a 7923
a0c0a00f
CR
7924<p>If Bash is started with the effective user (group) id not equal to the
7925real user (group) id, and the <samp>-p</samp> option is not supplied, no startup
17345e5a 7926files are read, shell functions are not inherited from the environment,
a0c0a00f 7927the <code>SHELLOPTS</code>, <code>BASHOPTS</code>, <code>CDPATH</code>, and <code>GLOBIGNORE</code>
0001803f
CR
7928variables, if they appear in the environment, are ignored, and the effective
7929user id is set to the real user id.
a0c0a00f 7930If the <samp>-p</samp> option is supplied at invocation, the startup behavior is
17345e5a 7931the same, but the effective user id is not reset.
a0c0a00f
CR
7932</p>
7933<hr>
7934<a name="Interactive-Shells"></a>
7935<div class="header">
7936<p>
7937Next: <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>
7938</div>
7939<a name="Interactive-Shells-1"></a>
7940<h3 class="section">6.3 Interactive Shells</h3>
7941<a name="index-interactive-shell-1"></a>
7942<a name="index-shell_002c-interactive"></a>
7943
7944<table class="menu" border="0" cellspacing="0">
7945<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.
7946</td></tr>
7947<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.
7948</td></tr>
7949<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?
7950</td></tr>
7951</table>
7952
7953<hr>
7954<a name="What-is-an-Interactive-Shell_003f"></a>
7955<div class="header">
7956<p>
7957Next: <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>
7958</div>
7959<a name="What-is-an-Interactive-Shell_003f-1"></a>
7960<h4 class="subsection">6.3.1 What is an Interactive Shell?</h4>
7961
7962<p>An interactive shell
7963is one started without non-option arguments, unless <samp>-s</samp> is
7964specified, without specifying the <samp>-c</samp> option, and
17345e5a 7965whose input and error output are both
a0c0a00f
CR
7966connected to terminals (as determined by <code>isatty(3)</code>),
7967or one started with the <samp>-i</samp> option.
7968</p>
7969<p>An interactive shell generally reads from and writes to a user&rsquo;s
17345e5a 7970terminal.
a0c0a00f
CR
7971</p>
7972<p>The <samp>-s</samp> invocation option may be used to set the positional parameters
17345e5a 7973when an interactive shell is started.
a0c0a00f
CR
7974</p>
7975<hr>
7976<a name="Is-this-Shell-Interactive_003f"></a>
7977<div class="header">
7978<p>
7979Next: <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>
7980</div>
7981<a name="Is-this-Shell-Interactive_003f-1"></a>
7982<h4 class="subsection">6.3.2 Is this Shell Interactive?</h4>
7983
7984<p>To determine within a startup script whether or not Bash is
17345e5a 7985running interactively,
a0c0a00f
CR
7986test the value of the &lsquo;<samp>-</samp>&rsquo; special parameter.
7987It contains <code>i</code> when the shell is interactive. For example:
7988</p>
7989<div class="example">
7990<pre class="example">case &quot;$-&quot; in
17345e5a
JA
7991*i*) echo This shell is interactive ;;
7992*) echo This shell is not interactive ;;
7993esac
a0c0a00f 7994</pre></div>
17345e5a 7995
a0c0a00f
CR
7996<p>Alternatively, startup scripts may examine the variable
7997<code>PS1</code>; it is unset in non-interactive shells, and set in
17345e5a 7998interactive shells. Thus:
a0c0a00f
CR
7999</p>
8000<div class="example">
8001<pre class="example">if [ -z &quot;$PS1&quot; ]; then
17345e5a
JA
8002 echo This shell is not interactive
8003else
8004 echo This shell is interactive
8005fi
a0c0a00f
CR
8006</pre></div>
8007
8008<hr>
8009<a name="Interactive-Shell-Behavior"></a>
8010<div class="header">
8011<p>
8012Previous: <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>
8013</div>
8014<a name="Interactive-Shell-Behavior-1"></a>
8015<h4 class="subsection">6.3.3 Interactive Shell Behavior</h4>
8016
8017<p>When the shell is running interactively, it changes its behavior in
17345e5a 8018several ways.
a0c0a00f
CR
8019</p>
8020<ol>
8021<li> Startup files are read and executed as described in <a href="#Bash-Startup-Files">Bash Startup Files</a>.
17345e5a 8022
a0c0a00f 8023</li><li> Job Control (see <a href="#Job-Control">Job Control</a>) is enabled by default. When job
17345e5a 8024control is in effect, Bash ignores the keyboard-generated job control
a0c0a00f 8025signals <code>SIGTTIN</code>, <code>SIGTTOU</code>, and <code>SIGTSTP</code>.
17345e5a 8026
a0c0a00f
CR
8027</li><li> Bash expands and displays <code>PS1</code> before reading the first line
8028of a command, and expands and displays <code>PS2</code> before reading the
17345e5a 8029second and subsequent lines of a multi-line command.
9a51695b
CR
8030Bash expands and displays <code>PS0</code> after it reads a command but before
8031executing it.
8032See <a href="#Controlling-the-Prompt">Controlling the Prompt</a>, for a complete list of prompt
8033string escape sequences.
17345e5a 8034
a0c0a00f
CR
8035</li><li> Bash executes the value of the <code>PROMPT_COMMAND</code> variable as a command
8036before printing the primary prompt, <code>$PS1</code>
8037(see <a href="#Bash-Variables">Bash Variables</a>).
17345e5a 8038
a0c0a00f
CR
8039</li><li> Readline (see <a href="#Command-Line-Editing">Command Line Editing</a>) is used to read commands from
8040the user&rsquo;s terminal.
17345e5a 8041
a0c0a00f
CR
8042</li><li> Bash inspects the value of the <code>ignoreeof</code> option to <code>set -o</code>
8043instead of exiting immediately when it receives an <code>EOF</code> on its
8044standard input when reading a command (see <a href="#The-Set-Builtin">The Set Builtin</a>).
17345e5a 8045
a0c0a00f
CR
8046</li><li> Command history (see <a href="#Bash-History-Facilities">Bash History Facilities</a>)
8047and history expansion (see <a href="#History-Interaction">History Interaction</a>)
8048are enabled by default.
8049Bash will save the command history to the file named by <code>$HISTFILE</code>
8050when a shell with history enabled exits.
17345e5a 8051
a0c0a00f 8052</li><li> Alias expansion (see <a href="#Aliases">Aliases</a>) is performed by default.
17345e5a 8053
a0c0a00f
CR
8054</li><li> In the absence of any traps, Bash ignores <code>SIGTERM</code>
8055(see <a href="#Signals">Signals</a>).
17345e5a 8056
a0c0a00f 8057</li><li> In the absence of any traps, <code>SIGINT</code> is caught and handled
2f5dfe5a 8058(see <a href="#Signals">Signals</a>).
a0c0a00f 8059<code>SIGINT</code> will interrupt some shell builtins.
17345e5a 8060
a0c0a00f
CR
8061</li><li> An interactive login shell sends a <code>SIGHUP</code> to all jobs on exit
8062if the <code>huponexit</code> shell option has been enabled (see <a href="#Signals">Signals</a>).
17345e5a 8063
a0c0a00f
CR
8064</li><li> The <samp>-n</samp> invocation option is ignored, and &lsquo;<samp>set -n</samp>&rsquo; has
8065no effect (see <a href="#The-Set-Builtin">The Set Builtin</a>).
17345e5a 8066
a0c0a00f
CR
8067</li><li> Bash will check for mail periodically, depending on the values of the
8068<code>MAIL</code>, <code>MAILPATH</code>, and <code>MAILCHECK</code> shell variables
8069(see <a href="#Bash-Variables">Bash Variables</a>).
17345e5a 8070
a0c0a00f
CR
8071</li><li> Expansion errors due to references to unbound shell variables after
8072&lsquo;<samp>set -u</samp>&rsquo; has been enabled will not cause the shell to exit
8073(see <a href="#The-Set-Builtin">The Set Builtin</a>).
17345e5a 8074
a0c0a00f
CR
8075</li><li> The shell will not exit on expansion errors caused by <var>var</var> being unset
8076or null in <code>${<var>var</var>:?<var>word</var>}</code> expansions
8077(see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
17345e5a 8078
a0c0a00f
CR
8079</li><li> Redirection errors encountered by shell builtins will not cause the
8080shell to exit.
17345e5a 8081
a0c0a00f
CR
8082</li><li> When running in <small>POSIX</small> mode, a special builtin returning an error
8083status will not cause the shell to exit (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>).
17345e5a 8084
a0c0a00f
CR
8085</li><li> A failed <code>exec</code> will not cause the shell to exit
8086(see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
495aee44 8087
a0c0a00f 8088</li><li> Parser syntax errors will not cause the shell to exit.
495aee44 8089
a0c0a00f
CR
8090</li><li> Simple spelling correction for directory arguments to the <code>cd</code>
8091builtin is enabled by default (see the description of the <code>cdspell</code>
8092option to the <code>shopt</code> builtin in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>).
17345e5a 8093
a0c0a00f
CR
8094</li><li> The shell will check the value of the <code>TMOUT</code> variable and exit
8095if a command is not read within the specified number of seconds after
8096printing <code>$PS1</code> (see <a href="#Bash-Variables">Bash Variables</a>).
8097
8098</li></ol>
8099
8100<hr>
8101<a name="Bash-Conditional-Expressions"></a>
8102<div class="header">
8103<p>
8104Next: <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>
8105</div>
8106<a name="Bash-Conditional-Expressions-1"></a>
8107<h3 class="section">6.4 Bash Conditional Expressions</h3>
8108<a name="index-expressions_002c-conditional"></a>
8109
8110<p>Conditional expressions are used by the <code>[[</code> compound command
8111and the <code>test</code> and <code>[</code> builtin commands.
8112</p>
8113<p>Expressions may be unary or binary.
8114Unary expressions are often used to examine the status of a file.
8115There are string operators and numeric comparison operators as well.
8116Bash handles several filenames specially when they are used in
8117expressions.
8118If the operating system on which Bash is running provides these
8119special files, Bash will use them; otherwise it will emulate them
8120internally with this behavior:
8121If the <var>file</var> argument to one of the primaries is of the form
8122<samp>/dev/fd/<var>N</var></samp>, then file descriptor <var>N</var> is checked.
8123If the <var>file</var> argument to one of the primaries is one of
8124<samp>/dev/stdin</samp>, <samp>/dev/stdout</samp>, or <samp>/dev/stderr</samp>, file
8125descriptor 0, 1, or 2, respectively, is checked.
8126</p>
8127<p>When used with <code>[[</code>, the &lsquo;<samp>&lt;</samp>&rsquo; and &lsquo;<samp>&gt;</samp>&rsquo; operators sort
8128lexicographically using the current locale.
8129The <code>test</code> command uses ASCII ordering.
8130</p>
8131<p>Unless otherwise specified, primaries that operate on files follow symbolic
8132links and operate on the target of the link, rather than the link itself.
8133</p>
8134<dl compact="compact">
8135<dt><code>-a <var>file</var></code></dt>
8136<dd><p>True if <var>file</var> exists.
8137</p>
8138</dd>
8139<dt><code>-b <var>file</var></code></dt>
8140<dd><p>True if <var>file</var> exists and is a block special file.
8141</p>
8142</dd>
8143<dt><code>-c <var>file</var></code></dt>
8144<dd><p>True if <var>file</var> exists and is a character special file.
8145</p>
8146</dd>
8147<dt><code>-d <var>file</var></code></dt>
8148<dd><p>True if <var>file</var> exists and is a directory.
8149</p>
8150</dd>
8151<dt><code>-e <var>file</var></code></dt>
8152<dd><p>True if <var>file</var> exists.
8153</p>
8154</dd>
8155<dt><code>-f <var>file</var></code></dt>
8156<dd><p>True if <var>file</var> exists and is a regular file.
8157</p>
8158</dd>
8159<dt><code>-g <var>file</var></code></dt>
8160<dd><p>True if <var>file</var> exists and its set-group-id bit is set.
8161</p>
8162</dd>
8163<dt><code>-h <var>file</var></code></dt>
8164<dd><p>True if <var>file</var> exists and is a symbolic link.
8165</p>
8166</dd>
8167<dt><code>-k <var>file</var></code></dt>
8168<dd><p>True if <var>file</var> exists and its &quot;sticky&quot; bit is set.
8169</p>
8170</dd>
8171<dt><code>-p <var>file</var></code></dt>
8172<dd><p>True if <var>file</var> exists and is a named pipe (FIFO).
8173</p>
8174</dd>
8175<dt><code>-r <var>file</var></code></dt>
8176<dd><p>True if <var>file</var> exists and is readable.
8177</p>
8178</dd>
8179<dt><code>-s <var>file</var></code></dt>
8180<dd><p>True if <var>file</var> exists and has a size greater than zero.
8181</p>
8182</dd>
8183<dt><code>-t <var>fd</var></code></dt>
8184<dd><p>True if file descriptor <var>fd</var> is open and refers to a terminal.
8185</p>
8186</dd>
8187<dt><code>-u <var>file</var></code></dt>
8188<dd><p>True if <var>file</var> exists and its set-user-id bit is set.
8189</p>
8190</dd>
8191<dt><code>-w <var>file</var></code></dt>
8192<dd><p>True if <var>file</var> exists and is writable.
8193</p>
8194</dd>
8195<dt><code>-x <var>file</var></code></dt>
8196<dd><p>True if <var>file</var> exists and is executable.
8197</p>
8198</dd>
8199<dt><code>-G <var>file</var></code></dt>
8200<dd><p>True if <var>file</var> exists and is owned by the effective group id.
8201</p>
8202</dd>
8203<dt><code>-L <var>file</var></code></dt>
8204<dd><p>True if <var>file</var> exists and is a symbolic link.
8205</p>
8206</dd>
8207<dt><code>-N <var>file</var></code></dt>
8208<dd><p>True if <var>file</var> exists and has been modified since it was last read.
8209</p>
8210</dd>
8211<dt><code>-O <var>file</var></code></dt>
8212<dd><p>True if <var>file</var> exists and is owned by the effective user id.
8213</p>
8214</dd>
8215<dt><code>-S <var>file</var></code></dt>
8216<dd><p>True if <var>file</var> exists and is a socket.
8217</p>
8218</dd>
8219<dt><code><var>file1</var> -ef <var>file2</var></code></dt>
8220<dd><p>True if <var>file1</var> and <var>file2</var> refer to the same device and
495aee44 8221inode numbers.
a0c0a00f
CR
8222</p>
8223</dd>
8224<dt><code><var>file1</var> -nt <var>file2</var></code></dt>
8225<dd><p>True if <var>file1</var> is newer (according to modification date)
8226than <var>file2</var>, or if <var>file1</var> exists and <var>file2</var> does not.
8227</p>
8228</dd>
8229<dt><code><var>file1</var> -ot <var>file2</var></code></dt>
8230<dd><p>True if <var>file1</var> is older than <var>file2</var>,
8231or if <var>file2</var> exists and <var>file1</var> does not.
8232</p>
8233</dd>
8234<dt><code>-o <var>optname</var></code></dt>
8235<dd><p>True if the shell option <var>optname</var> is enabled.
8236The list of options appears in the description of the <samp>-o</samp>
8237option to the <code>set</code> builtin (see <a href="#The-Set-Builtin">The Set Builtin</a>).
8238</p>
8239</dd>
8240<dt><code>-v <var>varname</var></code></dt>
8241<dd><p>True if the shell variable <var>varname</var> is set (has been assigned a value).
8242</p>
8243</dd>
8244<dt><code>-R <var>varname</var></code></dt>
8245<dd><p>True if the shell variable <var>varname</var> is set and is a name reference.
8246</p>
8247</dd>
8248<dt><code>-z <var>string</var></code></dt>
8249<dd><p>True if the length of <var>string</var> is zero.
8250</p>
8251</dd>
8252<dt><code>-n <var>string</var></code></dt>
8253<dt><code><var>string</var></code></dt>
8254<dd><p>True if the length of <var>string</var> is non-zero.
8255</p>
8256</dd>
8257<dt><code><var>string1</var> == <var>string2</var></code></dt>
8258<dt><code><var>string1</var> = <var>string2</var></code></dt>
8259<dd><p>True if the strings are equal.
8260When used with the <code>[[</code> command, this performs pattern matching as
8261described above (see <a href="#Conditional-Constructs">Conditional Constructs</a>).
8262</p>
8263<p>&lsquo;<samp>=</samp>&rsquo; should be used with the <code>test</code> command for <small>POSIX</small> conformance.
8264</p>
8265</dd>
8266<dt><code><var>string1</var> != <var>string2</var></code></dt>
8267<dd><p>True if the strings are not equal.
8268</p>
8269</dd>
8270<dt><code><var>string1</var> &lt; <var>string2</var></code></dt>
8271<dd><p>True if <var>string1</var> sorts before <var>string2</var> lexicographically.
8272</p>
8273</dd>
8274<dt><code><var>string1</var> &gt; <var>string2</var></code></dt>
8275<dd><p>True if <var>string1</var> sorts after <var>string2</var> lexicographically.
8276</p>
8277</dd>
8278<dt><code><var>arg1</var> OP <var>arg2</var></code></dt>
8279<dd><p><code>OP</code> is one of
8280&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;.
8281These arithmetic binary operators return true if <var>arg1</var>
17345e5a 8282is equal to, not equal to, less than, less than or equal to,
a0c0a00f
CR
8283greater than, or greater than or equal to <var>arg2</var>,
8284respectively. <var>Arg1</var> and <var>arg2</var>
17345e5a 8285may be positive or negative integers.
9a51695b
CR
8286When used with the <code>[[</code> command, <var>Arg1</var> and <var>Arg2</var>
8287are evaluated as arithmetic expressions (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>).
a0c0a00f
CR
8288</p></dd>
8289</dl>
8290
8291<hr>
8292<a name="Shell-Arithmetic"></a>
8293<div class="header">
8294<p>
8295Next: <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>
8296</div>
8297<a name="Shell-Arithmetic-1"></a>
8298<h3 class="section">6.5 Shell Arithmetic</h3>
8299<a name="index-arithmetic_002c-shell"></a>
8300<a name="index-shell-arithmetic"></a>
8301<a name="index-expressions_002c-arithmetic"></a>
8302<a name="index-evaluation_002c-arithmetic"></a>
8303<a name="index-arithmetic-evaluation"></a>
8304
8305<p>The shell allows arithmetic expressions to be evaluated, as one of
8306the shell expansions or by using the <code>((</code> compound command, the
8307<code>let</code> builtin, or the <samp>-i</samp> option to the <code>declare</code> builtin.
8308</p>
8309<p>Evaluation is done in fixed-width integers with no check for overflow,
17345e5a
JA
8310though division by 0 is trapped and flagged as an error.
8311The operators and their precedence, associativity, and values
8312are the same as in the C language.
8313The following list of operators is grouped into levels of
8314equal-precedence operators.
8315The levels are listed in order of decreasing precedence.
a0c0a00f
CR
8316</p>
8317<dl compact="compact">
8318<dt><code><var>id</var>++ <var>id</var>--</code></dt>
8319<dd><p>variable post-increment and post-decrement
8320</p>
8321</dd>
8322<dt><code>++<var>id</var> --<var>id</var></code></dt>
8323<dd><p>variable pre-increment and pre-decrement
8324</p>
8325</dd>
8326<dt><code>- +</code></dt>
8327<dd><p>unary minus and plus
8328</p>
8329</dd>
8330<dt><code>! ~</code></dt>
8331<dd><p>logical and bitwise negation
8332</p>
8333</dd>
8334<dt><code>**</code></dt>
8335<dd><p>exponentiation
8336</p>
8337</dd>
8338<dt><code>* / %</code></dt>
8339<dd><p>multiplication, division, remainder
8340</p>
8341</dd>
8342<dt><code>+ -</code></dt>
8343<dd><p>addition, subtraction
8344</p>
8345</dd>
8346<dt><code>&lt;&lt; &gt;&gt;</code></dt>
8347<dd><p>left and right bitwise shifts
8348</p>
8349</dd>
8350<dt><code>&lt;= &gt;= &lt; &gt;</code></dt>
8351<dd><p>comparison
8352</p>
8353</dd>
8354<dt><code>== !=</code></dt>
8355<dd><p>equality and inequality
8356</p>
8357</dd>
8358<dt><code>&amp;</code></dt>
8359<dd><p>bitwise AND
8360</p>
8361</dd>
8362<dt><code>^</code></dt>
8363<dd><p>bitwise exclusive OR
8364</p>
8365</dd>
8366<dt><code>|</code></dt>
8367<dd><p>bitwise OR
8368</p>
8369</dd>
8370<dt><code>&amp;&amp;</code></dt>
8371<dd><p>logical AND
8372</p>
8373</dd>
8374<dt><code>||</code></dt>
8375<dd><p>logical OR
8376</p>
8377</dd>
8378<dt><code>expr ? expr : expr</code></dt>
8379<dd><p>conditional operator
8380</p>
8381</dd>
8382<dt><code>= *= /= %= += -= &lt;&lt;= &gt;&gt;= &amp;= ^= |=</code></dt>
8383<dd><p>assignment
8384</p>
8385</dd>
8386<dt><code>expr1 , expr2</code></dt>
8387<dd><p>comma
8388</p></dd>
8389</dl>
8390
8391<p>Shell variables are allowed as operands; parameter expansion is
17345e5a
JA
8392performed before the expression is evaluated.
8393Within an expression, shell variables may also be referenced by name
8394without using the parameter expansion syntax.
8395A shell variable that is null or unset evaluates to 0 when referenced
8396by name without using the parameter expansion syntax.
8397The value of a variable is evaluated as an arithmetic expression
8398when it is referenced, or when a variable which has been given the
a0c0a00f 8399<var>integer</var> attribute using &lsquo;<samp>declare -i</samp>&rsquo; is assigned a value.
17345e5a 8400A null value evaluates to 0.
a0c0a00f 8401A shell variable need not have its <var>integer</var> attribute turned on
17345e5a 8402to be used in an expression.
a0c0a00f
CR
8403</p>
8404<p>Constants with a leading 0 are interpreted as octal numbers.
8405A leading &lsquo;<samp>0x</samp>&rsquo; or &lsquo;<samp>0X</samp>&rsquo; denotes hexadecimal. Otherwise,
8406numbers take the form [<var>base</var><code>#</code>]<var>n</var>, where the optional <var>base</var>
17345e5a 8407is a decimal number between 2 and 64 representing the arithmetic
a0c0a00f
CR
8408base, and <var>n</var> is a number in that base.
8409If <var>base</var><code>#</code> is omitted, then base 10 is used.
8410When specifying <var>n</var>,
8411the digits greater than 9 are represented by the lowercase letters,
8412the uppercase letters, &lsquo;<samp>@</samp>&rsquo;, and &lsquo;<samp>_</samp>&rsquo;, in that order.
8413If <var>base</var> is less than or equal to 36, lowercase and uppercase
17345e5a
JA
8414letters may be used interchangeably to represent numbers between 10
8415and 35.
a0c0a00f
CR
8416</p>
8417<p>Operators are evaluated in order of precedence. Sub-expressions in
17345e5a
JA
8418parentheses are evaluated first and may override the precedence
8419rules above.
a0c0a00f
CR
8420</p>
8421<hr>
8422<a name="Aliases"></a>
8423<div class="header">
8424<p>
8425Next: <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>
8426</div>
8427<a name="Aliases-1"></a>
8428<h3 class="section">6.6 Aliases</h3>
8429<a name="index-alias-expansion"></a>
8430
8431<p><var>Aliases</var> allow a string to be substituted for a word when it is used
17345e5a
JA
8432as the first word of a simple command.
8433The shell maintains a list of aliases that may be set and unset with
a0c0a00f
CR
8434the <code>alias</code> and <code>unalias</code> builtin commands.
8435</p>
8436<p>The first word of each simple command, if unquoted, is checked to see
17345e5a
JA
8437if it has an alias.
8438If so, that word is replaced by the text of the alias.
a0c0a00f 8439The characters &lsquo;<samp>/</samp>&rsquo;, &lsquo;<samp>$</samp>&rsquo;, &lsquo;<samp>`</samp>&rsquo;, &lsquo;<samp>=</samp>&rsquo; and any of the
17345e5a
JA
8440shell metacharacters or quoting characters listed above may not appear
8441in an alias name.
8442The replacement text may contain any valid
8443shell input, including shell metacharacters.
8444The first word of the replacement text is tested for
8445aliases, but a word that is identical to an alias being expanded
8446is not expanded a second time.
a0c0a00f 8447This means that one may alias <code>ls</code> to <code>&quot;ls -F&quot;</code>,
17345e5a 8448for instance, and Bash does not try to recursively expand the
ac50fbac
CR
8449replacement text.
8450If the last character of the alias value is a
a0c0a00f 8451<var>blank</var>, then the next command word following the
17345e5a 8452alias is also checked for alias expansion.
a0c0a00f
CR
8453</p>
8454<p>Aliases are created and listed with the <code>alias</code>
8455command, and removed with the <code>unalias</code> command.
8456</p>
8457<p>There is no mechanism for using arguments in the replacement text,
8458as in <code>csh</code>.
17345e5a 8459If arguments are needed, a shell function should be used
a0c0a00f
CR
8460(see <a href="#Shell-Functions">Shell Functions</a>).
8461</p>
8462<p>Aliases are not expanded when the shell is not interactive,
8463unless the <code>expand_aliases</code> shell option is set using
8464<code>shopt</code> (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>).
8465</p>
8466<p>The rules concerning the definition and use of aliases are
17345e5a
JA
8467somewhat confusing. Bash
8468always reads at least one complete line
8469of input before executing any
8470of the commands on that line. Aliases are expanded when a
8471command is read, not when it is executed. Therefore, an
8472alias definition appearing on the same line as another
8473command does not take effect until the next line of input is read.
8474The commands following the alias definition
8475on that line are not affected by the new alias.
8476This behavior is also an issue when functions are executed.
8477Aliases are expanded when a function definition is read,
8478not when the function is executed, because a function definition
a0c0a00f 8479is itself a command. As a consequence, aliases
17345e5a
JA
8480defined in a function are not available until after that
8481function is executed. To be safe, always put
a0c0a00f 8482alias definitions on a separate line, and do not use <code>alias</code>
17345e5a 8483in compound commands.
a0c0a00f
CR
8484</p>
8485<p>For almost every purpose, shell functions are preferred over aliases.
8486</p>
8487<hr>
8488<a name="Arrays"></a>
8489<div class="header">
8490<p>
8491Next: <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>
8492</div>
8493<a name="Arrays-1"></a>
8494<h3 class="section">6.7 Arrays</h3>
8495<a name="index-arrays"></a>
8496
8497<p>Bash provides one-dimensional indexed and associative array variables.
17345e5a 8498Any variable may be used as an indexed array;
a0c0a00f 8499the <code>declare</code> builtin will explicitly declare an array.
17345e5a
JA
8500There is no maximum
8501limit on the size of an array, nor any requirement that members
8502be indexed or assigned contiguously.
8503Indexed arrays are referenced using integers (including arithmetic
a0c0a00f 8504expressions (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>)) and are zero-based;
17345e5a 8505associative arrays use arbitrary strings.
ac50fbac 8506Unless otherwise noted, indexed array indices must be non-negative integers.
a0c0a00f
CR
8507</p>
8508<p>An indexed array is created automatically if any variable is assigned to
17345e5a 8509using the syntax
a0c0a00f
CR
8510</p><div class="example">
8511<pre class="example"><var>name</var>[<var>subscript</var>]=<var>value</var>
8512</pre></div>
17345e5a 8513
a0c0a00f 8514<p>The <var>subscript</var>
495aee44 8515is treated as an arithmetic expression that must evaluate to a number.
495aee44 8516To explicitly declare an array, use
a0c0a00f
CR
8517</p><div class="example">
8518<pre class="example">declare -a <var>name</var>
8519</pre></div>
8520<p>The syntax
8521</p><div class="example">
8522<pre class="example">declare -a <var>name</var>[<var>subscript</var>]
8523</pre></div>
8524<p>is also accepted; the <var>subscript</var> is ignored.
8525</p>
8526<p>Associative arrays are created using
8527</p><div class="example">
8528<pre class="example">declare -A <var>name</var>.
8529</pre></div>
8530
8531<p>Attributes may be
8532specified for an array variable using the <code>declare</code> and
8533<code>readonly</code> builtins. Each attribute applies to all members of
17345e5a 8534an array.
a0c0a00f
CR
8535</p>
8536<p>Arrays are assigned to using compound assignments of the form
8537</p><div class="example">
8538<pre class="example"><var>name</var>=(<var>value1</var> <var>value2</var> &hellip; )
8539</pre></div>
8540<p>where each
8541<var>value</var> is of the form <code>[<var>subscript</var>]=</code><var>string</var>.
8542Indexed array assignments do not require anything but <var>string</var>.
17345e5a
JA
8543When assigning to indexed arrays, if
8544the optional subscript is supplied, that index is assigned to;
8545otherwise the index of the element assigned is the last index assigned
8546to by the statement plus one. Indexing starts at zero.
a0c0a00f
CR
8547</p>
8548<p>When assigning to an associative array, the subscript is required.
8549</p>
8550<p>This syntax is also accepted by the <code>declare</code>
17345e5a 8551builtin. Individual array elements may be assigned to using the
a0c0a00f
CR
8552<code><var>name</var>[<var>subscript</var>]=<var>value</var></code> syntax introduced above.
8553</p>
8554<p>When assigning to an indexed array, if <var>name</var>
ac50fbac
CR
8555is subscripted by a negative number, that number is
8556interpreted as relative to one greater than the maximum index of
a0c0a00f 8557<var>name</var>, so negative indices count back from the end of the
ac50fbac 8558array, and an index of -1 references the last element.
a0c0a00f
CR
8559</p>
8560<p>Any element of an array may be referenced using
8561<code>${<var>name</var>[<var>subscript</var>]}</code>.
17345e5a 8562The braces are required to avoid
a0c0a00f
CR
8563conflicts with the shell&rsquo;s filename expansion operators. If the
8564<var>subscript</var> is &lsquo;<samp>@</samp>&rsquo; or &lsquo;<samp>*</samp>&rsquo;, the word expands to all members
8565of the array <var>name</var>. These subscripts differ only when the word
17345e5a
JA
8566appears within double quotes.
8567If the word is double-quoted,
a0c0a00f 8568<code>${<var>name</var>[*]}</code> expands to a single word with
17345e5a 8569the value of each array member separated by the first character of the
a0c0a00f
CR
8570<code>IFS</code> variable, and <code>${<var>name</var>[@]}</code> expands each element of
8571<var>name</var> to a separate word. When there are no array members,
8572<code>${<var>name</var>[@]}</code> expands to nothing.
17345e5a
JA
8573If the double-quoted expansion occurs within a word, the expansion of
8574the first parameter is joined with the beginning part of the original
8575word, and the expansion of the last parameter is joined with the last
8576part of the original word.
8577This is analogous to the
a0c0a00f
CR
8578expansion of the special parameters &lsquo;<samp>@</samp>&rsquo; and &lsquo;<samp>*</samp>&rsquo;.
8579<code>${#<var>name</var>[<var>subscript</var>]}</code> expands to the length of
8580<code>${<var>name</var>[<var>subscript</var>]}</code>.
8581If <var>subscript</var> is &lsquo;<samp>@</samp>&rsquo; or
8582&lsquo;<samp>*</samp>&rsquo;, the expansion is the number of elements in the array.
8583If the <var>subscript</var>
ac50fbac 8584used to reference an element of an indexed array
a0c0a00f 8585evaluates to a number less than zero, it is
ac50fbac
CR
8586interpreted as relative to one greater than the maximum index of the array,
8587so negative indices count back from the end of the array,
8588and an index of -1 refers to the last element.
a0c0a00f
CR
8589</p>
8590<p>Referencing an array variable without a subscript is equivalent to
8591referencing with a subscript of 0.
8592Any reference to a variable using a valid subscript is legal, and
8593<code>bash</code> will create an array if necessary.
8594</p>
8595<p>An array variable is considered set if a subscript has been assigned a
0001803f 8596value. The null string is a valid value.
a0c0a00f
CR
8597</p>
8598<p>It is possible to obtain the keys (indices) of an array as well as the values.
8599${!<var>name</var>[@]} and ${!<var>name</var>[*]} expand to the indices
8600assigned in array variable <var>name</var>.
ac50fbac 8601The treatment when in double quotes is similar to the expansion of the
a0c0a00f
CR
8602special parameters &lsquo;<samp>@</samp>&rsquo; and &lsquo;<samp>*</samp>&rsquo; within double quotes.
8603</p>
8604<p>The <code>unset</code> builtin is used to destroy arrays.
8605<code>unset <var>name</var>[<var>subscript</var>]</code>
8606destroys the array element at index <var>subscript</var>.
ac50fbac 8607Negative subscripts to indexed arrays are interpreted as described above.
9a51695b 8608Unsetting the last element of an array variable does not unset the variable.
a0c0a00f
CR
8609<code>unset <var>name</var></code>, where <var>name</var> is an array, removes the
8610entire array. A subscript of &lsquo;<samp>*</samp>&rsquo; or &lsquo;<samp>@</samp>&rsquo; also removes the
17345e5a 8611entire array.
a0c0a00f 8612</p>
9a51695b
CR
8613<p>When using a variable name with a subscript as an argument to a command,
8614such as with <code>unset</code>, without using the word expansion syntax
8615described above, the argument is subject to the shell&rsquo;s filename expansion.
8616If filename expansion is not desired, the argument should be quoted.
8617</p>
a0c0a00f
CR
8618<p>The <code>declare</code>, <code>local</code>, and <code>readonly</code>
8619builtins each accept a <samp>-a</samp> option to specify an indexed
8620array and a <samp>-A</samp> option to specify an associative array.
8621If both options are supplied, <samp>-A</samp> takes precedence.
8622The <code>read</code> builtin accepts a <samp>-a</samp>
17345e5a
JA
8623option to assign a list of words read from the standard input
8624to an array, and can read values from the standard input into
a0c0a00f 8625individual array elements. The <code>set</code> and <code>declare</code>
17345e5a
JA
8626builtins display array values in a way that allows them to be
8627reused as input.
a0c0a00f
CR
8628</p>
8629<hr>
8630<a name="The-Directory-Stack"></a>
8631<div class="header">
8632<p>
8633Next: <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>
8634</div>
8635<a name="The-Directory-Stack-1"></a>
8636<h3 class="section">6.8 The Directory Stack</h3>
8637<a name="index-directory-stack"></a>
8638
8639<table class="menu" border="0" cellspacing="0">
8640<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
8641 the directory stack.
8642</td></tr>
8643</table>
8644
8645<p>The directory stack is a list of recently-visited directories. The
8646<code>pushd</code> builtin adds directories to the stack as it changes
8647the current directory, and the <code>popd</code> builtin removes specified
17345e5a 8648directories from the stack and changes the current directory to
a0c0a00f
CR
8649the directory removed. The <code>dirs</code> builtin displays the contents
8650of the directory stack. The current directory is always the &quot;top&quot;
17345e5a 8651of the directory stack.
a0c0a00f
CR
8652</p>
8653<p>The contents of the directory stack are also visible
8654as the value of the <code>DIRSTACK</code> shell variable.
8655</p>
8656<hr>
8657<a name="Directory-Stack-Builtins"></a>
8658<div class="header">
8659<p>
8660Up: <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>
8661</div>
8662<a name="Directory-Stack-Builtins-1"></a>
8663<h4 class="subsection">6.8.1 Directory Stack Builtins</h4>
8664
8665<dl compact="compact">
8666<dt><code>dirs</code></dt>
8667<dd><a name="index-dirs"></a>
8668<div class="example">
8669<pre class="example">dirs [-clpv] [+<var>N</var> | -<var>N</var>]
8670</pre></div>
8671
8672<p>Display the list of currently remembered directories. Directories
8673are added to the list with the <code>pushd</code> command; the
8674<code>popd</code> command removes directories from the list.
8675The current directory is always the first directory in the stack.
8676</p>
8677<dl compact="compact">
8678<dt><code>-c</code></dt>
8679<dd><p>Clears the directory stack by deleting all of the elements.
8680</p></dd>
8681<dt><code>-l</code></dt>
8682<dd><p>Produces a listing using full pathnames;
ac50fbac 8683the default listing format uses a tilde to denote the home directory.
a0c0a00f
CR
8684</p></dd>
8685<dt><code>-p</code></dt>
8686<dd><p>Causes <code>dirs</code> to print the directory stack with one entry per
17345e5a 8687line.
a0c0a00f
CR
8688</p></dd>
8689<dt><code>-v</code></dt>
8690<dd><p>Causes <code>dirs</code> to print the directory stack with one entry per
17345e5a 8691line, prefixing each entry with its index in the stack.
a0c0a00f
CR
8692</p></dd>
8693<dt><code>+<var>N</var></code></dt>
8694<dd><p>Displays the <var>N</var>th directory (counting from the left of the
8695list printed by <code>dirs</code> when invoked without options), starting
ac50fbac 8696with zero.
a0c0a00f
CR
8697</p></dd>
8698<dt><code>-<var>N</var></code></dt>
8699<dd><p>Displays the <var>N</var>th directory (counting from the right of the
8700list printed by <code>dirs</code> when invoked without options), starting
ac50fbac 8701with zero.
a0c0a00f
CR
8702</p></dd>
8703</dl>
17345e5a 8704
a0c0a00f
CR
8705</dd>
8706<dt><code>popd</code></dt>
8707<dd><a name="index-popd"></a>
8708<div class="example">
8709<pre class="example">popd [-n] [+<var>N</var> | -<var>N</var>]
8710</pre></div>
17345e5a 8711
a0c0a00f 8712<p>When no arguments are given, <code>popd</code>
17345e5a 8713removes the top directory from the stack and
a0c0a00f
CR
8714performs a <code>cd</code> to the new top directory.
8715The elements are numbered from 0 starting at the first directory
8716listed with <code>dirs</code>; that is, <code>popd</code> is equivalent to <code>popd +0</code>.
8717</p>
8718<dl compact="compact">
8719<dt><code>-n</code></dt>
8720<dd><p>Suppresses the normal change of directory when removing directories
ac50fbac 8721from the stack, so that only the stack is manipulated.
a0c0a00f
CR
8722</p></dd>
8723<dt><code>+<var>N</var></code></dt>
8724<dd><p>Removes the <var>N</var>th directory (counting from the left of the
8725list printed by <code>dirs</code>), starting with zero.
8726</p></dd>
8727<dt><code>-<var>N</var></code></dt>
8728<dd><p>Removes the <var>N</var>th directory (counting from the right of the
8729list printed by <code>dirs</code>), starting with zero.
8730</p></dd>
8731</dl>
8732
8733<a name="index-pushd"></a>
8734</dd>
8735<dt><code>pushd</code></dt>
8736<dd><div class="example">
8737<pre class="example">pushd [-n] [<var>+N</var> | <var>-N</var> | <var>dir</var>]
8738</pre></div>
8739
8740<p>Save the current directory on the top of the directory stack
8741and then <code>cd</code> to <var>dir</var>.
8742With no arguments, <code>pushd</code> exchanges the top two directories
8743and makes the new top the current directory.
8744</p>
8745<dl compact="compact">
8746<dt><code>-n</code></dt>
8747<dd><p>Suppresses the normal change of directory when rotating or
8748adding directories to the stack, so that only the stack is manipulated.
8749</p></dd>
8750<dt><code>+<var>N</var></code></dt>
8751<dd><p>Brings the <var>N</var>th directory (counting from the left of the
8752list printed by <code>dirs</code>, starting with zero) to the top of
17345e5a 8753the list by rotating the stack.
a0c0a00f
CR
8754</p></dd>
8755<dt><code>-<var>N</var></code></dt>
8756<dd><p>Brings the <var>N</var>th directory (counting from the right of the
8757list printed by <code>dirs</code>, starting with zero) to the top of
17345e5a 8758the list by rotating the stack.
a0c0a00f
CR
8759</p></dd>
8760<dt><code><var>dir</var></code></dt>
8761<dd><p>Makes <var>dir</var> be the top of the stack, making
ac50fbac 8762it the new current directory as if it had been supplied as an argument
a0c0a00f
CR
8763to the <code>cd</code> builtin.
8764</p></dd>
8765</dl>
8766</dd>
8767</dl>
8768
8769<hr>
8770<a name="Controlling-the-Prompt"></a>
8771<div class="header">
8772<p>
8773Next: <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>
8774</div>
8775<a name="Controlling-the-Prompt-1"></a>
8776<h3 class="section">6.9 Controlling the Prompt</h3>
8777<a name="index-prompting"></a>
8778
8779<p>The value of the variable <code>PROMPT_COMMAND</code> is examined just before
8780Bash prints each primary prompt. If <code>PROMPT_COMMAND</code> is set and
17345e5a
JA
8781has a non-null value, then the
8782value is executed just as if it had been typed on the command line.
a0c0a00f
CR
8783</p>
8784<p>In addition, the following table describes the special characters which
9a51695b
CR
8785can appear in the prompt variables <code>PS0</code>, <code>PS1</code>, <code>PS2</code>, and
8786<code>PS4</code>:
a0c0a00f
CR
8787</p>
8788<dl compact="compact">
8789<dt><code>\a</code></dt>
8790<dd><p>A bell character.
8791</p></dd>
8792<dt><code>\d</code></dt>
8793<dd><p>The date, in &quot;Weekday Month Date&quot; format (e.g., &quot;Tue May 26&quot;).
8794</p></dd>
8795<dt><code>\D{<var>format</var>}</code></dt>
8796<dd><p>The <var>format</var> is passed to <code>strftime</code>(3) and the result is inserted
8797into the prompt string; an empty <var>format</var> results in a locale-specific
17345e5a 8798time representation. The braces are required.
a0c0a00f
CR
8799</p></dd>
8800<dt><code>\e</code></dt>
8801<dd><p>An escape character.
8802</p></dd>
8803<dt><code>\h</code></dt>
8804<dd><p>The hostname, up to the first &lsquo;.&rsquo;.
8805</p></dd>
8806<dt><code>\H</code></dt>
8807<dd><p>The hostname.
8808</p></dd>
8809<dt><code>\j</code></dt>
8810<dd><p>The number of jobs currently managed by the shell.
8811</p></dd>
8812<dt><code>\l</code></dt>
8813<dd><p>The basename of the shell&rsquo;s terminal device name.
8814</p></dd>
8815<dt><code>\n</code></dt>
8816<dd><p>A newline.
8817</p></dd>
8818<dt><code>\r</code></dt>
8819<dd><p>A carriage return.
8820</p></dd>
8821<dt><code>\s</code></dt>
8822<dd><p>The name of the shell, the basename of <code>$0</code> (the portion
17345e5a 8823following the final slash).
a0c0a00f
CR
8824</p></dd>
8825<dt><code>\t</code></dt>
8826<dd><p>The time, in 24-hour HH:MM:SS format.
8827</p></dd>
8828<dt><code>\T</code></dt>
8829<dd><p>The time, in 12-hour HH:MM:SS format.
8830</p></dd>
8831<dt><code>\@</code></dt>
8832<dd><p>The time, in 12-hour am/pm format.
8833</p></dd>
8834<dt><code>\A</code></dt>
8835<dd><p>The time, in 24-hour HH:MM format.
8836</p></dd>
8837<dt><code>\u</code></dt>
8838<dd><p>The username of the current user.
8839</p></dd>
8840<dt><code>\v</code></dt>
8841<dd><p>The version of Bash (e.g., 2.00)
8842</p></dd>
8843<dt><code>\V</code></dt>
8844<dd><p>The release of Bash, version + patchlevel (e.g., 2.00.0)
8845</p></dd>
8846<dt><code>\w</code></dt>
8847<dd><p>The current working directory, with <code>$HOME</code> abbreviated with a tilde
8848(uses the <code>$PROMPT_DIRTRIM</code> variable).
8849</p></dd>
8850<dt><code>\W</code></dt>
8851<dd><p>The basename of <code>$PWD</code>, with <code>$HOME</code> abbreviated with a tilde.
8852</p></dd>
8853<dt><code>\!</code></dt>
8854<dd><p>The history number of this command.
8855</p></dd>
8856<dt><code>\#</code></dt>
8857<dd><p>The command number of this command.
8858</p></dd>
8859<dt><code>\$</code></dt>
8860<dd><p>If the effective uid is 0, <code>#</code>, otherwise <code>$</code>.
8861</p></dd>
8862<dt><code>\<var>nnn</var></code></dt>
8863<dd><p>The character whose ASCII code is the octal value <var>nnn</var>.
8864</p></dd>
8865<dt><code>\\</code></dt>
8866<dd><p>A backslash.
8867</p></dd>
8868<dt><code>\[</code></dt>
8869<dd><p>Begin a sequence of non-printing characters. This could be used to
17345e5a 8870embed a terminal control sequence into the prompt.
a0c0a00f
CR
8871</p></dd>
8872<dt><code>\]</code></dt>
8873<dd><p>End a sequence of non-printing characters.
8874</p></dd>
8875</dl>
17345e5a 8876
a0c0a00f 8877<p>The command number and the history number are usually different:
17345e5a
JA
8878the history number of a command is its position in the history
8879list, which may include commands restored from the history file
a0c0a00f 8880(see <a href="#Bash-History-Facilities">Bash History Facilities</a>), while the command number is
17345e5a
JA
8881the position in the sequence of commands executed during the current
8882shell session.
a0c0a00f
CR
8883</p>
8884<p>After the string is decoded, it is expanded via
17345e5a
JA
8885parameter expansion, command substitution, arithmetic
8886expansion, and quote removal, subject to the value of the
2f5dfe5a 8887<code>promptvars</code> shell option (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>).
a0c0a00f
CR
8888</p>
8889<hr>
8890<a name="The-Restricted-Shell"></a>
8891<div class="header">
8892<p>
8893Next: <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>
8894</div>
8895<a name="The-Restricted-Shell-1"></a>
8896<h3 class="section">6.10 The Restricted Shell</h3>
8897<a name="index-restricted-shell"></a>
8898
8899<p>If Bash is started with the name <code>rbash</code>, or the
8900<samp>--restricted</samp>
17345e5a 8901or
a0c0a00f 8902<samp>-r</samp>
17345e5a
JA
8903option is supplied at invocation, the shell becomes restricted.
8904A restricted shell is used to
8905set up an environment more controlled than the standard shell.
a0c0a00f 8906A restricted shell behaves identically to <code>bash</code>
17345e5a 8907with the exception that the following are disallowed or not performed:
a0c0a00f
CR
8908</p>
8909<ul>
8910<li> Changing directories with the <code>cd</code> builtin.
8911</li><li> Setting or unsetting the values of the <code>SHELL</code>, <code>PATH</code>,
8912<code>ENV</code>, or <code>BASH_ENV</code> variables.
8913</li><li> Specifying command names containing slashes.
8914</li><li> Specifying a filename containing a slash as an argument to the <code>.</code>
17345e5a 8915builtin command.
a0c0a00f
CR
8916</li><li> Specifying a filename containing a slash as an argument to the <samp>-p</samp>
8917option to the <code>hash</code> builtin command.
8918</li><li> Importing function definitions from the shell environment at startup.
8919</li><li> Parsing the value of <code>SHELLOPTS</code> from the shell environment at startup.
8920</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;,
8921&lsquo;<samp>&amp;&gt;</samp>&rsquo;, and &lsquo;<samp>&gt;&gt;</samp>&rsquo; redirection operators.
8922</li><li> Using the <code>exec</code> builtin to replace the shell with another command.
8923</li><li> Adding or deleting builtin commands with the
8924<samp>-f</samp> and <samp>-d</samp> options to the <code>enable</code> builtin.
8925</li><li> Using the <code>enable</code> builtin command to enable disabled shell builtins.
8926</li><li> Specifying the <samp>-p</samp> option to the <code>command</code> builtin.
8927</li><li> Turning off restricted mode with &lsquo;<samp>set +r</samp>&rsquo; or &lsquo;<samp>set +o restricted</samp>&rsquo;.
8928</li></ul>
8929
8930<p>These restrictions are enforced after any startup files are read.
8931</p>
8932<p>When a command that is found to be a shell script is executed
8933(see <a href="#Shell-Scripts">Shell Scripts</a>), <code>rbash</code> turns off any restrictions in
17345e5a 8934the shell spawned to execute the script.
a0c0a00f
CR
8935</p>
8936<hr>
8937<a name="Bash-POSIX-Mode"></a>
8938<div class="header">
8939<p>
8940Previous: <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>
8941</div>
8942<a name="Bash-POSIX-Mode-1"></a>
8943<h3 class="section">6.11 Bash POSIX Mode</h3>
8944<a name="index-POSIX-Mode"></a>
8945
8946<p>Starting Bash with the <samp>--posix</samp> command-line option or executing
8947&lsquo;<samp>set -o posix</samp>&rsquo; while Bash is running will cause Bash to conform more
8948closely to the <small>POSIX</small> standard by changing the behavior to
8949match that specified by <small>POSIX</small> in areas where the Bash default differs.
8950</p>
8951<p>When invoked as <code>sh</code>, Bash enters <small>POSIX</small> mode after reading the
17345e5a 8952startup files.
a0c0a00f
CR
8953</p>
8954<p>The following list is what&rsquo;s changed when &lsquo;<small>POSIX</small> mode&rsquo; is in effect:
8955</p>
8956<ol>
2f5dfe5a
CR
8957<li> Bash ensures that the <code>POSIXLY_CORRECT</code> variable is set.
8958
8959</li><li> When a command in the hash table no longer exists, Bash will re-search
a0c0a00f
CR
8960<code>$PATH</code> to find the new location. This is also available with
8961&lsquo;<samp>shopt -s checkhash</samp>&rsquo;.
17345e5a 8962
a0c0a00f
CR
8963</li><li> The message printed by the job control code and builtins when a job
8964exits with a non-zero status is &lsquo;Done(status)&rsquo;.
17345e5a 8965
a0c0a00f
CR
8966</li><li> The message printed by the job control code and builtins when a job
8967is stopped is &lsquo;Stopped(<var>signame</var>)&rsquo;, where <var>signame</var> is, for
8968example, <code>SIGTSTP</code>.
17345e5a 8969
a0c0a00f 8970</li><li> Alias expansion is always enabled, even in non-interactive shells.
17345e5a 8971
a0c0a00f
CR
8972</li><li> Reserved words appearing in a context where reserved words are recognized
8973do not undergo alias expansion.
17345e5a 8974
a0c0a00f
CR
8975</li><li> The <small>POSIX</small> <code>PS1</code> and <code>PS2</code> expansions of &lsquo;<samp>!</samp>&rsquo; to
8976the history number and &lsquo;<samp>!!</samp>&rsquo; to &lsquo;<samp>!</samp>&rsquo; are enabled,
8977and parameter expansion is performed on the values of <code>PS1</code> and
8978<code>PS2</code> regardless of the setting of the <code>promptvars</code> option.
17345e5a 8979
a0c0a00f
CR
8980</li><li> The <small>POSIX</small> startup files are executed (<code>$ENV</code>) rather than
8981the normal Bash files.
17345e5a 8982
a0c0a00f
CR
8983</li><li> Tilde expansion is only performed on assignments preceding a command
8984name, rather than on all assignment statements on the line.
17345e5a 8985
a0c0a00f
CR
8986</li><li> The default history file is <samp>~/.sh_history</samp> (this is the
8987default value of <code>$HISTFILE</code>).
495aee44 8988
a0c0a00f 8989</li><li> Redirection operators do not perform filename expansion on the word
17345e5a 8990in the redirection unless the shell is interactive.
17345e5a 8991
a0c0a00f 8992</li><li> Redirection operators do not perform word splitting on the word in the
17345e5a 8993redirection.
17345e5a 8994
a0c0a00f 8995</li><li> Function names must be valid shell <code>name</code>s. That is, they may not
17345e5a
JA
8996contain characters other than letters, digits, and underscores, and
8997may not start with a digit. Declaring a function with an invalid name
8998causes a fatal syntax error in non-interactive shells.
17345e5a 8999
a0c0a00f 9000</li><li> Function names may not be the same as one of the <small>POSIX</small> special
ac50fbac 9001builtins.
ac50fbac 9002
a0c0a00f 9003</li><li> <small>POSIX</small> special builtins are found before shell functions
17345e5a 9004during command lookup.
17345e5a 9005
a0c0a00f
CR
9006</li><li> When printing shell function definitions (e.g., by <code>type</code>), Bash does
9007not print the <code>function</code> keyword.
9008
9009</li><li> Literal tildes that appear as the first character in elements of
9010the <code>PATH</code> variable are not expanded as described above
9011under <a href="#Tilde-Expansion">Tilde Expansion</a>.
9012
9013</li><li> The <code>time</code> reserved word may be used by itself as a command. When
495aee44 9014used in this way, it displays timing statistics for the shell and its
a0c0a00f 9015completed children. The <code>TIMEFORMAT</code> variable controls the format
495aee44 9016of the timing information.
495aee44 9017
a0c0a00f 9018</li><li> When parsing and expanding a ${&hellip;} expansion that appears within
495aee44
CR
9019double quotes, single quotes are no longer special and cannot be used to
9020quote a closing brace or other special character, unless the operator is
9021one of those defined to perform pattern removal. In this case, they do
9022not have to appear as matched pairs.
495aee44 9023
a0c0a00f
CR
9024</li><li> The parser does not recognize <code>time</code> as a reserved word if the next
9025token begins with a &lsquo;<samp>-</samp>&rsquo;.
9026
9027</li><li> The &lsquo;<samp>!</samp>&rsquo; character does not introduce history expansion within a
9028double-quoted string, even if the <code>histexpand</code> option is enabled.
495aee44 9029
a0c0a00f 9030</li><li> If a <small>POSIX</small> special builtin returns an error status, a
17345e5a 9031non-interactive shell exits. The fatal errors are those listed in
a0c0a00f 9032the <small>POSIX</small> standard, and include things like passing incorrect options,
17345e5a
JA
9033redirection errors, variable assignment errors for assignments preceding
9034the command name, and so on.
17345e5a 9035
a0c0a00f 9036</li><li> A non-interactive shell exits with an error status if a variable
17345e5a
JA
9037assignment error occurs when no command name follows the assignment
9038statements.
9039A variable assignment error occurs, for example, when trying to assign
9040a value to a readonly variable.
17345e5a 9041
a0c0a00f 9042</li><li> A non-interactive shell exits with an error status if a variable
495aee44
CR
9043assignment error occurs in an assignment statement preceding a special
9044builtin, but not with any other simple command.
495aee44 9045
a0c0a00f
CR
9046</li><li> A non-interactive shell exits with an error status if the iteration
9047variable in a <code>for</code> statement or the selection variable in a
9048<code>select</code> statement is a readonly variable.
17345e5a 9049
a0c0a00f
CR
9050</li><li> Non-interactive shells exit if <var>filename</var> in <code>.</code> <var>filename</var>
9051is not found.
9052
9053</li><li> Non-interactive shells exit if a syntax error in an arithmetic expansion
9054results in an invalid expression.
9055
9056</li><li> Non-interactive shells exit if a parameter expansion error occurs.
17345e5a 9057
a0c0a00f
CR
9058</li><li> Non-interactive shells exit if there is a syntax error in a script read
9059with the <code>.</code> or <code>source</code> builtins, or in a string processed by
9060the <code>eval</code> builtin.
9061
9062</li><li> Process substitution is not available.
9063
9064</li><li> While variable indirection is available, it may not be applied to the
9065&lsquo;<samp>#</samp>&rsquo; and &lsquo;<samp>?</samp>&rsquo; special parameters.
9066
9067</li><li> When expanding the &lsquo;<samp>*</samp>&rsquo; special parameter in a pattern context where the
9068expansion is double-quoted does not treat the <code>$*</code> as if it were
9069double-quoted.
ac50fbac 9070
a0c0a00f 9071</li><li> Assignment statements preceding <small>POSIX</small> special builtins
17345e5a 9072persist in the shell environment after the builtin completes.
17345e5a 9073
a0c0a00f
CR
9074</li><li> Assignment statements preceding shell function calls persist in the
9075shell environment after the function returns, as if a <small>POSIX</small>
17345e5a 9076special builtin command had been executed.
17345e5a 9077
a0c0a00f
CR
9078</li><li> The <code>command</code> builtin does not prevent builtins that take assignment
9079statements as arguments from expanding them as assignment statements;
9080when not in <small>POSIX</small> mode, assignment builtins lose their assignment
9081statement expansion properties when preceded by <code>command</code>.
9082
9083</li><li> The <code>bg</code> builtin uses the required format to describe each job placed
9084in the background, which does not include an indication of whether the job
9085is the current or previous job.
9086
9087</li><li> The output of &lsquo;<samp>kill -l</samp>&rsquo; prints all the signal names on a single line,
9088separated by spaces, without the &lsquo;<samp>SIG</samp>&rsquo; prefix.
9089
9090</li><li> The <code>kill</code> builtin does not accept signal names with a &lsquo;<samp>SIG</samp>&rsquo;
9091prefix.
9092
9093</li><li> The <code>export</code> and <code>readonly</code> builtin commands display their
9094output in the format required by <small>POSIX</small>.
17345e5a 9095
a0c0a00f
CR
9096</li><li> The <code>trap</code> builtin displays signal names without the leading
9097<code>SIG</code>.
17345e5a 9098
a0c0a00f 9099</li><li> The <code>trap</code> builtin doesn&rsquo;t check the first argument for a possible
17345e5a
JA
9100signal specification and revert the signal handling to the original
9101disposition if it is, unless that argument consists solely of digits and
9102is a valid signal number. If users want to reset the handler for a given
a0c0a00f 9103signal to the original disposition, they should use &lsquo;<samp>-</samp>&rsquo; as the
17345e5a 9104first argument.
a0c0a00f
CR
9105
9106</li><li> The <code>.</code> and <code>source</code> builtins do not search the current directory
9107for the filename argument if it is not found by searching <code>PATH</code>.
9108
9109</li><li> Enabling <small>POSIX</small> mode has the effect of setting the
9110<code>inherit_errexit</code> option, so
9111subshells spawned to execute command substitutions inherit the value of
9112the <samp>-e</samp> option from the parent shell.
9113When the <code>inherit_errexit</code> option is not enabled,
9114Bash clears the <samp>-e</samp> option in such subshells.
9115
9116</li><li> When the <code>alias</code> builtin displays alias definitions, it does not
9117display them with a leading &lsquo;<samp>alias </samp>&rsquo; unless the <samp>-p</samp> option
17345e5a 9118is supplied.
17345e5a 9119
a0c0a00f 9120</li><li> When the <code>set</code> builtin is invoked without options, it does not display
17345e5a 9121shell function names and definitions.
17345e5a 9122
a0c0a00f 9123</li><li> When the <code>set</code> builtin is invoked without options, it displays
17345e5a
JA
9124variable values without quotes, unless they contain shell metacharacters,
9125even if the result contains nonprinting characters.
17345e5a 9126
a0c0a00f
CR
9127</li><li> When the <code>cd</code> builtin is invoked in <var>logical</var> mode, and the pathname
9128constructed from <code>$PWD</code> and the directory name supplied as an argument
9129does not refer to an existing directory, <code>cd</code> will fail instead of
9130falling back to <var>physical</var> mode.
17345e5a 9131
a0c0a00f 9132</li><li> The <code>pwd</code> builtin verifies that the value it prints is the same as the
17345e5a 9133current directory, even if it is not asked to check the file system with the
a0c0a00f 9134<samp>-P</samp> option.
17345e5a 9135
a0c0a00f 9136</li><li> When listing the history, the <code>fc</code> builtin does not include an
17345e5a 9137indication of whether or not a history entry has been modified.
17345e5a 9138
a0c0a00f 9139</li><li> The default editor used by <code>fc</code> is <code>ed</code>.
17345e5a 9140
a0c0a00f 9141</li><li> The <code>type</code> and <code>command</code> builtins will not report a non-executable
17345e5a 9142file as having been found, though the shell will attempt to execute such a
a0c0a00f
CR
9143file if it is the only so-named file found in <code>$PATH</code>.
9144
9145</li><li> The <code>vi</code> editing mode will invoke the <code>vi</code> editor directly when
9146the &lsquo;<samp>v</samp>&rsquo; command is run, instead of checking <code>$VISUAL</code> and
9147<code>$EDITOR</code>.
9148
9149</li><li> When the <code>xpg_echo</code> option is enabled, Bash does not attempt to interpret
9150any arguments to <code>echo</code> as options. Each argument is displayed, after
17345e5a 9151escape characters are converted.
17345e5a 9152
a0c0a00f
CR
9153</li><li> The <code>ulimit</code> builtin uses a block size of 512 bytes for the <samp>-c</samp>
9154and <samp>-f</samp> options.
17345e5a 9155
a0c0a00f
CR
9156</li><li> The arrival of <code>SIGCHLD</code> when a trap is set on <code>SIGCHLD</code> does
9157not interrupt the <code>wait</code> builtin and cause it to return immediately.
0001803f 9158The trap command is run once for each child that exits.
0001803f 9159
a0c0a00f 9160</li><li> The <code>read</code> builtin may be interrupted by a signal for which a trap
ac50fbac 9161has been set.
a0c0a00f
CR
9162If Bash receives a trapped signal while executing <code>read</code>, the trap
9163handler executes and <code>read</code> returns an exit status greater than 128.
9164
9165</li><li> Bash removes an exited background process&rsquo;s status from the list of such
9166statuses after the <code>wait</code> builtin is used to obtain it.
ac50fbac 9167
a0c0a00f 9168</li></ol>
17345e5a 9169
a0c0a00f
CR
9170<p>There is other <small>POSIX</small> behavior that Bash does not implement by
9171default even when in <small>POSIX</small> mode.
17345e5a 9172Specifically:
a0c0a00f
CR
9173</p>
9174<ol>
9175<li> The <code>fc</code> builtin checks <code>$EDITOR</code> as a program to edit history
9176entries if <code>FCEDIT</code> is unset, rather than defaulting directly to
9177<code>ed</code>. <code>fc</code> uses <code>ed</code> if <code>EDITOR</code> is unset.
9178
9179</li><li> As noted above, Bash requires the <code>xpg_echo</code> option to be enabled for
9180the <code>echo</code> builtin to be fully conformant.
9181
9182</li></ol>
9183
9184<p>Bash can be configured to be <small>POSIX</small>-conformant by default, by specifying
9185the <samp>--enable-strict-posix-default</samp> to <code>configure</code> when building
9186(see <a href="#Optional-Features">Optional Features</a>).
9187</p>
9188<hr>
9189<a name="Job-Control"></a>
9190<div class="header">
9191<p>
9192Next: <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>
9193</div>
9194<a name="Job-Control-1"></a>
9195<h2 class="chapter">7 Job Control</h2>
9196
9197<p>This chapter discusses what job control is, how it works, and how
17345e5a 9198Bash allows you to access its facilities.
a0c0a00f
CR
9199</p>
9200<table class="menu" border="0" cellspacing="0">
9201<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.
9202</td></tr>
9203<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
9204 with job control.
9205</td></tr>
9206<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
9207 control.
9208</td></tr>
9209</table>
9210
9211<hr>
9212<a name="Job-Control-Basics"></a>
9213<div class="header">
9214<p>
9215Next: <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>
9216</div>
9217<a name="Job-Control-Basics-1"></a>
9218<h3 class="section">7.1 Job Control Basics</h3>
9219<a name="index-job-control-1"></a>
9220<a name="index-foreground"></a>
9221<a name="index-background"></a>
9222<a name="index-suspending-jobs"></a>
9223
9224<p>Job control
17345e5a
JA
9225refers to the ability to selectively stop (suspend)
9226the execution of processes and continue (resume)
9227their execution at a later point. A user typically employs
9228this facility via an interactive interface supplied jointly
a0c0a00f
CR
9229by the operating system kernel&rsquo;s terminal driver and Bash.
9230</p>
9231<p>The shell associates a <var>job</var> with each pipeline. It keeps a
17345e5a 9232table of currently executing jobs, which may be listed with the
a0c0a00f 9233<code>jobs</code> command. When Bash starts a job
17345e5a
JA
9234asynchronously, it prints a line that looks
9235like:
a0c0a00f
CR
9236</p><div class="example">
9237<pre class="example">[1] 25647
9238</pre></div>
9239<p>indicating that this job is job number 1 and that the process <small>ID</small>
17345e5a
JA
9240of the last process in the pipeline associated with this job is
924125647. All of the processes in a single pipeline are members of
a0c0a00f 9242the same job. Bash uses the <var>job</var> abstraction as the
17345e5a 9243basis for job control.
a0c0a00f
CR
9244</p>
9245<p>To facilitate the implementation of the user interface to job
17345e5a 9246control, the operating system maintains the notion of a current terminal
a0c0a00f
CR
9247process group <small>ID</small>. Members of this process group (processes whose
9248process group <small>ID</small> is equal to the current terminal process group
9249<small>ID</small>) receive keyboard-generated signals such as <code>SIGINT</code>.
17345e5a 9250These processes are said to be in the foreground. Background
a0c0a00f
CR
9251processes are those whose process group <small>ID</small> differs from the
9252terminal&rsquo;s; such processes are immune to keyboard-generated
0001803f 9253signals. Only foreground processes are allowed to read from or, if
a0c0a00f 9254the user so specifies with <code>stty tostop</code>, write to the terminal.
0001803f 9255Background processes which attempt to
a0c0a00f
CR
9256read from (write to when <code>stty tostop</code> is in effect) the
9257terminal are sent a <code>SIGTTIN</code> (<code>SIGTTOU</code>)
9258signal by the kernel&rsquo;s terminal driver,
0001803f 9259which, unless caught, suspends the process.
a0c0a00f
CR
9260</p>
9261<p>If the operating system on which Bash is running supports
17345e5a 9262job control, Bash contains facilities to use it. Typing the
a0c0a00f 9263<var>suspend</var> character (typically &lsquo;<samp>^Z</samp>&rsquo;, Control-Z) while a
17345e5a 9264process is running causes that process to be stopped and returns
a0c0a00f
CR
9265control to Bash. Typing the <var>delayed suspend</var> character
9266(typically &lsquo;<samp>^Y</samp>&rsquo;, Control-Y) causes the process to be stopped
17345e5a
JA
9267when it attempts to read input from the terminal, and control to
9268be returned to Bash. The user then manipulates the state of
a0c0a00f
CR
9269this job, using the <code>bg</code> command to continue it in the
9270background, the <code>fg</code> command to continue it in the
9271foreground, or the <code>kill</code> command to kill it. A &lsquo;<samp>^Z</samp>&rsquo;
17345e5a
JA
9272takes effect immediately, and has the additional side effect of
9273causing pending output and typeahead to be discarded.
a0c0a00f
CR
9274</p>
9275<p>There are a number of ways to refer to a job in the shell. The
9276character &lsquo;<samp>%</samp>&rsquo; introduces a job specification (<var>jobspec</var>).
9277</p>
9278<p>Job number <code>n</code> may be referred to as &lsquo;<samp>%n</samp>&rsquo;.
9279The symbols &lsquo;<samp>%%</samp>&rsquo; and &lsquo;<samp>%+</samp>&rsquo; refer to the shell&rsquo;s notion of the
17345e5a
JA
9280current job, which is the last job stopped while it was in the foreground
9281or started in the background.
a0c0a00f 9282A single &lsquo;<samp>%</samp>&rsquo; (with no accompanying job specification) also refers
17345e5a 9283to the current job.
a0c0a00f
CR
9284The previous job may be referenced using &lsquo;<samp>%-</samp>&rsquo;.
9285If there is only a single job, &lsquo;<samp>%+</samp>&rsquo; and &lsquo;<samp>%-</samp>&rsquo; can both be used
17345e5a 9286to refer to that job.
a0c0a00f
CR
9287In output pertaining to jobs (e.g., the output of the <code>jobs</code>
9288command), the current job is always flagged with a &lsquo;<samp>+</samp>&rsquo;, and the
9289previous job with a &lsquo;<samp>-</samp>&rsquo;.
9290</p>
9291<p>A job may also be referred to
17345e5a 9292using a prefix of the name used to start it, or using a substring
a0c0a00f
CR
9293that appears in its command line. For example, &lsquo;<samp>%ce</samp>&rsquo; refers
9294to a stopped <code>ce</code> job. Using &lsquo;<samp>%?ce</samp>&rsquo;, on the
9295other hand, refers to any job containing the string &lsquo;<samp>ce</samp>&rsquo; in
17345e5a
JA
9296its command line. If the prefix or substring matches more than one job,
9297Bash reports an error.
a0c0a00f
CR
9298</p>
9299<p>Simply naming a job can be used to bring it into the foreground:
9300&lsquo;<samp>%1</samp>&rsquo; is a synonym for &lsquo;<samp>fg %1</samp>&rsquo;, bringing job 1 from the
9301background into the foreground. Similarly, &lsquo;<samp>%1 &amp;</samp>&rsquo; resumes
9302job 1 in the background, equivalent to &lsquo;<samp>bg %1</samp>&rsquo;
9303</p>
9304<p>The shell learns immediately whenever a job changes state.
17345e5a 9305Normally, Bash waits until it is about to print a prompt
a0c0a00f 9306before reporting changes in a job&rsquo;s status so as to not interrupt
17345e5a 9307any other output.
a0c0a00f
CR
9308If the <samp>-b</samp> option to the <code>set</code> builtin is enabled,
9309Bash reports such changes immediately (see <a href="#The-Set-Builtin">The Set Builtin</a>).
9310Any trap on <code>SIGCHLD</code> is executed for each child process
17345e5a 9311that exits.
a0c0a00f
CR
9312</p>
9313<p>If an attempt to exit Bash is made while jobs are stopped, (or running, if
9314the <code>checkjobs</code> option is enabled &ndash; see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), the
9315shell prints a warning message, and if the <code>checkjobs</code> option is
17345e5a 9316enabled, lists the jobs and their statuses.
a0c0a00f 9317The <code>jobs</code> command may then be used to inspect their status.
17345e5a
JA
9318If a second attempt to exit is made without an intervening command,
9319Bash does not print another warning, and any stopped jobs are terminated.
a0c0a00f 9320</p>
9a51695b
CR
9321<p>When the shell is waiting for a job or process using the <code>wait</code>
9322builtin, and job control is enabled, <code>wait</code> will return when the
9323job changes state. The <samp>-f</samp> option will force <code>wait</code> to wait
9324until the job or process terminates before returning.
9325</p>
a0c0a00f
CR
9326<hr>
9327<a name="Job-Control-Builtins"></a>
9328<div class="header">
9329<p>
9330Next: <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>
9331</div>
9332<a name="Job-Control-Builtins-1"></a>
9333<h3 class="section">7.2 Job Control Builtins</h3>
9334
9335<dl compact="compact">
9336<dt><code>bg</code></dt>
9337<dd><a name="index-bg"></a>
9338<div class="example">
9339<pre class="example">bg [<var>jobspec</var> &hellip;]
9340</pre></div>
9341
9342<p>Resume each suspended job <var>jobspec</var> in the background, as if it
9343had been started with &lsquo;<samp>&amp;</samp>&rsquo;.
9344If <var>jobspec</var> is not supplied, the current job is used.
17345e5a
JA
9345The return status is zero unless it is run when job control is not
9346enabled, or, when run with job control enabled, any
a0c0a00f 9347<var>jobspec</var> was not found or specifies a job
17345e5a 9348that was started without job control.
a0c0a00f
CR
9349</p>
9350</dd>
9351<dt><code>fg</code></dt>
9352<dd><a name="index-fg"></a>
9353<div class="example">
9354<pre class="example">fg [<var>jobspec</var>]
9355</pre></div>
9356
9357<p>Resume the job <var>jobspec</var> in the foreground and make it the current job.
9358If <var>jobspec</var> is not supplied, the current job is used.
17345e5a
JA
9359The return status is that of the command placed into the foreground,
9360or non-zero if run when job control is disabled or, when run with
a0c0a00f
CR
9361job control enabled, <var>jobspec</var> does not specify a valid job or
9362<var>jobspec</var> specifies a job that was started without job control.
9363</p>
9364</dd>
9365<dt><code>jobs</code></dt>
9366<dd><a name="index-jobs"></a>
9367<div class="example">
9368<pre class="example">jobs [-lnprs] [<var>jobspec</var>]
9369jobs -x <var>command</var> [<var>arguments</var>]
9370</pre></div>
9371
9372<p>The first form lists the active jobs. The options have the
17345e5a 9373following meanings:
a0c0a00f
CR
9374</p>
9375<dl compact="compact">
9376<dt><code>-l</code></dt>
9377<dd><p>List process <small>ID</small>s in addition to the normal information.
9378</p>
9379</dd>
9380<dt><code>-n</code></dt>
9381<dd><p>Display information only about jobs that have changed status since
17345e5a 9382the user was last notified of their status.
a0c0a00f
CR
9383</p>
9384</dd>
9385<dt><code>-p</code></dt>
9386<dd><p>List only the process <small>ID</small> of the job&rsquo;s process group leader.
9387</p>
9388</dd>
9389<dt><code>-r</code></dt>
9390<dd><p>Display only running jobs.
9391</p>
9392</dd>
9393<dt><code>-s</code></dt>
9394<dd><p>Display only stopped jobs.
9395</p></dd>
9396</dl>
9397
9398<p>If <var>jobspec</var> is given,
17345e5a 9399output is restricted to information about that job.
a0c0a00f 9400If <var>jobspec</var> is not supplied, the status of all jobs is
17345e5a 9401listed.
a0c0a00f
CR
9402</p>
9403<p>If the <samp>-x</samp> option is supplied, <code>jobs</code> replaces any
9404<var>jobspec</var> found in <var>command</var> or <var>arguments</var> with the
9405corresponding process group <small>ID</small>, and executes <var>command</var>,
9406passing it <var>argument</var>s, returning its exit status.
9407</p>
9408</dd>
9409<dt><code>kill</code></dt>
9410<dd><a name="index-kill"></a>
9411<div class="example">
9412<pre class="example">kill [-s <var>sigspec</var>] [-n <var>signum</var>] [-<var>sigspec</var>] <var>jobspec</var> or <var>pid</var>
9413kill -l|-L [<var>exit_status</var>]
9414</pre></div>
9415
9416<p>Send a signal specified by <var>sigspec</var> or <var>signum</var> to the process
9417named by job specification <var>jobspec</var> or process <small>ID</small> <var>pid</var>.
9418<var>sigspec</var> is either a case-insensitive signal name such as
9419<code>SIGINT</code> (with or without the <code>SIG</code> prefix)
9420or a signal number; <var>signum</var> is a signal number.
9421If <var>sigspec</var> and <var>signum</var> are not present, <code>SIGTERM</code> is used.
9422The <samp>-l</samp> option lists the signal names.
9423If any arguments are supplied when <samp>-l</samp> is given, the names of the
17345e5a
JA
9424signals corresponding to the arguments are listed, and the return status
9425is zero.
a0c0a00f 9426<var>exit_status</var> is a number specifying a signal number or the exit
17345e5a 9427status of a process terminated by a signal.
a0c0a00f 9428The <samp>-L</samp> option is equivalent to <samp>-l</samp>.
17345e5a
JA
9429The return status is zero if at least one signal was successfully sent,
9430or non-zero if an error occurs or an invalid option is encountered.
a0c0a00f
CR
9431</p>
9432</dd>
9433<dt><code>wait</code></dt>
9434<dd><a name="index-wait"></a>
9435<div class="example">
9a51695b 9436<pre class="example">wait [-fn] [<var>jobspec</var> or <var>pid</var> &hellip;]
a0c0a00f
CR
9437</pre></div>
9438
9439<p>Wait until the child process specified by each process <small>ID</small> <var>pid</var>
9440or job specification <var>jobspec</var> exits and return the exit status of the
17345e5a
JA
9441last command waited for.
9442If a job spec is given, all processes in the job are waited for.
9443If no arguments are given, all currently active child processes are
9444waited for, and the return status is zero.
a0c0a00f 9445If the <samp>-n</samp> option is supplied, <code>wait</code> waits for any job to
ac50fbac 9446terminate and returns its exit status.
9a51695b
CR
9447If the <samp>-f</samp> option is supplied, and job control is enabled,
9448<code>wait</code> forces each <var>pid</var> or <var>jobspec</var> to terminate before
9449returning its status, intead of returning when it changes status.
a0c0a00f 9450If neither <var>jobspec</var> nor <var>pid</var> specifies an active child process
17345e5a 9451of the shell, the return status is 127.
a0c0a00f
CR
9452</p>
9453</dd>
9454<dt><code>disown</code></dt>
9455<dd><a name="index-disown"></a>
9456<div class="example">
9457<pre class="example">disown [-ar] [-h] [<var>jobspec</var> &hellip; | <var>pid</var> &hellip; ]
9458</pre></div>
9459
9460<p>Without options, remove each <var>jobspec</var> from the table of
17345e5a 9461active jobs.
a0c0a00f
CR
9462If the <samp>-h</samp> option is given, the job is not removed from the table,
9463but is marked so that <code>SIGHUP</code> is not sent to the job if the shell
9464receives a <code>SIGHUP</code>.
9465If <var>jobspec</var> is not present, and neither the <samp>-a</samp> nor the
9466<samp>-r</samp> option is supplied, the current job is used.
9467If no <var>jobspec</var> is supplied, the <samp>-a</samp> option means to remove or
9468mark all jobs; the <samp>-r</samp> option without a <var>jobspec</var>
17345e5a 9469argument restricts operation to running jobs.
a0c0a00f
CR
9470</p>
9471</dd>
9472<dt><code>suspend</code></dt>
9473<dd><a name="index-suspend"></a>
9474<div class="example">
9475<pre class="example">suspend [-f]
9476</pre></div>
9477
9478<p>Suspend the execution of this shell until it receives a
9479<code>SIGCONT</code> signal.
9480A login shell cannot be suspended; the <samp>-f</samp>
17345e5a 9481option can be used to override this and force the suspension.
a0c0a00f
CR
9482</p></dd>
9483</dl>
9484
9485<p>When job control is not active, the <code>kill</code> and <code>wait</code>
9486builtins do not accept <var>jobspec</var> arguments. They must be
9487supplied process <small>ID</small>s.
9488</p>
9489<hr>
9490<a name="Job-Control-Variables"></a>
9491<div class="header">
9492<p>
9493Previous: <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>
9494</div>
9495<a name="Job-Control-Variables-1"></a>
9496<h3 class="section">7.3 Job Control Variables</h3>
9497
9498<dl compact="compact">
9499<dt><code>auto_resume</code>
9500<a name="index-auto_005fresume"></a>
9501</dt>
9502<dd><p>This variable controls how the shell interacts with the user and
17345e5a
JA
9503job control. If this variable exists then single word simple
9504commands without redirections are treated as candidates for resumption
9505of an existing job. There is no ambiguity allowed; if there is
9506more than one job beginning with the string typed, then
9507the most recently accessed job will be selected.
9508The name of a stopped job, in this context, is the command line
a0c0a00f 9509used to start it. If this variable is set to the value &lsquo;<samp>exact</samp>&rsquo;,
17345e5a 9510the string supplied must match the name of a stopped job exactly;
a0c0a00f 9511if set to &lsquo;<samp>substring</samp>&rsquo;,
17345e5a 9512the string supplied needs to match a substring of the name of a
a0c0a00f
CR
9513stopped job. The &lsquo;<samp>substring</samp>&rsquo; value provides functionality
9514analogous to the &lsquo;<samp>%?</samp>&rsquo; job <small>ID</small> (see <a href="#Job-Control-Basics">Job Control Basics</a>).
17345e5a 9515If set to any other value, the supplied string must
a0c0a00f
CR
9516be a prefix of a stopped job&rsquo;s name; this provides functionality
9517analogous to the &lsquo;<samp>%</samp>&rsquo; job <small>ID</small>.
9518</p>
9519</dd>
9520</dl>
9521
9522<a name="index-Readline_002c-how-to-use"></a>
9523
9524
9525
9526
9527<hr>
9528<a name="Command-Line-Editing"></a>
9529<div class="header">
9530<p>
9531Next: <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>
9532</div>
9533<a name="Command-Line-Editing-1"></a>
9534<h2 class="chapter">8 Command Line Editing</h2>
9535
9536<p>This chapter describes the basic features of the <small>GNU</small>
17345e5a
JA
9537command line editing interface.
9538Command line editing is provided by the Readline library, which is
9539used by several different programs, including Bash.
9540Command line editing is enabled by default when using an interactive shell,
a0c0a00f
CR
9541unless the <samp>--noediting</samp> option is supplied at shell invocation.
9542Line editing is also used when using the <samp>-e</samp> option to the
9543<code>read</code> builtin command (see <a href="#Bash-Builtins">Bash Builtins</a>).
495aee44 9544By default, the line editing commands are similar to those of Emacs.
17345e5a 9545A vi-style line editing interface is also available.
a0c0a00f
CR
9546Line editing can be enabled at any time using the <samp>-o emacs</samp> or
9547<samp>-o vi</samp> options to the <code>set</code> builtin command
9548(see <a href="#The-Set-Builtin">The Set Builtin</a>), or disabled using the <samp>+o emacs</samp> or
9549<samp>+o vi</samp> options to <code>set</code>.
9550</p>
9551<table class="menu" border="0" cellspacing="0">
9552<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.
9553</td></tr>
9554<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.
9555</td></tr>
9556<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.
9557</td></tr>
9558<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
9559 available for binding
9560</td></tr>
9561<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
9562 behave like the vi editor.
9563</td></tr>
9564<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
9565 a specific command.
9566</td></tr>
9567<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
9568 complete arguments for a particular command.
9569</td></tr>
9570<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
9571 generating possible completions.
9572</td></tr>
9573</table>
9574
9575<hr>
9576<a name="Introduction-and-Notation"></a>
9577<div class="header">
9578<p>
9579Next: <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>
9580</div>
9581<a name="Introduction-to-Line-Editing"></a>
9582<h3 class="section">8.1 Introduction to Line Editing</h3>
9583
9584<p>The following paragraphs describe the notation used to represent
17345e5a 9585keystrokes.
a0c0a00f
CR
9586</p>
9587<p>The text <kbd>C-k</kbd> is read as &lsquo;Control-K&rsquo; and describes the character
9588produced when the <tt class="key">k</tt> key is pressed while the Control key
17345e5a 9589is depressed.
a0c0a00f
CR
9590</p>
9591<p>The text <kbd>M-k</kbd> is read as &lsquo;Meta-K&rsquo; and describes the character
9592produced when the Meta key (if you have one) is depressed, and the <tt class="key">k</tt>
17345e5a 9593key is pressed.
a0c0a00f
CR
9594The Meta key is labeled <tt class="key">ALT</tt> on many keyboards.
9595On keyboards with two keys labeled <tt class="key">ALT</tt> (usually to either side of
9596the space bar), the <tt class="key">ALT</tt> on the left side is generally set to
17345e5a 9597work as a Meta key.
a0c0a00f 9598The <tt class="key">ALT</tt> key on the right may also be configured to work as a
17345e5a
JA
9599Meta key or may be configured as some other modifier, such as a
9600Compose key for typing accented characters.
a0c0a00f
CR
9601</p>
9602<p>If you do not have a Meta or <tt class="key">ALT</tt> key, or another key working as
9603a Meta key, the identical keystroke can be generated by typing <tt class="key">ESC</tt>
9604<em>first</em>, and then typing <tt class="key">k</tt>.
9605Either process is known as <em>metafying</em> the <tt class="key">k</tt> key.
9606</p>
9607<p>The text <kbd>M-C-k</kbd> is read as &lsquo;Meta-Control-k&rsquo; and describes the
9608character produced by <em>metafying</em> <kbd>C-k</kbd>.
9609</p>
9610<p>In addition, several keys have their own names. Specifically,
9611<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
17345e5a 9612stand for themselves when seen in this text, or in an init file
a0c0a00f
CR
9613(see <a href="#Readline-Init-File">Readline Init File</a>).
9614If your keyboard lacks a <tt class="key">LFD</tt> key, typing <tt class="key">C-j</tt> will
17345e5a 9615produce the desired character.
a0c0a00f 9616The <tt class="key">RET</tt> key may be labeled <tt class="key">Return</tt> or <tt class="key">Enter</tt> on
17345e5a 9617some keyboards.
a0c0a00f
CR
9618</p>
9619<hr>
9620<a name="Readline-Interaction"></a>
9621<div class="header">
9622<p>
9623Next: <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>
9624</div>
9625<a name="Readline-Interaction-1"></a>
9626<h3 class="section">8.2 Readline Interaction</h3>
9627<a name="index-interaction_002c-readline"></a>
9628
9629<p>Often during an interactive session you type in a long line of text,
17345e5a
JA
9630only to notice that the first word on the line is misspelled. The
9631Readline library gives you a set of commands for manipulating the text
9632as you type it in, allowing you to just fix your typo, and not forcing
9633you to retype the majority of the line. Using these editing commands,
9634you move the cursor to the place that needs correction, and delete or
9635insert the text of the corrections. Then, when you are satisfied with
a0c0a00f
CR
9636the line, you simply press <tt class="key">RET</tt>. You do not have to be at the
9637end of the line to press <tt class="key">RET</tt>; the entire line is accepted
17345e5a 9638regardless of the location of the cursor within the line.
a0c0a00f
CR
9639</p>
9640<table class="menu" border="0" cellspacing="0">
9641<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.
9642</td></tr>
9643<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.
9644</td></tr>
9645<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!
9646</td></tr>
9647<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.
9648</td></tr>
9649<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.
9650</td></tr>
9651</table>
9652
9653<hr>
9654<a name="Readline-Bare-Essentials"></a>
9655<div class="header">
9656<p>
9657Next: <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>
9658</div>
9659<a name="Readline-Bare-Essentials-1"></a>
9660<h4 class="subsection">8.2.1 Readline Bare Essentials</h4>
9661<a name="index-notation_002c-readline"></a>
9662<a name="index-command-editing"></a>
9663<a name="index-editing-command-lines"></a>
9664
9665<p>In order to enter characters into the line, simply type them. The typed
17345e5a
JA
9666character appears where the cursor was, and then the cursor moves one
9667space to the right. If you mistype a character, you can use your
9668erase character to back up and delete the mistyped character.
a0c0a00f
CR
9669</p>
9670<p>Sometimes you may mistype a character, and
17345e5a 9671not notice the error until you have typed several other characters. In
a0c0a00f 9672that case, you can type <kbd>C-b</kbd> to move the cursor to the left, and then
17345e5a 9673correct your mistake. Afterwards, you can move the cursor to the right
a0c0a00f
CR
9674with <kbd>C-f</kbd>.
9675</p>
9676<p>When you add text in the middle of a line, you will notice that characters
9677to the right of the cursor are &lsquo;pushed over&rsquo; to make room for the text
17345e5a 9678that you have inserted. Likewise, when you delete text behind the cursor,
a0c0a00f 9679characters to the right of the cursor are &lsquo;pulled back&rsquo; to fill in the
17345e5a
JA
9680blank space created by the removal of the text. A list of the bare
9681essentials for editing the text of an input line follows.
a0c0a00f
CR
9682</p>
9683<dl compact="compact">
9684<dt><kbd>C-b</kbd></dt>
9685<dd><p>Move back one character.
9686</p></dd>
9687<dt><kbd>C-f</kbd></dt>
9688<dd><p>Move forward one character.
9689</p></dd>
9690<dt><tt class="key">DEL</tt> or <tt class="key">Backspace</tt></dt>
9691<dd><p>Delete the character to the left of the cursor.
9692</p></dd>
9693<dt><kbd>C-d</kbd></dt>
9694<dd><p>Delete the character underneath the cursor.
9695</p></dd>
9696<dt>Printing&nbsp;characters<!-- /@w --></dt>
9697<dd><p>Insert the character into the line at the cursor.
9698</p></dd>
9699<dt><kbd>C-_</kbd> or <kbd>C-x C-u</kbd></dt>
9700<dd><p>Undo the last editing command. You can undo all the way back to an
17345e5a 9701empty line.
a0c0a00f
CR
9702</p></dd>
9703</dl>
17345e5a 9704
a0c0a00f
CR
9705<p>(Depending on your configuration, the <tt class="key">Backspace</tt> key be set to
9706delete the character to the left of the cursor and the <tt class="key">DEL</tt> key set
9707to delete the character underneath the cursor, like <kbd>C-d</kbd>, rather
17345e5a 9708than the character to the left of the cursor.)
a0c0a00f
CR
9709</p>
9710<hr>
9711<a name="Readline-Movement-Commands"></a>
9712<div class="header">
9713<p>
9714Next: <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>
9715</div>
9716<a name="Readline-Movement-Commands-1"></a>
9717<h4 class="subsection">8.2.2 Readline Movement Commands</h4>
9718
9719
9720<p>The above table describes the most basic keystrokes that you need
17345e5a 9721in order to do editing of the input line. For your convenience, many
a0c0a00f
CR
9722other commands have been added in addition to <kbd>C-b</kbd>, <kbd>C-f</kbd>,
9723<kbd>C-d</kbd>, and <tt class="key">DEL</tt>. Here are some commands for moving more rapidly
17345e5a 9724about the line.
a0c0a00f
CR
9725</p>
9726<dl compact="compact">
9727<dt><kbd>C-a</kbd></dt>
9728<dd><p>Move to the start of the line.
9729</p></dd>
9730<dt><kbd>C-e</kbd></dt>
9731<dd><p>Move to the end of the line.
9732</p></dd>
9733<dt><kbd>M-f</kbd></dt>
9734<dd><p>Move forward a word, where a word is composed of letters and digits.
9735</p></dd>
9736<dt><kbd>M-b</kbd></dt>
9737<dd><p>Move backward a word.
9738</p></dd>
9739<dt><kbd>C-l</kbd></dt>
9740<dd><p>Clear the screen, reprinting the current line at the top.
9741</p></dd>
9742</dl>
9743
9744<p>Notice how <kbd>C-f</kbd> moves forward a character, while <kbd>M-f</kbd> moves
17345e5a
JA
9745forward a word. It is a loose convention that control keystrokes
9746operate on characters while meta keystrokes operate on words.
a0c0a00f
CR
9747</p>
9748<hr>
9749<a name="Readline-Killing-Commands"></a>
9750<div class="header">
9751<p>
9752Next: <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>
9753</div>
9754<a name="Readline-Killing-Commands-1"></a>
9755<h4 class="subsection">8.2.3 Readline Killing Commands</h4>
9756
9757<a name="index-killing-text"></a>
9758<a name="index-yanking-text"></a>
9759
9760<p><em>Killing</em> text means to delete the text from the line, but to save
9761it away for later use, usually by <em>yanking</em> (re-inserting)
17345e5a 9762it back into the line.
a0c0a00f
CR
9763(&lsquo;Cut&rsquo; and &lsquo;paste&rsquo; are more recent jargon for &lsquo;kill&rsquo; and &lsquo;yank&rsquo;.)
9764</p>
9765<p>If the description for a command says that it &lsquo;kills&rsquo; text, then you can
17345e5a
JA
9766be sure that you can get the text back in a different (or the same)
9767place later.
a0c0a00f
CR
9768</p>
9769<p>When you use a kill command, the text is saved in a <em>kill-ring</em>.
17345e5a
JA
9770Any number of consecutive kills save all of the killed text together, so
9771that when you yank it back, you get it all. The kill
9772ring is not line specific; the text that you killed on a previously
9773typed line is available to be yanked back later, when you are typing
9774another line.
a0c0a00f
CR
9775<a name="index-kill-ring"></a>
9776</p>
9777<p>Here is the list of commands for killing text.
9778</p>
9779<dl compact="compact">
9780<dt><kbd>C-k</kbd></dt>
9781<dd><p>Kill the text from the current cursor position to the end of the line.
9782</p>
9783</dd>
9784<dt><kbd>M-d</kbd></dt>
9785<dd><p>Kill from the cursor to the end of the current word, or, if between
17345e5a 9786words, to the end of the next word.
a0c0a00f
CR
9787Word boundaries are the same as those used by <kbd>M-f</kbd>.
9788</p>
9789</dd>
9790<dt><kbd>M-<span class="key">DEL</span></kbd></dt>
9791<dd><p>Kill from the cursor the start of the current word, or, if between
17345e5a 9792words, to the start of the previous word.
a0c0a00f
CR
9793Word boundaries are the same as those used by <kbd>M-b</kbd>.
9794</p>
9795</dd>
9796<dt><kbd>C-w</kbd></dt>
9797<dd><p>Kill from the cursor to the previous whitespace. This is different than
9798<kbd>M-<span class="key">DEL</span></kbd> because the word boundaries differ.
9799</p>
9800</dd>
9801</dl>
9802
9803<p>Here is how to <em>yank</em> the text back into the line. Yanking
17345e5a 9804means to copy the most-recently-killed text from the kill buffer.
a0c0a00f
CR
9805</p>
9806<dl compact="compact">
9807<dt><kbd>C-y</kbd></dt>
9808<dd><p>Yank the most recently killed text back into the buffer at the cursor.
9809</p>
9810</dd>
9811<dt><kbd>M-y</kbd></dt>
9812<dd><p>Rotate the kill-ring, and yank the new top. You can only do this if
9813the prior command is <kbd>C-y</kbd> or <kbd>M-y</kbd>.
9814</p></dd>
9815</dl>
9816
9817<hr>
9818<a name="Readline-Arguments"></a>
9819<div class="header">
9820<p>
9821Next: <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>
9822</div>
9823<a name="Readline-Arguments-1"></a>
9824<h4 class="subsection">8.2.4 Readline Arguments</h4>
9825
9826<p>You can pass numeric arguments to Readline commands. Sometimes the
9827argument acts as a repeat count, other times it is the <i>sign</i> of the
17345e5a
JA
9828argument that is significant. If you pass a negative argument to a
9829command which normally acts in a forward direction, that command will
9830act in a backward direction. For example, to kill text back to the
a0c0a00f
CR
9831start of the line, you might type &lsquo;<samp>M-- C-k</samp>&rsquo;.
9832</p>
9833<p>The general way to pass numeric arguments to a command is to type meta
9834digits before the command. If the first &lsquo;digit&rsquo; typed is a minus
9835sign (&lsquo;<samp>-</samp>&rsquo;), then the sign of the argument will be negative. Once
17345e5a
JA
9836you have typed one meta digit to get the argument started, you can type
9837the remainder of the digits, and then the command. For example, to give
a0c0a00f 9838the <kbd>C-d</kbd> command an argument of 10, you could type &lsquo;<samp>M-1 0 C-d</samp>&rsquo;,
17345e5a 9839which will delete the next ten characters on the input line.
a0c0a00f
CR
9840</p>
9841<hr>
9842<a name="Searching"></a>
9843<div class="header">
9844<p>
9845Previous: <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>
9846</div>
9847<a name="Searching-for-Commands-in-the-History"></a>
9848<h4 class="subsection">8.2.5 Searching for Commands in the History</h4>
9849
9850<p>Readline provides commands for searching through the command history
9851(see <a href="#Bash-History-Facilities">Bash History Facilities</a>)
17345e5a 9852for lines containing a specified string.
a0c0a00f
CR
9853There are two search modes: <em>incremental</em> and <em>non-incremental</em>.
9854</p>
9855<p>Incremental searches begin before the user has finished typing the
17345e5a
JA
9856search string.
9857As each character of the search string is typed, Readline displays
9858the next entry from the history matching the string typed so far.
9859An incremental search requires only as many characters as needed to
9860find the desired history entry.
9861To search backward in the history for a particular string, type
a0c0a00f
CR
9862<kbd>C-r</kbd>. Typing <kbd>C-s</kbd> searches forward through the history.
9863The characters present in the value of the <code>isearch-terminators</code> variable
17345e5a 9864are used to terminate an incremental search.
a0c0a00f
CR
9865If that variable has not been assigned a value, the <tt class="key">ESC</tt> and
9866<kbd>C-J</kbd> characters will terminate an incremental search.
9867<kbd>C-g</kbd> will abort an incremental search and restore the original line.
17345e5a
JA
9868When the search is terminated, the history entry containing the
9869search string becomes the current line.
a0c0a00f
CR
9870</p>
9871<p>To find other matching entries in the history list, type <kbd>C-r</kbd> or
9872<kbd>C-s</kbd> as appropriate.
17345e5a
JA
9873This will search backward or forward in the history for the next
9874entry matching the search string typed so far.
9875Any other key sequence bound to a Readline command will terminate
9876the search and execute that command.
a0c0a00f 9877For instance, a <tt class="key">RET</tt> will terminate the search and accept
17345e5a
JA
9878the line, thereby executing the command from the history list.
9879A movement command will terminate the search, make the last line found
9880the current line, and begin editing.
a0c0a00f
CR
9881</p>
9882<p>Readline remembers the last incremental search string. If two
9883<kbd>C-r</kbd>s are typed without any intervening characters defining a new
17345e5a 9884search string, any remembered search string is used.
a0c0a00f
CR
9885</p>
9886<p>Non-incremental searches read the entire search string before starting
17345e5a
JA
9887to search for matching history lines. The search string may be
9888typed by the user or be part of the contents of the current line.
a0c0a00f
CR
9889</p>
9890<hr>
9891<a name="Readline-Init-File"></a>
9892<div class="header">
9893<p>
9894Next: <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>
9895</div>
9896<a name="Readline-Init-File-1"></a>
9897<h3 class="section">8.3 Readline Init File</h3>
9898<a name="index-initialization-file_002c-readline"></a>
9899
9900<p>Although the Readline library comes with a set of Emacs-like
17345e5a
JA
9901keybindings installed by default, it is possible to use a different set
9902of keybindings.
9903Any user can customize programs that use Readline by putting
a0c0a00f 9904commands in an <em>inputrc</em> file, conventionally in his home directory.
17345e5a 9905The name of this
a0c0a00f
CR
9906file is taken from the value of the shell variable <code>INPUTRC</code>. If
9907that variable is unset, the default is <samp>~/.inputrc</samp>. If that
17345e5a 9908file does not exist or cannot be read, the ultimate default is
a0c0a00f
CR
9909<samp>/etc/inputrc</samp>.
9910</p>
9911<p>When a program which uses the Readline library starts up, the
17345e5a 9912init file is read, and the key bindings are set.
a0c0a00f
CR
9913</p>
9914<p>In addition, the <code>C-x C-r</code> command re-reads this init file, thus
17345e5a 9915incorporating any changes that you might have made to it.
a0c0a00f
CR
9916</p>
9917<table class="menu" border="0" cellspacing="0">
9918<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.
9919</td></tr>
9920<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
9921
9922</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.
9923</td></tr>
9924<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
9925
9926</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.
9927</td></tr>
9928</table>
9929
9930<hr>
9931<a name="Readline-Init-File-Syntax"></a>
9932<div class="header">
9933<p>
9934Next: <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>
9935</div>
9936<a name="Readline-Init-File-Syntax-1"></a>
9937<h4 class="subsection">8.3.1 Readline Init File Syntax</h4>
9938
9939<p>There are only a few basic constructs allowed in the
17345e5a 9940Readline init file. Blank lines are ignored.
a0c0a00f
CR
9941Lines beginning with a &lsquo;<samp>#</samp>&rsquo; are comments.
9942Lines beginning with a &lsquo;<samp>$</samp>&rsquo; indicate conditional
9943constructs (see <a href="#Conditional-Init-Constructs">Conditional Init Constructs</a>). Other lines
17345e5a 9944denote variable settings and key bindings.
a0c0a00f
CR
9945</p>
9946<dl compact="compact">
9947<dt>Variable Settings</dt>
9948<dd><p>You can modify the run-time behavior of Readline by
17345e5a 9949altering the values of variables in Readline
a0c0a00f 9950using the <code>set</code> command within the init file.
17345e5a 9951The syntax is simple:
a0c0a00f
CR
9952</p>
9953<div class="example">
9954<pre class="example">set <var>variable</var> <var>value</var>
9955</pre></div>
17345e5a 9956
a0c0a00f 9957<p>Here, for example, is how to
17345e5a 9958change from the default Emacs-like key binding to use
a0c0a00f
CR
9959<code>vi</code> line editing commands:
9960</p>
9961<div class="example">
9962<pre class="example">set editing-mode vi
9963</pre></div>
17345e5a 9964
a0c0a00f 9965<p>Variable names and values, where appropriate, are recognized without regard
17345e5a 9966to case. Unrecognized variable names are ignored.
a0c0a00f
CR
9967</p>
9968<p>Boolean variables (those that can be set to on or off) are set to on if
9969the value is null or empty, <var>on</var> (case-insensitive), or 1. Any other
17345e5a 9970value results in the variable being set to off.
a0c0a00f
CR
9971</p>
9972<p>The <code>bind&nbsp;<span class="nolinebreak">-V</span></code><!-- /@w --> command lists the current Readline variable names
9973and values. See <a href="#Bash-Builtins">Bash Builtins</a>.
9974</p>
9975<p>A great deal of run-time behavior is changeable with the following
17345e5a 9976variables.
a0c0a00f
CR
9977</p>
9978<a name="index-variables_002c-readline"></a>
9979<dl compact="compact">
9980<dt><code>bell-style</code></dt>
9981<dd><a name="index-bell_002dstyle"></a>
9982<p>Controls what happens when Readline wants to ring the terminal bell.
9983If set to &lsquo;<samp>none</samp>&rsquo;, Readline never rings the bell. If set to
9984&lsquo;<samp>visible</samp>&rsquo;, Readline uses a visible bell if one is available.
9985If set to &lsquo;<samp>audible</samp>&rsquo; (the default), Readline attempts to ring
9986the terminal&rsquo;s bell.
9987</p>
9988</dd>
9989<dt><code>bind-tty-special-chars</code></dt>
9990<dd><a name="index-bind_002dtty_002dspecial_002dchars"></a>
9991<p>If set to &lsquo;<samp>on</samp>&rsquo; (the default), Readline attempts to bind the control
9992characters treated specially by the kernel&rsquo;s terminal driver to their
9993Readline equivalents.
9994</p>
9995</dd>
9996<dt><code>blink-matching-paren</code></dt>
9997<dd><a name="index-blink_002dmatching_002dparen"></a>
9998<p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline attempts to briefly move the cursor to an
9999opening parenthesis when a closing parenthesis is inserted. The default
10000is &lsquo;<samp>off</samp>&rsquo;.
10001</p>
10002</dd>
10003<dt><code>colored-completion-prefix</code></dt>
10004<dd><a name="index-colored_002dcompletion_002dprefix"></a>
10005<p>If set to &lsquo;<samp>on</samp>&rsquo;, when listing completions, Readline displays the
10006common prefix of the set of possible completions using a different color.
10007The color definitions are taken from the value of the <code>LS_COLORS</code>
10008environment variable.
10009The default is &lsquo;<samp>off</samp>&rsquo;.
10010</p>
10011</dd>
10012<dt><code>colored-stats</code></dt>
10013<dd><a name="index-colored_002dstats"></a>
10014<p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline displays possible completions using different
ac50fbac 10015colors to indicate their file type.
a0c0a00f 10016The color definitions are taken from the value of the <code>LS_COLORS</code>
ac50fbac 10017environment variable.
a0c0a00f
CR
10018The default is &lsquo;<samp>off</samp>&rsquo;.
10019</p>
10020</dd>
10021<dt><code>comment-begin</code></dt>
10022<dd><a name="index-comment_002dbegin"></a>
10023<p>The string to insert at the beginning of the line when the
10024<code>insert-comment</code> command is executed. The default value
10025is <code>&quot;#&quot;</code>.
10026</p>
10027</dd>
10028<dt><code>completion-display-width</code></dt>
10029<dd><a name="index-completion_002ddisplay_002dwidth"></a>
10030<p>The number of screen columns used to display possible matches
495aee44
CR
10031when performing completion.
10032The value is ignored if it is less than 0 or greater than the terminal
10033screen width.
10034A value of 0 will cause matches to be displayed one per line.
10035The default value is -1.
a0c0a00f
CR
10036</p>
10037</dd>
10038<dt><code>completion-ignore-case</code></dt>
10039<dd><a name="index-completion_002dignore_002dcase"></a>
10040<p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline performs filename matching and completion
17345e5a 10041in a case-insensitive fashion.
a0c0a00f
CR
10042The default value is &lsquo;<samp>off</samp>&rsquo;.
10043</p>
10044</dd>
10045<dt><code>completion-map-case</code></dt>
10046<dd><a name="index-completion_002dmap_002dcase"></a>
10047<p>If set to &lsquo;<samp>on</samp>&rsquo;, and <var>completion-ignore-case</var> is enabled, Readline
10048treats hyphens (&lsquo;<samp>-</samp>&rsquo;) and underscores (&lsquo;<samp>_</samp>&rsquo;) as equivalent when
495aee44 10049performing case-insensitive filename matching and completion.
2f5dfe5a 10050The default value is &lsquo;<samp>off</samp>&rsquo;.
a0c0a00f
CR
10051</p>
10052</dd>
10053<dt><code>completion-prefix-display-length</code></dt>
10054<dd><a name="index-completion_002dprefix_002ddisplay_002dlength"></a>
10055<p>The length in characters of the common prefix of a list of possible
17345e5a
JA
10056completions that is displayed without modification. When set to a
10057value greater than zero, common prefixes longer than this value are
10058replaced with an ellipsis when displaying possible completions.
a0c0a00f
CR
10059</p>
10060</dd>
10061<dt><code>completion-query-items</code></dt>
10062<dd><a name="index-completion_002dquery_002ditems"></a>
10063<p>The number of possible completions that determines when the user is
17345e5a
JA
10064asked whether the list of possibilities should be displayed.
10065If the number of possible completions is greater than this value,
10066Readline will ask the user whether or not he wishes to view
10067them; otherwise, they are simply listed.
10068This variable must be set to an integer value greater than or equal to 0.
10069A negative value means Readline should never ask.
a0c0a00f
CR
10070The default limit is <code>100</code>.
10071</p>
10072</dd>
10073<dt><code>convert-meta</code></dt>
10074<dd><a name="index-convert_002dmeta"></a>
10075<p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline will convert characters with the
10076eighth bit set to an <small>ASCII</small> key sequence by stripping the eighth
10077bit and prefixing an <tt class="key">ESC</tt> character, converting them to a
10078meta-prefixed key sequence. The default value is &lsquo;<samp>on</samp>&rsquo;, but
10079will be set to &lsquo;<samp>off</samp>&rsquo; if the locale is one that contains
10080eight-bit characters.
10081</p>
10082</dd>
10083<dt><code>disable-completion</code></dt>
10084<dd><a name="index-disable_002dcompletion"></a>
10085<p>If set to &lsquo;<samp>On</samp>&rsquo;, Readline will inhibit word completion.
17345e5a 10086Completion characters will be inserted into the line as if they had
a0c0a00f
CR
10087been mapped to <code>self-insert</code>. The default is &lsquo;<samp>off</samp>&rsquo;.
10088</p>
10089</dd>
10090<dt><code>echo-control-characters</code></dt>
10091<dd><a name="index-echo_002dcontrol_002dcharacters"></a>
10092<p>When set to &lsquo;<samp>on</samp>&rsquo;, on operating systems that indicate they support it,
10093readline echoes a character corresponding to a signal generated from the
10094keyboard. The default is &lsquo;<samp>on</samp>&rsquo;.
10095</p>
10096</dd>
10097<dt><code>editing-mode</code></dt>
10098<dd><a name="index-editing_002dmode"></a>
10099<p>The <code>editing-mode</code> variable controls which default set of
17345e5a
JA
10100key bindings is used. By default, Readline starts up in Emacs editing
10101mode, where the keystrokes are most similar to Emacs. This variable can be
a0c0a00f
CR
10102set to either &lsquo;<samp>emacs</samp>&rsquo; or &lsquo;<samp>vi</samp>&rsquo;.
10103</p>
10104</dd>
10105<dt><code>emacs-mode-string</code></dt>
10106<dd><a name="index-emacs_002dmode_002dstring"></a>
9a51695b
CR
10107<p>If the <var>show-mode-in-prompt</var> variable is enabled,
10108this string is displayed immediately before the last line of the primary
a0c0a00f
CR
10109prompt when emacs editing mode is active. The value is expanded like a
10110key binding, so the standard set of meta- and control prefixes and
10111backslash escape sequences is available.
10112Use the &lsquo;<samp>\1</samp>&rsquo; and &lsquo;<samp>\2</samp>&rsquo; escapes to begin and end sequences of
10113non-printing characters, which can be used to embed a terminal control
10114sequence into the mode string.
10115The default is &lsquo;<samp>@</samp>&rsquo;.
10116</p>
10117</dd>
10118<dt><code>enable-bracketed-paste</code></dt>
10119<dd><a name="index-enable_002dbracketed_002dpaste"></a>
10120<p>When set to &lsquo;<samp>On</samp>&rsquo;, Readline will configure the terminal in a way
10121that will enable it to insert each paste into the editing buffer as a
10122single string of characters, instead of treating each character as if
10123it had been read from the keyboard. This can prevent pasted characters
10124from being interpreted as editing commands. The default is &lsquo;<samp>off</samp>&rsquo;.
10125</p>
10126</dd>
10127<dt><code>enable-keypad</code></dt>
10128<dd><a name="index-enable_002dkeypad"></a>
10129<p>When set to &lsquo;<samp>on</samp>&rsquo;, Readline will try to enable the application
17345e5a 10130keypad when it is called. Some systems need this to enable the
a0c0a00f
CR
10131arrow keys. The default is &lsquo;<samp>off</samp>&rsquo;.
10132</p>
10133</dd>
10134<dt><code>enable-meta-key</code></dt>
10135<dd><p>When set to &lsquo;<samp>on</samp>&rsquo;, Readline will try to enable any meta modifier
0001803f
CR
10136key the terminal claims to support when it is called. On many terminals,
10137the meta key is used to send eight-bit characters.
a0c0a00f
CR
10138The default is &lsquo;<samp>on</samp>&rsquo;.
10139</p>
10140</dd>
10141<dt><code>expand-tilde</code></dt>
10142<dd><a name="index-expand_002dtilde"></a>
10143<p>If set to &lsquo;<samp>on</samp>&rsquo;, tilde expansion is performed when Readline
10144attempts word completion. The default is &lsquo;<samp>off</samp>&rsquo;.
10145</p>
10146</dd>
10147<dt><code>history-preserve-point</code></dt>
10148<dd><a name="index-history_002dpreserve_002dpoint"></a>
10149<p>If set to &lsquo;<samp>on</samp>&rsquo;, the history code attempts to place the point (the
17345e5a 10150current cursor position) at the
a0c0a00f
CR
10151same location on each history line retrieved with <code>previous-history</code>
10152or <code>next-history</code>. The default is &lsquo;<samp>off</samp>&rsquo;.
10153</p>
10154</dd>
10155<dt><code>history-size</code></dt>
10156<dd><a name="index-history_002dsize"></a>
10157<p>Set the maximum number of history entries saved in the history list.
ac50fbac
CR
10158If set to zero, any existing history entries are deleted and no new entries
10159are saved.
10160If set to a value less than zero, the number of history entries is not
10161limited.
10162By default, the number of history entries is not limited.
a0c0a00f
CR
10163If an attempt is made to set <var>history-size</var> to a non-numeric value,
10164the maximum number of history entries will be set to 500.
10165</p>
10166</dd>
10167<dt><code>horizontal-scroll-mode</code></dt>
10168<dd><a name="index-horizontal_002dscroll_002dmode"></a>
10169<p>This variable can be set to either &lsquo;<samp>on</samp>&rsquo; or &lsquo;<samp>off</samp>&rsquo;. Setting it
10170to &lsquo;<samp>on</samp>&rsquo; means that the text of the lines being edited will scroll
17345e5a
JA
10171horizontally on a single screen line when they are longer than the width
10172of the screen, instead of wrapping onto a new screen line. By default,
a0c0a00f
CR
10173this variable is set to &lsquo;<samp>off</samp>&rsquo;.
10174</p>
10175</dd>
10176<dt><code>input-meta</code></dt>
10177<dd><a name="index-input_002dmeta"></a>
10178<a name="index-meta_002dflag"></a>
10179<p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline will enable eight-bit input (it
17345e5a
JA
10180will not clear the eighth bit in the characters it reads),
10181regardless of what the terminal claims it can support. The
a0c0a00f
CR
10182default value is &lsquo;<samp>off</samp>&rsquo;, but Readline will set it to &lsquo;<samp>on</samp>&rsquo; if the
10183locale contains eight-bit characters.
10184The name <code>meta-flag</code> is a synonym for this variable.
10185</p>
10186</dd>
10187<dt><code>isearch-terminators</code></dt>
10188<dd><a name="index-isearch_002dterminators"></a>
10189<p>The string of characters that should terminate an incremental search without
10190subsequently executing the character as a command (see <a href="#Searching">Searching</a>).
10191If this variable has not been given a value, the characters <tt class="key">ESC</tt> and
10192<kbd>C-J</kbd> will terminate an incremental search.
10193</p>
10194</dd>
10195<dt><code>keymap</code></dt>
10196<dd><a name="index-keymap"></a>
10197<p>Sets Readline&rsquo;s idea of the current keymap for key binding commands.
10198Acceptable <code>keymap</code> names are
10199<code>emacs</code>,
10200<code>emacs-standard</code>,
10201<code>emacs-meta</code>,
10202<code>emacs-ctlx</code>,
10203<code>vi</code>,
10204<code>vi-move</code>,
10205<code>vi-command</code>, and
10206<code>vi-insert</code>.
10207<code>vi</code> is equivalent to <code>vi-command</code> (<code>vi-move</code> is also a
10208synonym); <code>emacs</code> is equivalent to <code>emacs-standard</code>.
10209The default value is <code>emacs</code>.
10210The value of the <code>editing-mode</code> variable also affects the
17345e5a 10211default keymap.
a0c0a00f
CR
10212</p>
10213</dd>
10214<dt><code>keyseq-timeout</code></dt>
10215<dd><p>Specifies the duration Readline will wait for a character when reading an
ac50fbac
CR
10216ambiguous key sequence (one that can form a complete key sequence using
10217the input read so far, or can take additional input to complete a longer
10218key sequence).
10219If no input is received within the timeout, Readline will use the shorter
10220but complete key sequence.
10221Readline uses this value to determine whether or not input is
a0c0a00f 10222available on the current input source (<code>rl_instream</code> by default).
ac50fbac
CR
10223The value is specified in milliseconds, so a value of 1000 means that
10224Readline will wait one second for additional input.
10225If this variable is set to a value less than or equal to zero, or to a
10226non-numeric value, Readline will wait until another key is pressed to
10227decide which key sequence to complete.
a0c0a00f
CR
10228The default value is <code>500</code>.
10229</p>
10230</dd>
10231<dt><code>mark-directories</code></dt>
10232<dd><p>If set to &lsquo;<samp>on</samp>&rsquo;, completed directory names have a slash
10233appended. The default is &lsquo;<samp>on</samp>&rsquo;.
10234</p>
10235</dd>
10236<dt><code>mark-modified-lines</code></dt>
10237<dd><a name="index-mark_002dmodified_002dlines"></a>
10238<p>This variable, when set to &lsquo;<samp>on</samp>&rsquo;, causes Readline to display an
10239asterisk (&lsquo;<samp>*</samp>&rsquo;) at the start of history lines which have been modified.
10240This variable is &lsquo;<samp>off</samp>&rsquo; by default.
10241</p>
10242</dd>
10243<dt><code>mark-symlinked-directories</code></dt>
10244<dd><a name="index-mark_002dsymlinked_002ddirectories"></a>
10245<p>If set to &lsquo;<samp>on</samp>&rsquo;, completed names which are symbolic links
17345e5a 10246to directories have a slash appended (subject to the value of
a0c0a00f
CR
10247<code>mark-directories</code>).
10248The default is &lsquo;<samp>off</samp>&rsquo;.
10249</p>
10250</dd>
10251<dt><code>match-hidden-files</code></dt>
10252<dd><a name="index-match_002dhidden_002dfiles"></a>
10253<p>This variable, when set to &lsquo;<samp>on</samp>&rsquo;, causes Readline to match files whose
10254names begin with a &lsquo;<samp>.</samp>&rsquo; (hidden files) when performing filename
495aee44 10255completion.
a0c0a00f 10256If set to &lsquo;<samp>off</samp>&rsquo;, the leading &lsquo;<samp>.</samp>&rsquo; must be
17345e5a 10257supplied by the user in the filename to be completed.
a0c0a00f
CR
10258This variable is &lsquo;<samp>on</samp>&rsquo; by default.
10259</p>
10260</dd>
10261<dt><code>menu-complete-display-prefix</code></dt>
10262<dd><a name="index-menu_002dcomplete_002ddisplay_002dprefix"></a>
10263<p>If set to &lsquo;<samp>on</samp>&rsquo;, menu completion displays the common prefix of the
495aee44 10264list of possible completions (which may be empty) before cycling through
a0c0a00f
CR
10265the list. The default is &lsquo;<samp>off</samp>&rsquo;.
10266</p>
10267</dd>
10268<dt><code>output-meta</code></dt>
10269<dd><a name="index-output_002dmeta"></a>
10270<p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline will display characters with the
17345e5a 10271eighth bit set directly rather than as a meta-prefixed escape
a0c0a00f
CR
10272sequence.
10273The default is &lsquo;<samp>off</samp>&rsquo;, but Readline will set it to &lsquo;<samp>on</samp>&rsquo; if the
10274locale contains eight-bit characters.
10275</p>
10276</dd>
10277<dt><code>page-completions</code></dt>
10278<dd><a name="index-page_002dcompletions"></a>
10279<p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline uses an internal <code>more</code>-like pager
17345e5a 10280to display a screenful of possible completions at a time.
a0c0a00f
CR
10281This variable is &lsquo;<samp>on</samp>&rsquo; by default.
10282</p>
10283</dd>
10284<dt><code>print-completions-horizontally</code></dt>
10285<dd><p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline will display completions with matches
17345e5a 10286sorted horizontally in alphabetical order, rather than down the screen.
a0c0a00f
CR
10287The default is &lsquo;<samp>off</samp>&rsquo;.
10288</p>
10289</dd>
10290<dt><code>revert-all-at-newline</code></dt>
10291<dd><a name="index-revert_002dall_002dat_002dnewline"></a>
10292<p>If set to &lsquo;<samp>on</samp>&rsquo;, Readline will undo all changes to history lines
10293before returning when <code>accept-line</code> is executed. By default,
17345e5a 10294history lines may be modified and retain individual undo lists across
a0c0a00f
CR
10295calls to <code>readline</code>. The default is &lsquo;<samp>off</samp>&rsquo;.
10296</p>
10297</dd>
10298<dt><code>show-all-if-ambiguous</code></dt>
10299<dd><a name="index-show_002dall_002dif_002dambiguous"></a>
10300<p>This alters the default behavior of the completion functions. If
10301set to &lsquo;<samp>on</samp>&rsquo;,
17345e5a
JA
10302words which have more than one possible completion cause the
10303matches to be listed immediately instead of ringing the bell.
a0c0a00f
CR
10304The default value is &lsquo;<samp>off</samp>&rsquo;.
10305</p>
10306</dd>
10307<dt><code>show-all-if-unmodified</code></dt>
10308<dd><a name="index-show_002dall_002dif_002dunmodified"></a>
10309<p>This alters the default behavior of the completion functions in
10310a fashion similar to <var>show-all-if-ambiguous</var>.
10311If set to &lsquo;<samp>on</samp>&rsquo;,
17345e5a 10312words which have more than one possible completion without any
a0c0a00f 10313possible partial completion (the possible completions don&rsquo;t share
17345e5a
JA
10314a common prefix) cause the matches to be listed immediately instead
10315of ringing the bell.
a0c0a00f
CR
10316The default value is &lsquo;<samp>off</samp>&rsquo;.
10317</p>
10318</dd>
10319<dt><code>show-mode-in-prompt</code></dt>
10320<dd><a name="index-show_002dmode_002din_002dprompt"></a>
9a51695b 10321<p>If set to &lsquo;<samp>on</samp>&rsquo;, add a string to the beginning of the prompt
a0c0a00f 10322indicating the editing mode: emacs, vi command, or vi insertion.
9a51695b 10323The mode strings are user-settable (e.g., <var>emacs-mode-string</var>).
a0c0a00f
CR
10324The default value is &lsquo;<samp>off</samp>&rsquo;.
10325</p>
10326</dd>
10327<dt><code>skip-completed-text</code></dt>
10328<dd><a name="index-skip_002dcompleted_002dtext"></a>
10329<p>If set to &lsquo;<samp>on</samp>&rsquo;, this alters the default completion behavior when
10330inserting a single match into the line. It&rsquo;s only active when
0001803f
CR
10331performing completion in the middle of a word. If enabled, readline
10332does not insert characters from the completion that match characters
10333after point in the word being completed, so portions of the word
10334following the cursor are not duplicated.
10335For instance, if this is enabled, attempting completion when the cursor
a0c0a00f
CR
10336is after the &lsquo;<samp>e</samp>&rsquo; in &lsquo;<samp>Makefile</samp>&rsquo; will result in &lsquo;<samp>Makefile</samp>&rsquo;
10337rather than &lsquo;<samp>Makefilefile</samp>&rsquo;, assuming there is a single possible
0001803f 10338completion.
a0c0a00f
CR
10339The default value is &lsquo;<samp>off</samp>&rsquo;.
10340</p>
10341</dd>
10342<dt><code>vi-cmd-mode-string</code></dt>
10343<dd><a name="index-vi_002dcmd_002dmode_002dstring"></a>
9a51695b
CR
10344<p>If the <var>show-mode-in-prompt</var> variable is enabled,
10345this string is displayed immediately before the last line of the primary
a0c0a00f
CR
10346prompt when vi editing mode is active and in command mode.
10347The value is expanded like a
10348key binding, so the standard set of meta- and control prefixes and
10349backslash escape sequences is available.
10350Use the &lsquo;<samp>\1</samp>&rsquo; and &lsquo;<samp>\2</samp>&rsquo; escapes to begin and end sequences of
10351non-printing characters, which can be used to embed a terminal control
10352sequence into the mode string.
10353The default is &lsquo;<samp>(cmd)</samp>&rsquo;.
10354</p>
10355</dd>
10356<dt><code>vi-ins-mode-string</code></dt>
10357<dd><a name="index-vi_002dins_002dmode_002dstring"></a>
9a51695b
CR
10358<p>If the <var>show-mode-in-prompt</var> variable is enabled,
10359this string is displayed immediately before the last line of the primary
a0c0a00f
CR
10360prompt when vi editing mode is active and in insertion mode.
10361The value is expanded like a
10362key binding, so the standard set of meta- and control prefixes and
10363backslash escape sequences is available.
10364Use the &lsquo;<samp>\1</samp>&rsquo; and &lsquo;<samp>\2</samp>&rsquo; escapes to begin and end sequences of
10365non-printing characters, which can be used to embed a terminal control
10366sequence into the mode string.
10367The default is &lsquo;<samp>(ins)</samp>&rsquo;.
10368</p>
10369</dd>
10370<dt><code>visible-stats</code></dt>
10371<dd><a name="index-visible_002dstats"></a>
10372<p>If set to &lsquo;<samp>on</samp>&rsquo;, a character denoting a file&rsquo;s type
17345e5a 10373is appended to the filename when listing possible
a0c0a00f
CR
10374completions. The default is &lsquo;<samp>off</samp>&rsquo;.
10375</p>
10376</dd>
10377</dl>
10378
10379</dd>
10380<dt>Key Bindings</dt>
10381<dd><p>The syntax for controlling key bindings in the init file is
17345e5a
JA
10382simple. First you need to find the name of the command that you
10383want to change. The following sections contain tables of the command
10384name, the default keybinding, if any, and a short description of what
10385the command does.
a0c0a00f
CR
10386</p>
10387<p>Once you know the name of the command, simply place on a line
17345e5a
JA
10388in the init file the name of the key
10389you wish to bind the command to, a colon, and then the name of the
10390command.
a0c0a00f 10391There can be no space between the key name and the colon &ndash; that will be
17345e5a
JA
10392interpreted as part of the key name.
10393The name of the key can be expressed in different ways, depending on
10394what you find most comfortable.
a0c0a00f
CR
10395</p>
10396<p>In addition to command names, readline allows keys to be bound
10397to a string that is inserted when the key is pressed (a <var>macro</var>).
10398</p>
10399<p>The <code>bind&nbsp;<span class="nolinebreak">-p</span></code><!-- /@w --> command displays Readline function names and
17345e5a 10400bindings in a format that can put directly into an initialization file.
a0c0a00f
CR
10401See <a href="#Bash-Builtins">Bash Builtins</a>.
10402</p>
10403<dl compact="compact">
10404<dt><var>keyname</var>:&nbsp;<var><span class="nolinebreak">function-name</span></var>&nbsp;or&nbsp;<var>macro</var><!-- /@w --></dt>
10405<dd><p><var>keyname</var> is the name of a key spelled out in English. For example:
10406</p><div class="example">
10407<pre class="example">Control-u: universal-argument
17345e5a 10408Meta-Rubout: backward-kill-word
a0c0a00f
CR
10409Control-o: &quot;&gt; output&quot;
10410</pre></div>
17345e5a 10411
2f5dfe5a 10412<p>In the example above, <kbd>C-u</kbd> is bound to the function
a0c0a00f
CR
10413<code>universal-argument</code>,
10414<kbd>M-DEL</kbd> is bound to the function <code>backward-kill-word</code>, and
10415<kbd>C-o</kbd> is bound to run the macro
17345e5a 10416expressed on the right hand side (that is, to insert the text
a0c0a00f
CR
10417&lsquo;<samp>&gt; output</samp>&rsquo; into the line).
10418</p>
10419<p>A number of symbolic character names are recognized while
17345e5a 10420processing this key binding syntax:
a0c0a00f
CR
10421<var>DEL</var>,
10422<var>ESC</var>,
10423<var>ESCAPE</var>,
10424<var>LFD</var>,
10425<var>NEWLINE</var>,
10426<var>RET</var>,
10427<var>RETURN</var>,
10428<var>RUBOUT</var>,
10429<var>SPACE</var>,
10430<var>SPC</var>,
17345e5a 10431and
a0c0a00f
CR
10432<var>TAB</var>.
10433</p>
10434</dd>
10435<dt>&quot;<var>keyseq</var>&quot;:&nbsp;<var><span class="nolinebreak">function-name</span></var>&nbsp;or&nbsp;<var>macro</var><!-- /@w --></dt>
10436<dd><p><var>keyseq</var> differs from <var>keyname</var> above in that strings
17345e5a 10437denoting an entire key sequence can be specified, by placing
a0c0a00f 10438the key sequence in double quotes. Some <small>GNU</small> Emacs style key
17345e5a
JA
10439escapes can be used, as in the following example, but the
10440special character names are not recognized.
a0c0a00f
CR
10441</p>
10442<div class="example">
10443<pre class="example">&quot;\C-u&quot;: universal-argument
10444&quot;\C-x\C-r&quot;: re-read-init-file
10445&quot;\e[11~&quot;: &quot;Function Key 1&quot;
10446</pre></div>
10447
10448<p>In the above example, <kbd>C-u</kbd> is again bound to the function
10449<code>universal-argument</code> (just as it was in the first example),
10450&lsquo;<samp><kbd>C-x</kbd> <kbd>C-r</kbd></samp>&rsquo; is bound to the function <code>re-read-init-file</code>,
10451and &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
10452the text &lsquo;<samp>Function Key 1</samp>&rsquo;.
10453</p>
10454</dd>
10455</dl>
10456
10457<p>The following <small>GNU</small> Emacs style escape sequences are available when
17345e5a 10458specifying key sequences:
a0c0a00f
CR
10459</p>
10460<dl compact="compact">
10461<dt><code><kbd>\C-</kbd></code></dt>
10462<dd><p>control prefix
10463</p></dd>
10464<dt><code><kbd>\M-</kbd></code></dt>
10465<dd><p>meta prefix
10466</p></dd>
10467<dt><code><kbd>\e</kbd></code></dt>
10468<dd><p>an escape character
10469</p></dd>
10470<dt><code><kbd>\\</kbd></code></dt>
10471<dd><p>backslash
10472</p></dd>
10473<dt><code><kbd>\&quot;</kbd></code></dt>
10474<dd><p><tt class="key">&quot;</tt>, a double quotation mark
10475</p></dd>
10476<dt><code><kbd>\'</kbd></code></dt>
10477<dd><p><tt class="key">'</tt>, a single quote or apostrophe
10478</p></dd>
10479</dl>
10480
10481<p>In addition to the <small>GNU</small> Emacs style escape sequences, a second
17345e5a 10482set of backslash escapes is available:
a0c0a00f
CR
10483</p>
10484<dl compact="compact">
10485<dt><code>\a</code></dt>
10486<dd><p>alert (bell)
10487</p></dd>
10488<dt><code>\b</code></dt>
10489<dd><p>backspace
10490</p></dd>
10491<dt><code>\d</code></dt>
10492<dd><p>delete
10493</p></dd>
10494<dt><code>\f</code></dt>
10495<dd><p>form feed
10496</p></dd>
10497<dt><code>\n</code></dt>
10498<dd><p>newline
10499</p></dd>
10500<dt><code>\r</code></dt>
10501<dd><p>carriage return
10502</p></dd>
10503<dt><code>\t</code></dt>
10504<dd><p>horizontal tab
10505</p></dd>
10506<dt><code>\v</code></dt>
10507<dd><p>vertical tab
10508</p></dd>
10509<dt><code>\<var>nnn</var></code></dt>
10510<dd><p>the eight-bit character whose value is the octal value <var>nnn</var>
17345e5a 10511(one to three digits)
a0c0a00f
CR
10512</p></dd>
10513<dt><code>\x<var>HH</var></code></dt>
10514<dd><p>the eight-bit character whose value is the hexadecimal value <var>HH</var>
17345e5a 10515(one or two hex digits)
a0c0a00f
CR
10516</p></dd>
10517</dl>
17345e5a 10518
a0c0a00f 10519<p>When entering the text of a macro, single or double quotes must
17345e5a
JA
10520be used to indicate a macro definition.
10521Unquoted text is assumed to be a function name.
10522In the macro body, the backslash escapes described above are expanded.
10523Backslash will quote any other character in the macro text,
a0c0a00f
CR
10524including &lsquo;<samp>&quot;</samp>&rsquo; and &lsquo;<samp>'</samp>&rsquo;.
10525For example, the following binding will make &lsquo;<samp><kbd>C-x</kbd> \</samp>&rsquo;
10526insert a single &lsquo;<samp>\</samp>&rsquo; into the line:
10527</p><div class="example">
10528<pre class="example">&quot;\C-x\\&quot;: &quot;\\&quot;
10529</pre></div>
10530
10531</dd>
10532</dl>
10533
10534<hr>
10535<a name="Conditional-Init-Constructs"></a>
10536<div class="header">
10537<p>
10538Next: <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>
10539</div>
10540<a name="Conditional-Init-Constructs-1"></a>
10541<h4 class="subsection">8.3.2 Conditional Init Constructs</h4>
10542
10543<p>Readline implements a facility similar in spirit to the conditional
17345e5a
JA
10544compilation features of the C preprocessor which allows key
10545bindings and variable settings to be performed as the result
10546of tests. There are four parser directives used.
a0c0a00f
CR
10547</p>
10548<dl compact="compact">
10549<dt><code>$if</code></dt>
10550<dd><p>The <code>$if</code> construct allows bindings to be made based on the
17345e5a 10551editing mode, the terminal being used, or the application using
9a51695b
CR
10552Readline. The text of the test, after any comparison operator,
10553extends to the end of the line;
10554unless otherwise noted, no characters are required to isolate it.
a0c0a00f
CR
10555</p>
10556<dl compact="compact">
10557<dt><code>mode</code></dt>
10558<dd><p>The <code>mode=</code> form of the <code>$if</code> directive is used to test
10559whether Readline is in <code>emacs</code> or <code>vi</code> mode.
17345e5a 10560This may be used in conjunction
a0c0a00f
CR
10561with the &lsquo;<samp>set keymap</samp>&rsquo; command, for instance, to set bindings in
10562the <code>emacs-standard</code> and <code>emacs-ctlx</code> keymaps only if
10563Readline is starting out in <code>emacs</code> mode.
10564</p>
10565</dd>
10566<dt><code>term</code></dt>
10567<dd><p>The <code>term=</code> form may be used to include terminal-specific
17345e5a 10568key bindings, perhaps to bind the key sequences output by the
a0c0a00f
CR
10569terminal&rsquo;s function keys. The word on the right side of the
10570&lsquo;<samp>=</samp>&rsquo; is tested against both the full name of the terminal and
10571the portion of the terminal name before the first &lsquo;<samp>-</samp>&rsquo;. This
10572allows <code>sun</code> to match both <code>sun</code> and <code>sun-cmd</code>,
17345e5a 10573for instance.
a0c0a00f 10574</p>
9a51695b
CR
10575</dd>
10576<dt><code>version</code></dt>
10577<dd><p>The <code>version</code> test may be used to perform comparisons against
10578specific Readline versions.
10579The <code>version</code> expands to the current Readline version.
10580The set of comparison operators includes
10581&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;,
10582and &lsquo;<samp>&gt;</samp>&rsquo;.
10583The version number supplied on the right side of the operator consists
10584of a major version number, an optional decimal point, and an optional
10585minor version (e.g., &lsquo;<samp>7.1</samp>&rsquo;). If the minor version is omitted, it
10586is assumed to be &lsquo;<samp>0</samp>&rsquo;.
10587The operator may be separated from the string <code>version</code> and
10588from the version number argument by whitespace.
10589The following example sets a variable if the Readline version being used
10590is 7.0 or newer:
10591</p><div class="example">
10592<pre class="example">$if version &gt;= 7.0
10593set show-mode-in-prompt on
10594$endif
10595</pre></div>
10596
a0c0a00f
CR
10597</dd>
10598<dt><code>application</code></dt>
10599<dd><p>The <var>application</var> construct is used to include
17345e5a 10600application-specific settings. Each program using the Readline
a0c0a00f 10601library sets the <var>application name</var>, and you can test for
17345e5a
JA
10602a particular value.
10603This could be used to bind key sequences to functions useful for
10604a specific program. For instance, the following command adds a
10605key sequence that quotes the current or previous word in Bash:
a0c0a00f
CR
10606</p><div class="example">
10607<pre class="example">$if Bash
17345e5a 10608# Quote the current or previous word
a0c0a00f 10609&quot;\C-xq&quot;: &quot;\eb\&quot;\ef\&quot;&quot;
17345e5a 10610$endif
a0c0a00f 10611</pre></div>
9a51695b
CR
10612
10613</dd>
10614<dt><code>variable</code></dt>
10615<dd><p>The <var>variable</var> construct provides simple equality tests for Readline
10616variables and values.
10617The permitted comparison operators are &lsquo;<samp>=</samp>&rsquo;, &lsquo;<samp>==</samp>&rsquo;, and &lsquo;<samp>!=</samp>&rsquo;.
10618The variable name must be separated from the comparison operator by
10619whitespace; the operator may be separated from the value on the right hand
10620side by whitespace.
10621Both string and boolean variables may be tested. Boolean variables must be
10622tested against the values <var>on</var> and <var>off</var>.
10623The following example is equivalent to the <code>mode=emacs</code> test described
10624above:
10625</p><div class="example">
10626<pre class="example">$if editing-mode == emacs
10627set show-mode-in-prompt on
10628$endif
10629</pre></div>
a0c0a00f
CR
10630</dd>
10631</dl>
10632
10633</dd>
10634<dt><code>$endif</code></dt>
10635<dd><p>This command, as seen in the previous example, terminates an
10636<code>$if</code> command.
10637</p>
10638</dd>
10639<dt><code>$else</code></dt>
10640<dd><p>Commands in this branch of the <code>$if</code> directive are executed if
17345e5a 10641the test fails.
a0c0a00f
CR
10642</p>
10643</dd>
10644<dt><code>$include</code></dt>
10645<dd><p>This directive takes a single filename as an argument and reads commands
17345e5a 10646and bindings from that file.
a0c0a00f
CR
10647For example, the following directive reads from <samp>/etc/inputrc</samp>:
10648</p><div class="example">
10649<pre class="example">$include /etc/inputrc
10650</pre></div>
10651</dd>
10652</dl>
10653
10654<hr>
10655<a name="Sample-Init-File"></a>
10656<div class="header">
10657<p>
10658Previous: <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>
10659</div>
10660<a name="Sample-Init-File-1"></a>
10661<h4 class="subsection">8.3.3 Sample Init File</h4>
10662
10663<p>Here is an example of an <var>inputrc</var> file. This illustrates key
17345e5a 10664binding, variable assignment, and conditional syntax.
a0c0a00f
CR
10665</p>
10666<div class="example">
10667<pre class="example"># This file controls the behaviour of line input editing for
17345e5a
JA
10668# programs that use the GNU Readline library. Existing
10669# programs include FTP, Bash, and GDB.
10670#
10671# You can re-read the inputrc file with C-x C-r.
10672# Lines beginning with '#' are comments.
10673#
ac50fbac 10674# First, include any system-wide bindings and variable
17345e5a
JA
10675# assignments from /etc/Inputrc
10676$include /etc/Inputrc
10677
10678#
10679# Set various bindings for emacs mode.
10680
10681set editing-mode emacs
10682
10683$if mode=emacs
10684
10685Meta-Control-h: backward-kill-word Text after the function name is ignored
10686
10687#
10688# Arrow keys in keypad mode
10689#
a0c0a00f
CR
10690#&quot;\M-OD&quot;: backward-char
10691#&quot;\M-OC&quot;: forward-char
10692#&quot;\M-OA&quot;: previous-history
10693#&quot;\M-OB&quot;: next-history
17345e5a
JA
10694#
10695# Arrow keys in ANSI mode
10696#
a0c0a00f
CR
10697&quot;\M-[D&quot;: backward-char
10698&quot;\M-[C&quot;: forward-char
10699&quot;\M-[A&quot;: previous-history
10700&quot;\M-[B&quot;: next-history
17345e5a
JA
10701#
10702# Arrow keys in 8 bit keypad mode
10703#
a0c0a00f
CR
10704#&quot;\M-\C-OD&quot;: backward-char
10705#&quot;\M-\C-OC&quot;: forward-char
10706#&quot;\M-\C-OA&quot;: previous-history
10707#&quot;\M-\C-OB&quot;: next-history
17345e5a
JA
10708#
10709# Arrow keys in 8 bit ANSI mode
10710#
a0c0a00f
CR
10711#&quot;\M-\C-[D&quot;: backward-char
10712#&quot;\M-\C-[C&quot;: forward-char
10713#&quot;\M-\C-[A&quot;: previous-history
10714#&quot;\M-\C-[B&quot;: next-history
17345e5a
JA
10715
10716C-q: quoted-insert
10717
10718$endif
10719
10720# An old-style binding. This happens to be the default.
10721TAB: complete
10722
10723# Macros that are convenient for shell interaction
10724$if Bash
10725# edit the path
a0c0a00f 10726&quot;\C-xp&quot;: &quot;PATH=${PATH}\e\C-e\C-a\ef\C-f&quot;
17345e5a
JA
10727# prepare to type a quoted word --
10728# insert open and close double quotes
10729# and move to just after the open quote
a0c0a00f 10730&quot;\C-x\&quot;&quot;: &quot;\&quot;\&quot;\C-b&quot;
17345e5a
JA
10731# insert a backslash (testing backslash escapes
10732# in sequences and macros)
a0c0a00f 10733&quot;\C-x\\&quot;: &quot;\\&quot;
17345e5a 10734# Quote the current or previous word
a0c0a00f 10735&quot;\C-xq&quot;: &quot;\eb\&quot;\ef\&quot;&quot;
17345e5a 10736# Add a binding to refresh the line, which is unbound
a0c0a00f 10737&quot;\C-xr&quot;: redraw-current-line
17345e5a 10738# Edit variable on current line.
a0c0a00f 10739&quot;\M-\C-v&quot;: &quot;\C-a\C-k$\C-y\M-\C-e\C-a\C-y=&quot;
17345e5a
JA
10740$endif
10741
10742# use a visible bell if one is available
10743set bell-style visible
10744
10745# don't strip characters to 7 bits when reading
10746set input-meta on
10747
10748# allow iso-latin1 characters to be inserted rather
10749# than converted to prefix-meta sequences
10750set convert-meta off
10751
10752# display characters with the eighth bit set directly
10753# rather than as meta-prefixed characters
10754set output-meta on
10755
10756# if there are more than 150 possible completions for
10757# a word, ask the user if he wants to see all of them
10758set completion-query-items 150
10759
10760# For FTP
10761$if Ftp
a0c0a00f
CR
10762&quot;\C-xg&quot;: &quot;get \M-?&quot;
10763&quot;\C-xt&quot;: &quot;put \M-?&quot;
10764&quot;\M-.&quot;: yank-last-arg
17345e5a 10765$endif
a0c0a00f
CR
10766</pre></div>
10767
10768<hr>
10769<a name="Bindable-Readline-Commands"></a>
10770<div class="header">
10771<p>
10772Next: <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>
10773</div>
10774<a name="Bindable-Readline-Commands-1"></a>
10775<h3 class="section">8.4 Bindable Readline Commands</h3>
10776
10777<table class="menu" border="0" cellspacing="0">
10778<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.
10779</td></tr>
10780<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.
10781</td></tr>
10782<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.
10783</td></tr>
10784<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.
10785</td></tr>
10786<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.
10787</td></tr>
10788<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.
10789</td></tr>
10790<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
10791</td></tr>
10792<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.
10793</td></tr>
10794</table>
10795
10796<p>This section describes Readline commands that may be bound to key
17345e5a
JA
10797sequences.
10798You can list your key bindings by executing
a0c0a00f
CR
10799<code>bind&nbsp;<span class="nolinebreak">-P</span></code><!-- /@w --> or, for a more terse format, suitable for an
10800<var>inputrc</var> file, <code>bind&nbsp;<span class="nolinebreak">-p</span></code><!-- /@w -->. (See <a href="#Bash-Builtins">Bash Builtins</a>.)
17345e5a 10801Command names without an accompanying key sequence are unbound by default.
a0c0a00f
CR
10802</p>
10803<p>In the following descriptions, <em>point</em> refers to the current cursor
10804position, and <em>mark</em> refers to a cursor position saved by the
10805<code>set-mark</code> command.
10806The text between the point and mark is referred to as the <em>region</em>.
10807</p>
10808<hr>
10809<a name="Commands-For-Moving"></a>
10810<div class="header">
10811<p>
10812Next: <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>
10813</div>
10814<a name="Commands-For-Moving-1"></a>
10815<h4 class="subsection">8.4.1 Commands For Moving</h4>
10816<dl compact="compact">
10817<dt><code>beginning-of-line (C-a)</code>
10818<a name="index-beginning_002dof_002dline-_0028C_002da_0029"></a>
10819</dt>
10820<dd><p>Move to the start of the current line.
10821</p>
10822</dd>
10823<dt><code>end-of-line (C-e)</code>
10824<a name="index-end_002dof_002dline-_0028C_002de_0029"></a>
10825</dt>
10826<dd><p>Move to the end of the line.
10827</p>
10828</dd>
10829<dt><code>forward-char (C-f)</code>
10830<a name="index-forward_002dchar-_0028C_002df_0029"></a>
10831</dt>
10832<dd><p>Move forward a character.
10833</p>
10834</dd>
10835<dt><code>backward-char (C-b)</code>
10836<a name="index-backward_002dchar-_0028C_002db_0029"></a>
10837</dt>
10838<dd><p>Move back a character.
10839</p>
10840</dd>
10841<dt><code>forward-word (M-f)</code>
10842<a name="index-forward_002dword-_0028M_002df_0029"></a>
10843</dt>
10844<dd><p>Move forward to the end of the next word.
17345e5a 10845Words are composed of letters and digits.
a0c0a00f
CR
10846</p>
10847</dd>
10848<dt><code>backward-word (M-b)</code>
10849<a name="index-backward_002dword-_0028M_002db_0029"></a>
10850</dt>
10851<dd><p>Move back to the start of the current or previous word.
17345e5a 10852Words are composed of letters and digits.
a0c0a00f
CR
10853</p>
10854</dd>
10855<dt><code>shell-forward-word ()</code>
10856<a name="index-shell_002dforward_002dword-_0028_0029"></a>
10857</dt>
10858<dd><p>Move forward to the end of the next word.
17345e5a 10859Words are delimited by non-quoted shell metacharacters.
a0c0a00f
CR
10860</p>
10861</dd>
10862<dt><code>shell-backward-word ()</code>
10863<a name="index-shell_002dbackward_002dword-_0028_0029"></a>
10864</dt>
10865<dd><p>Move back to the start of the current or previous word.
17345e5a 10866Words are delimited by non-quoted shell metacharacters.
a0c0a00f
CR
10867</p>
10868</dd>
9a51695b
CR
10869<dt><code>previous-screen-line ()</code>
10870<a name="index-previous_002dscreen_002dline-_0028_0029"></a>
10871</dt>
10872<dd><p>Attempt to move point to the same physical screen column on the previous
10873physical screen line. This will not have the desired effect if the current
10874Readline line does not take up more than one physical line or if point is not
10875greater than the length of the prompt plus the screen width.
10876</p>
10877</dd>
10878<dt><code>next-screen-line ()</code>
10879<a name="index-next_002dscreen_002dline-_0028_0029"></a>
10880</dt>
10881<dd><p>Attempt to move point to the same physical screen column on the next
10882physical screen line. This will not have the desired effect if the current
10883Readline line does not take up more than one physical line or if the length
10884of the current Readline line is not greater than the length of the prompt
10885plus the screen width.
10886</p>
10887</dd>
a0c0a00f
CR
10888<dt><code>clear-screen (C-l)</code>
10889<a name="index-clear_002dscreen-_0028C_002dl_0029"></a>
10890</dt>
10891<dd><p>Clear the screen and redraw the current line,
17345e5a 10892leaving the current line at the top of the screen.
a0c0a00f
CR
10893</p>
10894</dd>
10895<dt><code>redraw-current-line ()</code>
10896<a name="index-redraw_002dcurrent_002dline-_0028_0029"></a>
10897</dt>
10898<dd><p>Refresh the current line. By default, this is unbound.
10899</p>
10900</dd>
10901</dl>
10902
10903<hr>
10904<a name="Commands-For-History"></a>
10905<div class="header">
10906<p>
10907Next: <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>
10908</div>
10909<a name="Commands-For-Manipulating-The-History"></a>
10910<h4 class="subsection">8.4.2 Commands For Manipulating The History</h4>
10911
10912<dl compact="compact">
10913<dt><code>accept-line (Newline or Return)</code>
10914<a name="index-accept_002dline-_0028Newline-or-Return_0029"></a>
10915</dt>
10916<dd><p>Accept the line regardless of where the cursor is.
17345e5a
JA
10917If this line is
10918non-empty, add it to the history list according to the setting of
a0c0a00f 10919the <code>HISTCONTROL</code> and <code>HISTIGNORE</code> variables.
17345e5a
JA
10920If this line is a modified history line, then restore the history line
10921to its original state.
a0c0a00f
CR
10922</p>
10923</dd>
10924<dt><code>previous-history (C-p)</code>
10925<a name="index-previous_002dhistory-_0028C_002dp_0029"></a>
10926</dt>
10927<dd><p>Move &lsquo;back&rsquo; through the history list, fetching the previous command.
10928</p>
10929</dd>
10930<dt><code>next-history (C-n)</code>
10931<a name="index-next_002dhistory-_0028C_002dn_0029"></a>
10932</dt>
10933<dd><p>Move &lsquo;forward&rsquo; through the history list, fetching the next command.
10934</p>
10935</dd>
10936<dt><code>beginning-of-history (M-&lt;)</code>
10937<a name="index-beginning_002dof_002dhistory-_0028M_002d_003c_0029"></a>
10938</dt>
10939<dd><p>Move to the first line in the history.
10940</p>
10941</dd>
10942<dt><code>end-of-history (M-&gt;)</code>
10943<a name="index-end_002dof_002dhistory-_0028M_002d_003e_0029"></a>
10944</dt>
10945<dd><p>Move to the end of the input history, i.e., the line currently
17345e5a 10946being entered.
a0c0a00f
CR
10947</p>
10948</dd>
10949<dt><code>reverse-search-history (C-r)</code>
10950<a name="index-reverse_002dsearch_002dhistory-_0028C_002dr_0029"></a>
10951</dt>
10952<dd><p>Search backward starting at the current line and moving &lsquo;up&rsquo; through
10953the history as necessary. This is an incremental search.
10954</p>
10955</dd>
10956<dt><code>forward-search-history (C-s)</code>
10957<a name="index-forward_002dsearch_002dhistory-_0028C_002ds_0029"></a>
10958</dt>
10959<dd><p>Search forward starting at the current line and moving &lsquo;down&rsquo; through
17345e5a 10960the history as necessary. This is an incremental search.
a0c0a00f
CR
10961</p>
10962</dd>
10963<dt><code>non-incremental-reverse-search-history (M-p)</code>
10964<a name="index-non_002dincremental_002dreverse_002dsearch_002dhistory-_0028M_002dp_0029"></a>
10965</dt>
10966<dd><p>Search backward starting at the current line and moving &lsquo;up&rsquo;
17345e5a
JA
10967through the history as necessary using a non-incremental search
10968for a string supplied by the user.
a0c0a00f
CR
10969The search string may match anywhere in a history line.
10970</p>
10971</dd>
10972<dt><code>non-incremental-forward-search-history (M-n)</code>
10973<a name="index-non_002dincremental_002dforward_002dsearch_002dhistory-_0028M_002dn_0029"></a>
10974</dt>
10975<dd><p>Search forward starting at the current line and moving &lsquo;down&rsquo;
10976through the history as necessary using a non-incremental search
17345e5a 10977for a string supplied by the user.
a0c0a00f
CR
10978The search string may match anywhere in a history line.
10979</p>
10980</dd>
10981<dt><code>history-search-forward ()</code>
10982<a name="index-history_002dsearch_002dforward-_0028_0029"></a>
10983</dt>
10984<dd><p>Search forward through the history for the string of characters
17345e5a 10985between the start of the current line and the point.
ac50fbac 10986The search string must match at the beginning of a history line.
17345e5a
JA
10987This is a non-incremental search.
10988By default, this command is unbound.
a0c0a00f
CR
10989</p>
10990</dd>
10991<dt><code>history-search-backward ()</code>
10992<a name="index-history_002dsearch_002dbackward-_0028_0029"></a>
10993</dt>
10994<dd><p>Search backward through the history for the string of characters
ac50fbac
CR
10995between the start of the current line and the point.
10996The search string must match at the beginning of a history line.
10997This is a non-incremental search.
10998By default, this command is unbound.
a0c0a00f
CR
10999</p>
11000</dd>
9a51695b
CR
11001<dt><code>history-substring-search-forward ()</code>
11002<a name="index-history_002dsubstring_002dsearch_002dforward-_0028_0029"></a>
a0c0a00f
CR
11003</dt>
11004<dd><p>Search forward through the history for the string of characters
ac50fbac
CR
11005between the start of the current line and the point.
11006The search string may match anywhere in a history line.
11007This is a non-incremental search.
11008By default, this command is unbound.
a0c0a00f
CR
11009</p>
11010</dd>
9a51695b
CR
11011<dt><code>history-substring-search-backward ()</code>
11012<a name="index-history_002dsubstring_002dsearch_002dbackward-_0028_0029"></a>
a0c0a00f
CR
11013</dt>
11014<dd><p>Search backward through the history for the string of characters
ac50fbac
CR
11015between the start of the current line and the point.
11016The search string may match anywhere in a history line.
11017This is a non-incremental search.
11018By default, this command is unbound.
a0c0a00f
CR
11019</p>
11020</dd>
11021<dt><code>yank-nth-arg (M-C-y)</code>
11022<a name="index-yank_002dnth_002darg-_0028M_002dC_002dy_0029"></a>
11023</dt>
11024<dd><p>Insert the first argument to the previous command (usually
17345e5a 11025the second word on the previous line) at point.
a0c0a00f
CR
11026With an argument <var>n</var>,
11027insert the <var>n</var>th word from the previous command (the words
17345e5a 11028in the previous command begin with word 0). A negative argument
a0c0a00f
CR
11029inserts the <var>n</var>th word from the end of the previous command.
11030Once the argument <var>n</var> is computed, the argument is extracted
11031as if the &lsquo;<samp>!<var>n</var></samp>&rsquo; history expansion had been specified.
11032</p>
11033</dd>
11034<dt><code>yank-last-arg (M-. or M-_)</code>
11035<a name="index-yank_002dlast_002darg-_0028M_002d_002e-or-M_002d_005f_0029"></a>
11036</dt>
11037<dd><p>Insert last argument to the previous command (the last word of the
495aee44 11038previous history entry).
a0c0a00f
CR
11039With a numeric argument, behave exactly like <code>yank-nth-arg</code>.
11040Successive calls to <code>yank-last-arg</code> move back through the history
495aee44
CR
11041list, inserting the last word (or the word specified by the argument to
11042the first call) of each line in turn.
11043Any numeric argument supplied to these successive calls determines
11044the direction to move through the history. A negative argument switches
11045the direction through the history (back or forward).
17345e5a 11046The history expansion facilities are used to extract the last argument,
a0c0a00f
CR
11047as if the &lsquo;<samp>!$</samp>&rsquo; history expansion had been specified.
11048</p>
11049</dd>
11050</dl>
11051
11052<hr>
11053<a name="Commands-For-Text"></a>
11054<div class="header">
11055<p>
11056Next: <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>
11057</div>
11058<a name="Commands-For-Changing-Text"></a>
11059<h4 class="subsection">8.4.3 Commands For Changing Text</h4>
11060
11061<dl compact="compact">
11062<dt><code><i>end-of-file</i> (usually C-d)</code>
11063<a name="index-end_002dof_002dfile-_0028usually-C_002dd_0029"></a>
11064</dt>
11065<dd><p>The character indicating end-of-file as set, for example, by
11066<code>stty</code>. If this character is read when there are no characters
ac50fbac 11067on the line, and point is at the beginning of the line, Readline
a0c0a00f
CR
11068interprets it as the end of input and returns <small>EOF</small>.
11069</p>
11070</dd>
11071<dt><code>delete-char (C-d)</code>
11072<a name="index-delete_002dchar-_0028C_002dd_0029"></a>
11073</dt>
11074<dd><p>Delete the character at point. If this function is bound to the
11075same character as the tty <small>EOF</small> character, as <kbd>C-d</kbd>
ac50fbac 11076commonly is, see above for the effects.
a0c0a00f
CR
11077</p>
11078</dd>
11079<dt><code>backward-delete-char (Rubout)</code>
11080<a name="index-backward_002ddelete_002dchar-_0028Rubout_0029"></a>
11081</dt>
11082<dd><p>Delete the character behind the cursor. A numeric argument means
17345e5a 11083to kill the characters instead of deleting them.
a0c0a00f
CR
11084</p>
11085</dd>
11086<dt><code>forward-backward-delete-char ()</code>
11087<a name="index-forward_002dbackward_002ddelete_002dchar-_0028_0029"></a>
11088</dt>
11089<dd><p>Delete the character under the cursor, unless the cursor is at the
17345e5a
JA
11090end of the line, in which case the character behind the cursor is
11091deleted. By default, this is not bound to a key.
a0c0a00f
CR
11092</p>
11093</dd>
11094<dt><code>quoted-insert (C-q or C-v)</code>
11095<a name="index-quoted_002dinsert-_0028C_002dq-or-C_002dv_0029"></a>
11096</dt>
11097<dd><p>Add the next character typed to the line verbatim. This is
11098how to insert key sequences like <kbd>C-q</kbd>, for example.
11099</p>
11100
11101</dd>
11102<dt><code>self-insert (a, b, A, 1, !, &hellip;)</code>
11103<a name="index-self_002dinsert-_0028a_002c-b_002c-A_002c-1_002c-_0021_002c-_2026_0029"></a>
11104</dt>
11105<dd><p>Insert yourself.
11106</p>
11107</dd>
11108<dt><code>bracketed-paste-begin ()</code>
11109<a name="index-bracketed_002dpaste_002dbegin-_0028_0029"></a>
11110</dt>
11111<dd><p>This function is intended to be bound to the &quot;bracketed paste&quot; escape
11112sequence sent by some terminals, and such a binding is assigned by default.
11113It allows Readline to insert the pasted text as a single unit without treating
11114each character as if it had been read from the keyboard. The characters
2f5dfe5a 11115are inserted as if each one was bound to <code>self-insert</code> instead of
a0c0a00f
CR
11116executing any editing commands.
11117</p>
11118</dd>
11119<dt><code>transpose-chars (C-t)</code>
11120<a name="index-transpose_002dchars-_0028C_002dt_0029"></a>
11121</dt>
11122<dd><p>Drag the character before the cursor forward over
17345e5a
JA
11123the character at the cursor, moving the
11124cursor forward as well. If the insertion point
11125is at the end of the line, then this
11126transposes the last two characters of the line.
11127Negative arguments have no effect.
a0c0a00f
CR
11128</p>
11129</dd>
11130<dt><code>transpose-words (M-t)</code>
11131<a name="index-transpose_002dwords-_0028M_002dt_0029"></a>
11132</dt>
11133<dd><p>Drag the word before point past the word after point,
17345e5a
JA
11134moving point past that word as well.
11135If the insertion point is at the end of the line, this transposes
11136the last two words on the line.
a0c0a00f
CR
11137</p>
11138</dd>
11139<dt><code>upcase-word (M-u)</code>
11140<a name="index-upcase_002dword-_0028M_002du_0029"></a>
11141</dt>
11142<dd><p>Uppercase the current (or following) word. With a negative argument,
17345e5a 11143uppercase the previous word, but do not move the cursor.
a0c0a00f
CR
11144</p>
11145</dd>
11146<dt><code>downcase-word (M-l)</code>
11147<a name="index-downcase_002dword-_0028M_002dl_0029"></a>
11148</dt>
11149<dd><p>Lowercase the current (or following) word. With a negative argument,
17345e5a 11150lowercase the previous word, but do not move the cursor.
a0c0a00f
CR
11151</p>
11152</dd>
11153<dt><code>capitalize-word (M-c)</code>
11154<a name="index-capitalize_002dword-_0028M_002dc_0029"></a>
11155</dt>
11156<dd><p>Capitalize the current (or following) word. With a negative argument,
17345e5a 11157capitalize the previous word, but do not move the cursor.
a0c0a00f
CR
11158</p>
11159</dd>
11160<dt><code>overwrite-mode ()</code>
11161<a name="index-overwrite_002dmode-_0028_0029"></a>
11162</dt>
11163<dd><p>Toggle overwrite mode. With an explicit positive numeric argument,
17345e5a
JA
11164switches to overwrite mode. With an explicit non-positive numeric
11165argument, switches to insert mode. This command affects only
a0c0a00f
CR
11166<code>emacs</code> mode; <code>vi</code> mode does overwrite differently.
11167Each call to <code>readline()</code> starts in insert mode.
11168</p>
11169<p>In overwrite mode, characters bound to <code>self-insert</code> replace
17345e5a 11170the text at point rather than pushing the text to the right.
a0c0a00f 11171Characters bound to <code>backward-delete-char</code> replace the character
17345e5a 11172before point with a space.
a0c0a00f
CR
11173</p>
11174<p>By default, this command is unbound.
11175</p>
11176</dd>
11177</dl>
11178
11179<hr>
11180<a name="Commands-For-Killing"></a>
11181<div class="header">
11182<p>
11183Next: <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>
11184</div>
11185<a name="Killing-And-Yanking"></a>
11186<h4 class="subsection">8.4.4 Killing And Yanking</h4>
11187
11188<dl compact="compact">
11189<dt><code>kill-line (C-k)</code>
11190<a name="index-kill_002dline-_0028C_002dk_0029"></a>
11191</dt>
11192<dd><p>Kill the text from point to the end of the line.
11193</p>
11194</dd>
11195<dt><code>backward-kill-line (C-x Rubout)</code>
11196<a name="index-backward_002dkill_002dline-_0028C_002dx-Rubout_0029"></a>
11197</dt>
11198<dd><p>Kill backward from the cursor to the beginning of the current line.
11199</p>
11200</dd>
11201<dt><code>unix-line-discard (C-u)</code>
11202<a name="index-unix_002dline_002ddiscard-_0028C_002du_0029"></a>
11203</dt>
11204<dd><p>Kill backward from the cursor to the beginning of the current line.
11205</p>
11206</dd>
11207<dt><code>kill-whole-line ()</code>
11208<a name="index-kill_002dwhole_002dline-_0028_0029"></a>
11209</dt>
11210<dd><p>Kill all characters on the current line, no matter where point is.
17345e5a 11211By default, this is unbound.
a0c0a00f
CR
11212</p>
11213</dd>
11214<dt><code>kill-word (M-d)</code>
11215<a name="index-kill_002dword-_0028M_002dd_0029"></a>
11216</dt>
11217<dd><p>Kill from point to the end of the current word, or if between
17345e5a 11218words, to the end of the next word.
a0c0a00f
CR
11219Word boundaries are the same as <code>forward-word</code>.
11220</p>
11221</dd>
11222<dt><code>backward-kill-word (M-<span class="key">DEL</span>)</code>
11223<a name="index-backward_002dkill_002dword-_0028M_002dDEL_0029"></a>
11224</dt>
11225<dd><p>Kill the word behind point.
11226Word boundaries are the same as <code>backward-word</code>.
11227</p>
11228</dd>
11229<dt><code>shell-kill-word ()</code>
11230<a name="index-shell_002dkill_002dword-_0028_0029"></a>
11231</dt>
11232<dd><p>Kill from point to the end of the current word, or if between
17345e5a 11233words, to the end of the next word.
a0c0a00f
CR
11234Word boundaries are the same as <code>shell-forward-word</code>.
11235</p>
11236</dd>
11237<dt><code>shell-backward-kill-word ()</code>
11238<a name="index-shell_002dbackward_002dkill_002dword-_0028_0029"></a>
11239</dt>
11240<dd><p>Kill the word behind point.
11241Word boundaries are the same as <code>shell-backward-word</code>.
11242</p>
11243</dd>
11244<dt><code>unix-word-rubout (C-w)</code>
11245<a name="index-unix_002dword_002drubout-_0028C_002dw_0029"></a>
11246</dt>
11247<dd><p>Kill the word behind point, using white space as a word boundary.
17345e5a 11248The killed text is saved on the kill-ring.
a0c0a00f
CR
11249</p>
11250</dd>
11251<dt><code>unix-filename-rubout ()</code>
11252<a name="index-unix_002dfilename_002drubout-_0028_0029"></a>
11253</dt>
11254<dd><p>Kill the word behind point, using white space and the slash character
17345e5a
JA
11255as the word boundaries.
11256The killed text is saved on the kill-ring.
a0c0a00f
CR
11257</p>
11258</dd>
11259<dt><code>delete-horizontal-space ()</code>
11260<a name="index-delete_002dhorizontal_002dspace-_0028_0029"></a>
11261</dt>
11262<dd><p>Delete all spaces and tabs around point. By default, this is unbound.
11263</p>
11264</dd>
11265<dt><code>kill-region ()</code>
11266<a name="index-kill_002dregion-_0028_0029"></a>
11267</dt>
11268<dd><p>Kill the text in the current region.
17345e5a 11269By default, this command is unbound.
a0c0a00f
CR
11270</p>
11271</dd>
11272<dt><code>copy-region-as-kill ()</code>
11273<a name="index-copy_002dregion_002das_002dkill-_0028_0029"></a>
11274</dt>
11275<dd><p>Copy the text in the region to the kill buffer, so it can be yanked
17345e5a 11276right away. By default, this command is unbound.
a0c0a00f
CR
11277</p>
11278</dd>
11279<dt><code>copy-backward-word ()</code>
11280<a name="index-copy_002dbackward_002dword-_0028_0029"></a>
11281</dt>
11282<dd><p>Copy the word before point to the kill buffer.
11283The word boundaries are the same as <code>backward-word</code>.
17345e5a 11284By default, this command is unbound.
a0c0a00f
CR
11285</p>
11286</dd>
11287<dt><code>copy-forward-word ()</code>
11288<a name="index-copy_002dforward_002dword-_0028_0029"></a>
11289</dt>
11290<dd><p>Copy the word following point to the kill buffer.
11291The word boundaries are the same as <code>forward-word</code>.
17345e5a 11292By default, this command is unbound.
a0c0a00f
CR
11293</p>
11294</dd>
11295<dt><code>yank (C-y)</code>
11296<a name="index-yank-_0028C_002dy_0029"></a>
11297</dt>
11298<dd><p>Yank the top of the kill ring into the buffer at point.
11299</p>
11300</dd>
11301<dt><code>yank-pop (M-y)</code>
11302<a name="index-yank_002dpop-_0028M_002dy_0029"></a>
11303</dt>
11304<dd><p>Rotate the kill-ring, and yank the new top. You can only do this if
11305the prior command is <code>yank</code> or <code>yank-pop</code>.
11306</p></dd>
11307</dl>
11308
11309<hr>
11310<a name="Numeric-Arguments"></a>
11311<div class="header">
11312<p>
11313Next: <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>
11314</div>
11315<a name="Specifying-Numeric-Arguments"></a>
11316<h4 class="subsection">8.4.5 Specifying Numeric Arguments</h4>
11317<dl compact="compact">
11318<dt><code>digit-argument (<kbd>M-0</kbd>, <kbd>M-1</kbd>, &hellip; <kbd>M--</kbd>)</code>
11319<a name="index-digit_002dargument-_0028M_002d0_002c-M_002d1_002c-_2026-M_002d_002d_0029"></a>
11320</dt>
11321<dd><p>Add this digit to the argument already accumulating, or start a new
11322argument. <kbd>M--</kbd> starts a negative argument.
11323</p>
11324</dd>
11325<dt><code>universal-argument ()</code>
11326<a name="index-universal_002dargument-_0028_0029"></a>
11327</dt>
11328<dd><p>This is another way to specify an argument.
17345e5a
JA
11329If this command is followed by one or more digits, optionally with a
11330leading minus sign, those digits define the argument.
a0c0a00f 11331If the command is followed by digits, executing <code>universal-argument</code>
17345e5a
JA
11332again ends the numeric argument, but is otherwise ignored.
11333As a special case, if this command is immediately followed by a
a0c0a00f 11334character that is neither a digit nor minus sign, the argument count
17345e5a
JA
11335for the next command is multiplied by four.
11336The argument count is initially one, so executing this function the
11337first time makes the argument count four, a second time makes the
11338argument count sixteen, and so on.
11339By default, this is not bound to a key.
a0c0a00f
CR
11340</p></dd>
11341</dl>
11342
11343<hr>
11344<a name="Commands-For-Completion"></a>
11345<div class="header">
11346<p>
11347Next: <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>
11348</div>
11349<a name="Letting-Readline-Type-For-You"></a>
11350<h4 class="subsection">8.4.6 Letting Readline Type For You</h4>
11351
11352<dl compact="compact">
11353<dt><code>complete (<span class="key">TAB</span>)</code>
11354<a name="index-complete-_0028TAB_0029"></a>
11355</dt>
11356<dd><p>Attempt to perform completion on the text before point.
17345e5a
JA
11357The actual completion performed is application-specific.
11358Bash attempts completion treating the text as a variable (if the
a0c0a00f
CR
11359text begins with &lsquo;<samp>$</samp>&rsquo;), username (if the text begins with
11360&lsquo;<samp>~</samp>&rsquo;), hostname (if the text begins with &lsquo;<samp>@</samp>&rsquo;), or
17345e5a
JA
11361command (including aliases and functions) in turn. If none
11362of these produces a match, filename completion is attempted.
a0c0a00f
CR
11363</p>
11364</dd>
11365<dt><code>possible-completions (M-?)</code>
11366<a name="index-possible_002dcompletions-_0028M_002d_003f_0029"></a>
11367</dt>
11368<dd><p>List the possible completions of the text before point.
495aee44 11369When displaying completions, Readline sets the number of columns used
a0c0a00f
CR
11370for display to the value of <code>completion-display-width</code>, the value of
11371the environment variable <code>COLUMNS</code>, or the screen width, in that order.
11372</p>
11373</dd>
11374<dt><code>insert-completions (M-*)</code>
11375<a name="index-insert_002dcompletions-_0028M_002d_002a_0029"></a>
11376</dt>
11377<dd><p>Insert all completions of the text before point that would have
11378been generated by <code>possible-completions</code>.
11379</p>
11380</dd>
11381<dt><code>menu-complete ()</code>
11382<a name="index-menu_002dcomplete-_0028_0029"></a>
11383</dt>
11384<dd><p>Similar to <code>complete</code>, but replaces the word to be completed
17345e5a 11385with a single match from the list of possible completions.
a0c0a00f 11386Repeated execution of <code>menu-complete</code> steps through the list
17345e5a
JA
11387of possible completions, inserting each match in turn.
11388At the end of the list of completions, the bell is rung
a0c0a00f 11389(subject to the setting of <code>bell-style</code>)
17345e5a 11390and the original text is restored.
a0c0a00f 11391An argument of <var>n</var> moves <var>n</var> positions forward in the list
17345e5a
JA
11392of matches; a negative argument may be used to move backward
11393through the list.
a0c0a00f 11394This command is intended to be bound to <tt class="key">TAB</tt>, but is unbound
17345e5a 11395by default.
a0c0a00f
CR
11396</p>
11397</dd>
11398<dt><code>menu-complete-backward ()</code>
11399<a name="index-menu_002dcomplete_002dbackward-_0028_0029"></a>
11400</dt>
11401<dd><p>Identical to <code>menu-complete</code>, but moves backward through the list
11402of possible completions, as if <code>menu-complete</code> had been given a
0001803f 11403negative argument.
a0c0a00f
CR
11404</p>
11405</dd>
11406<dt><code>delete-char-or-list ()</code>
11407<a name="index-delete_002dchar_002dor_002dlist-_0028_0029"></a>
11408</dt>
11409<dd><p>Deletes the character under the cursor if not at the beginning or
11410end of the line (like <code>delete-char</code>).
17345e5a 11411If at the end of the line, behaves identically to
a0c0a00f 11412<code>possible-completions</code>.
17345e5a 11413This command is unbound by default.
a0c0a00f
CR
11414</p>
11415</dd>
11416<dt><code>complete-filename (M-/)</code>
11417<a name="index-complete_002dfilename-_0028M_002d_002f_0029"></a>
11418</dt>
11419<dd><p>Attempt filename completion on the text before point.
11420</p>
11421</dd>
11422<dt><code>possible-filename-completions (C-x /)</code>
11423<a name="index-possible_002dfilename_002dcompletions-_0028C_002dx-_002f_0029"></a>
11424</dt>
11425<dd><p>List the possible completions of the text before point,
17345e5a 11426treating it as a filename.
a0c0a00f
CR
11427</p>
11428</dd>
11429<dt><code>complete-username (M-~)</code>
11430<a name="index-complete_002dusername-_0028M_002d_007e_0029"></a>
11431</dt>
11432<dd><p>Attempt completion on the text before point, treating
17345e5a 11433it as a username.
a0c0a00f
CR
11434</p>
11435</dd>
11436<dt><code>possible-username-completions (C-x ~)</code>
11437<a name="index-possible_002dusername_002dcompletions-_0028C_002dx-_007e_0029"></a>
11438</dt>
11439<dd><p>List the possible completions of the text before point,
17345e5a 11440treating it as a username.
a0c0a00f
CR
11441</p>
11442</dd>
11443<dt><code>complete-variable (M-$)</code>
11444<a name="index-complete_002dvariable-_0028M_002d_0024_0029"></a>
11445</dt>
11446<dd><p>Attempt completion on the text before point, treating
17345e5a 11447it as a shell variable.
a0c0a00f
CR
11448</p>
11449</dd>
11450<dt><code>possible-variable-completions (C-x $)</code>
11451<a name="index-possible_002dvariable_002dcompletions-_0028C_002dx-_0024_0029"></a>
11452</dt>
11453<dd><p>List the possible completions of the text before point,
17345e5a 11454treating it as a shell variable.
a0c0a00f
CR
11455</p>
11456</dd>
11457<dt><code>complete-hostname (M-@)</code>
11458<a name="index-complete_002dhostname-_0028M_002d_0040_0029"></a>
11459</dt>
11460<dd><p>Attempt completion on the text before point, treating
17345e5a 11461it as a hostname.
a0c0a00f
CR
11462</p>
11463</dd>
11464<dt><code>possible-hostname-completions (C-x @)</code>
11465<a name="index-possible_002dhostname_002dcompletions-_0028C_002dx-_0040_0029"></a>
11466</dt>
11467<dd><p>List the possible completions of the text before point,
17345e5a 11468treating it as a hostname.
a0c0a00f
CR
11469</p>
11470</dd>
11471<dt><code>complete-command (M-!)</code>
11472<a name="index-complete_002dcommand-_0028M_002d_0021_0029"></a>
11473</dt>
11474<dd><p>Attempt completion on the text before point, treating
17345e5a
JA
11475it as a command name. Command completion attempts to
11476match the text against aliases, reserved words, shell
11477functions, shell builtins, and finally executable filenames,
11478in that order.
a0c0a00f
CR
11479</p>
11480</dd>
11481<dt><code>possible-command-completions (C-x !)</code>
11482<a name="index-possible_002dcommand_002dcompletions-_0028C_002dx-_0021_0029"></a>
11483</dt>
11484<dd><p>List the possible completions of the text before point,
17345e5a 11485treating it as a command name.
a0c0a00f
CR
11486</p>
11487</dd>
11488<dt><code>dynamic-complete-history (M-<span class="key">TAB</span>)</code>
11489<a name="index-dynamic_002dcomplete_002dhistory-_0028M_002dTAB_0029"></a>
11490</dt>
11491<dd><p>Attempt completion on the text before point, comparing
17345e5a
JA
11492the text against lines from the history list for possible
11493completion matches.
a0c0a00f
CR
11494</p>
11495</dd>
11496<dt><code>dabbrev-expand ()</code>
11497<a name="index-dabbrev_002dexpand-_0028_0029"></a>
11498</dt>
11499<dd><p>Attempt menu completion on the text before point, comparing
17345e5a
JA
11500the text against lines from the history list for possible
11501completion matches.
a0c0a00f
CR
11502</p>
11503</dd>
11504<dt><code>complete-into-braces (M-{)</code>
11505<a name="index-complete_002dinto_002dbraces-_0028M_002d_007b_0029"></a>
11506</dt>
11507<dd><p>Perform filename completion and insert the list of possible completions
17345e5a 11508enclosed within braces so the list is available to the shell
a0c0a00f
CR
11509(see <a href="#Brace-Expansion">Brace Expansion</a>).
11510</p>
11511</dd>
11512</dl>
11513
11514<hr>
11515<a name="Keyboard-Macros"></a>
11516<div class="header">
11517<p>
11518Next: <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>
11519</div>
11520<a name="Keyboard-Macros-1"></a>
11521<h4 class="subsection">8.4.7 Keyboard Macros</h4>
11522<dl compact="compact">
11523<dt><code>start-kbd-macro (C-x ()</code>
11524<a name="index-start_002dkbd_002dmacro-_0028C_002dx-_0028_0029"></a>
11525</dt>
11526<dd><p>Begin saving the characters typed into the current keyboard macro.
11527</p>
11528</dd>
11529<dt><code>end-kbd-macro (C-x ))</code>
11530<a name="index-end_002dkbd_002dmacro-_0028C_002dx-_0029_0029"></a>
11531</dt>
11532<dd><p>Stop saving the characters typed into the current keyboard macro
17345e5a 11533and save the definition.
a0c0a00f
CR
11534</p>
11535</dd>
11536<dt><code>call-last-kbd-macro (C-x e)</code>
11537<a name="index-call_002dlast_002dkbd_002dmacro-_0028C_002dx-e_0029"></a>
11538</dt>
11539<dd><p>Re-execute the last keyboard macro defined, by making the characters
17345e5a 11540in the macro appear as if typed at the keyboard.
a0c0a00f
CR
11541</p>
11542</dd>
11543<dt><code>print-last-kbd-macro ()</code>
11544<a name="index-print_002dlast_002dkbd_002dmacro-_0028_0029"></a>
11545</dt>
11546<dd><p>Print the last keboard macro defined in a format suitable for the
11547<var>inputrc</var> file.
11548</p>
11549</dd>
11550</dl>
11551
11552<hr>
11553<a name="Miscellaneous-Commands"></a>
11554<div class="header">
11555<p>
11556Previous: <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>
11557</div>
11558<a name="Some-Miscellaneous-Commands"></a>
11559<h4 class="subsection">8.4.8 Some Miscellaneous Commands</h4>
11560<dl compact="compact">
11561<dt><code>re-read-init-file (C-x C-r)</code>
11562<a name="index-re_002dread_002dinit_002dfile-_0028C_002dx-C_002dr_0029"></a>
11563</dt>
11564<dd><p>Read in the contents of the <var>inputrc</var> file, and incorporate
17345e5a 11565any bindings or variable assignments found there.
a0c0a00f
CR
11566</p>
11567</dd>
11568<dt><code>abort (C-g)</code>
11569<a name="index-abort-_0028C_002dg_0029"></a>
11570</dt>
11571<dd><p>Abort the current editing command and
11572ring the terminal&rsquo;s bell (subject to the setting of
11573<code>bell-style</code>).
11574</p>
11575</dd>
9a51695b
CR
11576<dt><code>do-lowercase-version (M-A, M-B, M-<var>x</var>, &hellip;)</code>
11577<a name="index-do_002dlowercase_002dversion-_0028M_002dA_002c-M_002dB_002c-M_002dx_002c-_2026_0029"></a>
a0c0a00f 11578</dt>
9a51695b
CR
11579<dd><p>If the metafied character <var>x</var> is upper case, run the command
11580that is bound to the corresponding metafied lower case character.
11581The behavior is undefined if <var>x</var> is already lower case.
a0c0a00f
CR
11582</p>
11583</dd>
11584<dt><code>prefix-meta (<span class="key">ESC</span>)</code>
11585<a name="index-prefix_002dmeta-_0028ESC_0029"></a>
11586</dt>
11587<dd><p>Metafy the next character typed. This is for keyboards
11588without a meta key. Typing &lsquo;<samp><span class="key">ESC</span> f</samp>&rsquo; is equivalent to typing
11589<kbd>M-f</kbd>.
11590</p>
11591</dd>
11592<dt><code>undo (C-_ or C-x C-u)</code>
11593<a name="index-undo-_0028C_002d_005f-or-C_002dx-C_002du_0029"></a>
11594</dt>
11595<dd><p>Incremental undo, separately remembered for each line.
11596</p>
11597</dd>
11598<dt><code>revert-line (M-r)</code>
11599<a name="index-revert_002dline-_0028M_002dr_0029"></a>
11600</dt>
11601<dd><p>Undo all changes made to this line. This is like executing the <code>undo</code>
17345e5a 11602command enough times to get back to the beginning.
a0c0a00f
CR
11603</p>
11604</dd>
11605<dt><code>tilde-expand (M-&amp;)</code>
11606<a name="index-tilde_002dexpand-_0028M_002d_0026_0029"></a>
11607</dt>
11608<dd><p>Perform tilde expansion on the current word.
11609</p>
11610</dd>
11611<dt><code>set-mark (C-@)</code>
11612<a name="index-set_002dmark-_0028C_002d_0040_0029"></a>
11613</dt>
11614<dd><p>Set the mark to the point. If a
17345e5a 11615numeric argument is supplied, the mark is set to that position.
a0c0a00f
CR
11616</p>
11617</dd>
11618<dt><code>exchange-point-and-mark (C-x C-x)</code>
11619<a name="index-exchange_002dpoint_002dand_002dmark-_0028C_002dx-C_002dx_0029"></a>
11620</dt>
11621<dd><p>Swap the point with the mark. The current cursor position is set to
17345e5a 11622the saved position, and the old cursor position is saved as the mark.
a0c0a00f
CR
11623</p>
11624</dd>
11625<dt><code>character-search (C-])</code>
11626<a name="index-character_002dsearch-_0028C_002d_005d_0029"></a>
11627</dt>
11628<dd><p>A character is read and point is moved to the next occurrence of that
17345e5a 11629character. A negative count searches for previous occurrences.
a0c0a00f
CR
11630</p>
11631</dd>
11632<dt><code>character-search-backward (M-C-])</code>
11633<a name="index-character_002dsearch_002dbackward-_0028M_002dC_002d_005d_0029"></a>
11634</dt>
11635<dd><p>A character is read and point is moved to the previous occurrence
17345e5a
JA
11636of that character. A negative count searches for subsequent
11637occurrences.
a0c0a00f
CR
11638</p>
11639</dd>
11640<dt><code>skip-csi-sequence ()</code>
11641<a name="index-skip_002dcsi_002dsequence-_0028_0029"></a>
11642</dt>
11643<dd><p>Read enough characters to consume a multi-key sequence such as those
0001803f
CR
11644defined for keys like Home and End. Such sequences begin with a
11645Control Sequence Indicator (CSI), usually ESC-[. If this sequence is
a0c0a00f 11646bound to &quot;\e[&quot;, keys producing such sequences will have no effect
0001803f
CR
11647unless explicitly bound to a readline command, instead of inserting
11648stray characters into the editing buffer. This is unbound by default,
11649but usually bound to ESC-[.
a0c0a00f
CR
11650</p>
11651</dd>
11652<dt><code>insert-comment (M-#)</code>
11653<a name="index-insert_002dcomment-_0028M_002d_0023_0029"></a>
11654</dt>
11655<dd><p>Without a numeric argument, the value of the <code>comment-begin</code>
17345e5a
JA
11656variable is inserted at the beginning of the current line.
11657If a numeric argument is supplied, this command acts as a toggle: if
11658the characters at the beginning of the line do not match the value
a0c0a00f
CR
11659of <code>comment-begin</code>, the value is inserted, otherwise
11660the characters in <code>comment-begin</code> are deleted from the beginning of
17345e5a
JA
11661the line.
11662In either case, the line is accepted as if a newline had been typed.
a0c0a00f 11663The default value of <code>comment-begin</code> causes this command
17345e5a
JA
11664to make the current line a shell comment.
11665If a numeric argument causes the comment character to be removed, the line
11666will be executed by the shell.
a0c0a00f
CR
11667</p>
11668</dd>
11669<dt><code>dump-functions ()</code>
11670<a name="index-dump_002dfunctions-_0028_0029"></a>
11671</dt>
11672<dd><p>Print all of the functions and their key bindings to the
17345e5a
JA
11673Readline output stream. If a numeric argument is supplied,
11674the output is formatted in such a way that it can be made part
a0c0a00f
CR
11675of an <var>inputrc</var> file. This command is unbound by default.
11676</p>
11677</dd>
11678<dt><code>dump-variables ()</code>
11679<a name="index-dump_002dvariables-_0028_0029"></a>
11680</dt>
11681<dd><p>Print all of the settable variables and their values to the
17345e5a
JA
11682Readline output stream. If a numeric argument is supplied,
11683the output is formatted in such a way that it can be made part
a0c0a00f
CR
11684of an <var>inputrc</var> file. This command is unbound by default.
11685</p>
11686</dd>
11687<dt><code>dump-macros ()</code>
11688<a name="index-dump_002dmacros-_0028_0029"></a>
11689</dt>
11690<dd><p>Print all of the Readline key sequences bound to macros and the
17345e5a
JA
11691strings they output. If a numeric argument is supplied,
11692the output is formatted in such a way that it can be made part
a0c0a00f
CR
11693of an <var>inputrc</var> file. This command is unbound by default.
11694</p>
11695</dd>
11696<dt><code>glob-complete-word (M-g)</code>
11697<a name="index-glob_002dcomplete_002dword-_0028M_002dg_0029"></a>
11698</dt>
11699<dd><p>The word before point is treated as a pattern for pathname expansion,
17345e5a
JA
11700with an asterisk implicitly appended. This pattern is used to
11701generate a list of matching file names for possible completions.
a0c0a00f
CR
11702</p>
11703</dd>
11704<dt><code>glob-expand-word (C-x *)</code>
11705<a name="index-glob_002dexpand_002dword-_0028C_002dx-_002a_0029"></a>
11706</dt>
11707<dd><p>The word before point is treated as a pattern for pathname expansion,
17345e5a 11708and the list of matching file names is inserted, replacing the word.
a0c0a00f 11709If a numeric argument is supplied, a &lsquo;<samp>*</samp>&rsquo; is appended before
17345e5a 11710pathname expansion.
a0c0a00f
CR
11711</p>
11712</dd>
11713<dt><code>glob-list-expansions (C-x g)</code>
11714<a name="index-glob_002dlist_002dexpansions-_0028C_002dx-g_0029"></a>
11715</dt>
11716<dd><p>The list of expansions that would have been generated by
11717<code>glob-expand-word</code> is displayed, and the line is redrawn.
11718If a numeric argument is supplied, a &lsquo;<samp>*</samp>&rsquo; is appended before
17345e5a 11719pathname expansion.
a0c0a00f
CR
11720</p>
11721</dd>
11722<dt><code>display-shell-version (C-x C-v)</code>
11723<a name="index-display_002dshell_002dversion-_0028C_002dx-C_002dv_0029"></a>
11724</dt>
11725<dd><p>Display version information about the current instance of Bash.
11726</p>
11727</dd>
11728<dt><code>shell-expand-line (M-C-e)</code>
11729<a name="index-shell_002dexpand_002dline-_0028M_002dC_002de_0029"></a>
11730</dt>
11731<dd><p>Expand the line as the shell does.
17345e5a 11732This performs alias and history expansion as well as all of the shell
a0c0a00f
CR
11733word expansions (see <a href="#Shell-Expansions">Shell Expansions</a>).
11734</p>
11735</dd>
11736<dt><code>history-expand-line (M-^)</code>
11737<a name="index-history_002dexpand_002dline-_0028M_002d_005e_0029"></a>
11738</dt>
11739<dd><p>Perform history expansion on the current line.
11740</p>
11741</dd>
11742<dt><code>magic-space ()</code>
11743<a name="index-magic_002dspace-_0028_0029"></a>
11744</dt>
11745<dd><p>Perform history expansion on the current line and insert a space
11746(see <a href="#History-Interaction">History Interaction</a>).
11747</p>
11748</dd>
11749<dt><code>alias-expand-line ()</code>
11750<a name="index-alias_002dexpand_002dline-_0028_0029"></a>
11751</dt>
11752<dd><p>Perform alias expansion on the current line (see <a href="#Aliases">Aliases</a>).
11753</p>
11754</dd>
11755<dt><code>history-and-alias-expand-line ()</code>
11756<a name="index-history_002dand_002dalias_002dexpand_002dline-_0028_0029"></a>
11757</dt>
11758<dd><p>Perform history and alias expansion on the current line.
11759</p>
11760</dd>
11761<dt><code>insert-last-argument (M-. or M-_)</code>
11762<a name="index-insert_002dlast_002dargument-_0028M_002d_002e-or-M_002d_005f_0029"></a>
11763</dt>
11764<dd><p>A synonym for <code>yank-last-arg</code>.
11765</p>
11766</dd>
11767<dt><code>operate-and-get-next (C-o)</code>
11768<a name="index-operate_002dand_002dget_002dnext-_0028C_002do_0029"></a>
11769</dt>
11770<dd><p>Accept the current line for execution and fetch the next line
9a51695b
CR
11771relative to the current line from the history for editing.
11772A numeric argument, if supplied, specifies the history entry to use instead
11773of the current line.
a0c0a00f
CR
11774</p>
11775</dd>
9a51695b
CR
11776<dt><code>edit-and-execute-command (C-x C-e)</code>
11777<a name="index-edit_002dand_002dexecute_002dcommand-_0028C_002dx-C_002de_0029"></a>
a0c0a00f
CR
11778</dt>
11779<dd><p>Invoke an editor on the current command line, and execute the result as shell
17345e5a
JA
11780commands.
11781Bash attempts to invoke
a0c0a00f 11782<code>$VISUAL</code>, <code>$EDITOR</code>, and <code>emacs</code>
17345e5a 11783as the editor, in that order.
a0c0a00f
CR
11784</p>
11785
11786
11787</dd>
11788</dl>
11789
11790<hr>
11791<a name="Readline-vi-Mode"></a>
11792<div class="header">
11793<p>
11794Next: <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>
11795</div>
11796<a name="Readline-vi-Mode-1"></a>
11797<h3 class="section">8.5 Readline vi Mode</h3>
11798
11799<p>While the Readline library does not have a full set of <code>vi</code>
17345e5a 11800editing functions, it does contain enough to allow simple editing
a0c0a00f
CR
11801of the line. The Readline <code>vi</code> mode behaves as specified in
11802the <small>POSIX</small> standard.
11803</p>
11804<p>In order to switch interactively between <code>emacs</code> and <code>vi</code>
11805editing modes, use the &lsquo;<samp>set -o emacs</samp>&rsquo; and &lsquo;<samp>set -o vi</samp>&rsquo;
11806commands (see <a href="#The-Set-Builtin">The Set Builtin</a>).
11807The Readline default is <code>emacs</code> mode.
11808</p>
11809<p>When you enter a line in <code>vi</code> mode, you are already placed in
11810&lsquo;insertion&rsquo; mode, as if you had typed an &lsquo;<samp>i</samp>&rsquo;. Pressing <tt class="key">ESC</tt>
11811switches you into &lsquo;command&rsquo; mode, where you can edit the text of the
11812line with the standard <code>vi</code> movement keys, move to previous
11813history lines with &lsquo;<samp>k</samp>&rsquo; and subsequent lines with &lsquo;<samp>j</samp>&rsquo;, and
17345e5a 11814so forth.
a0c0a00f
CR
11815</p>
11816<hr>
11817<a name="Programmable-Completion"></a>
11818<div class="header">
11819<p>
11820Next: <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>
11821</div>
11822<a name="Programmable-Completion-1"></a>
11823<h3 class="section">8.6 Programmable Completion</h3>
11824<a name="index-programmable-completion"></a>
11825
11826<p>When word completion is attempted for an argument to a command for
11827which a completion specification (a <var>compspec</var>) has been defined
11828using the <code>complete</code> builtin (see <a href="#Programmable-Completion-Builtins">Programmable Completion Builtins</a>),
17345e5a 11829the programmable completion facilities are invoked.
a0c0a00f
CR
11830</p>
11831<p>First, the command name is identified.
17345e5a
JA
11832If a compspec has been defined for that command, the
11833compspec is used to generate the list of possible completions for the word.
0001803f
CR
11834If the command word is the empty string (completion attempted at the
11835beginning of an empty line), any compspec defined with
a0c0a00f 11836the <samp>-E</samp> option to <code>complete</code> is used.
17345e5a
JA
11837If the command word is a full pathname, a compspec for the full
11838pathname is searched for first.
11839If no compspec is found for the full pathname, an attempt is made to
11840find a compspec for the portion following the final slash.
0001803f 11841If those searches do not result in a compspec, any compspec defined with
a0c0a00f
CR
11842the <samp>-D</samp> option to <code>complete</code> is used as the default.
11843</p>
11844<p>Once a compspec has been found, it is used to generate the list of
17345e5a
JA
11845matching words.
11846If a compspec is not found, the default Bash completion
a0c0a00f
CR
11847described above (see <a href="#Commands-For-Completion">Commands For Completion</a>) is performed.
11848</p>
11849<p>First, the actions specified by the compspec are used.
17345e5a
JA
11850Only matches which are prefixed by the word being completed are
11851returned.
a0c0a00f
CR
11852When the <samp>-f</samp> or <samp>-d</samp> option is used for filename or
11853directory name completion, the shell variable <code>FIGNORE</code> is
17345e5a 11854used to filter the matches.
a0c0a00f
CR
11855See <a href="#Bash-Variables">Bash Variables</a>, for a description of <code>FIGNORE</code>.
11856</p>
11857<p>Any completions specified by a filename expansion pattern to the
11858<samp>-G</samp> option are generated next.
17345e5a 11859The words generated by the pattern need not match the word being completed.
a0c0a00f
CR
11860The <code>GLOBIGNORE</code> shell variable is not used to filter the matches,
11861but the <code>FIGNORE</code> shell variable is used.
11862</p>
11863<p>Next, the string specified as the argument to the <samp>-W</samp> option
17345e5a 11864is considered.
a0c0a00f 11865The string is first split using the characters in the <code>IFS</code>
17345e5a 11866special variable as delimiters.
9a51695b
CR
11867Shell quoting is honored within the string, in order to provide a
11868mechanism for the words to contain shell metacharacters or characters
11869in the value of <code>IFS</code>.
17345e5a
JA
11870Each word is then expanded using
11871brace expansion, tilde expansion, parameter and variable expansion,
11872command substitution, and arithmetic expansion,
a0c0a00f 11873as described above (see <a href="#Shell-Expansions">Shell Expansions</a>).
17345e5a 11874The results are split using the rules described above
a0c0a00f 11875(see <a href="#Word-Splitting">Word Splitting</a>).
17345e5a
JA
11876The results of the expansion are prefix-matched against the word being
11877completed, and the matching words become the possible completions.
a0c0a00f
CR
11878</p>
11879<p>After these matches have been generated, any shell function or command
11880specified with the <samp>-F</samp> and <samp>-C</samp> options is invoked.
11881When the command or function is invoked, the <code>COMP_LINE</code>,
11882<code>COMP_POINT</code>, <code>COMP_KEY</code>, and <code>COMP_TYPE</code> variables are
11883assigned values as described above (see <a href="#Bash-Variables">Bash Variables</a>).
11884If a shell function is being invoked, the <code>COMP_WORDS</code> and
11885<code>COMP_CWORD</code> variables are also set.
ac50fbac 11886When the function or command is invoked, the first argument ($1) is the
17345e5a 11887name of the command whose arguments are being completed, the
ac50fbac
CR
11888second argument ($2) is the word being completed, and the third argument
11889($3) is the word preceding the word being completed on the current command
11890line.
17345e5a
JA
11891No filtering of the generated completions against the word being completed
11892is performed; the function or command has complete freedom in generating
11893the matches.
a0c0a00f
CR
11894</p>
11895<p>Any function specified with <samp>-F</samp> is invoked first.
17345e5a 11896The function may use any of the shell facilities, including the
a0c0a00f
CR
11897<code>compgen</code> and <code>compopt</code> builtins described below
11898(see <a href="#Programmable-Completion-Builtins">Programmable Completion Builtins</a>), to generate the matches.
11899It must put the possible completions in the <code>COMPREPLY</code> array
ac50fbac 11900variable, one per array element.
a0c0a00f
CR
11901</p>
11902<p>Next, any command specified with the <samp>-C</samp> option is invoked
17345e5a
JA
11903in an environment equivalent to command substitution.
11904It should print a list of completions, one per line, to
11905the standard output.
11906Backslash may be used to escape a newline, if necessary.
a0c0a00f
CR
11907</p>
11908<p>After all of the possible completions are generated, any filter
11909specified with the <samp>-X</samp> option is applied to the list.
11910The filter is a pattern as used for pathname expansion; a &lsquo;<samp>&amp;</samp>&rsquo;
17345e5a 11911in the pattern is replaced with the text of the word being completed.
a0c0a00f 11912A literal &lsquo;<samp>&amp;</samp>&rsquo; may be escaped with a backslash; the backslash
17345e5a
JA
11913is removed before attempting a match.
11914Any completion that matches the pattern will be removed from the list.
a0c0a00f 11915A leading &lsquo;<samp>!</samp>&rsquo; negates the pattern; in this case any completion
17345e5a 11916not matching the pattern will be removed.
a0c0a00f
CR
11917If the <code>nocasematch</code> shell option
11918(see the description of <code>shopt</code> in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>)
11919is enabled, the match is performed without regard to the case
11920of alphabetic characters.
11921</p>
11922<p>Finally, any prefix and suffix specified with the <samp>-P</samp> and <samp>-S</samp>
17345e5a
JA
11923options are added to each member of the completion list, and the result is
11924returned to the Readline completion code as the list of possible
11925completions.
a0c0a00f
CR
11926</p>
11927<p>If the previously-applied actions do not generate any matches, and the
11928<samp>-o dirnames</samp> option was supplied to <code>complete</code> when the
17345e5a 11929compspec was defined, directory name completion is attempted.
a0c0a00f
CR
11930</p>
11931<p>If the <samp>-o plusdirs</samp> option was supplied to <code>complete</code> when
17345e5a
JA
11932the compspec was defined, directory name completion is attempted and any
11933matches are added to the results of the other actions.
a0c0a00f
CR
11934</p>
11935<p>By default, if a compspec is found, whatever it generates is returned to
17345e5a
JA
11936the completion code as the full set of possible completions.
11937The default Bash completions are not attempted, and the Readline default
11938of filename completion is disabled.
a0c0a00f 11939If the <samp>-o bashdefault</samp> option was supplied to <code>complete</code> when
17345e5a
JA
11940the compspec was defined, the default Bash completions are attempted
11941if the compspec generates no matches.
a0c0a00f
CR
11942If the <samp>-o default</samp> option was supplied to <code>complete</code> when the
11943compspec was defined, Readline&rsquo;s default completion will be performed
17345e5a
JA
11944if the compspec (and, if attempted, the default Bash completions)
11945generate no matches.
a0c0a00f
CR
11946</p>
11947<p>When a compspec indicates that directory name completion is desired,
17345e5a
JA
11948the programmable completion functions force Readline to append a slash
11949to completed names which are symbolic links to directories, subject to
a0c0a00f
CR
11950the value of the <var>mark-directories</var> Readline variable, regardless
11951of the setting of the <var>mark-symlinked-directories</var> Readline variable.
11952</p>
11953<p>There is some support for dynamically modifying completions. This is
0001803f 11954most useful when used in combination with a default completion specified
a0c0a00f 11955with <samp>-D</samp>. It&rsquo;s possible for shell functions executed as completion
0001803f
CR
11956handlers to indicate that completion should be retried by returning an
11957exit status of 124. If a shell function returns 124, and changes
11958the compspec associated with the command on which completion is being
11959attempted (supplied as the first argument when the function is executed),
11960programmable completion restarts from the beginning, with an
495aee44 11961attempt to find a new compspec for that command. This allows a set of
0001803f
CR
11962completions to be built dynamically as completion is attempted, rather than
11963being loaded all at once.
a0c0a00f
CR
11964</p>
11965<p>For instance, assuming that there is a library of compspecs, each kept in a
0001803f
CR
11966file corresponding to the name of the command, the following default
11967completion function would load completions dynamically:
a0c0a00f
CR
11968</p>
11969<div class="example">
11970<pre class="example">_completion_loader()
0001803f 11971{
a0c0a00f 11972 . &quot;/etc/bash_completion.d/$1.sh&quot; &gt;/dev/null 2&gt;&amp;1 &amp;&amp; return 124
0001803f 11973}
ac50fbac 11974complete -D -F _completion_loader -o bashdefault -o default
a0c0a00f
CR
11975</pre></div>
11976
11977<hr>
11978<a name="Programmable-Completion-Builtins"></a>
11979<div class="header">
11980<p>
11981Next: <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>
11982</div>
11983<a name="Programmable-Completion-Builtins-1"></a>
11984<h3 class="section">8.7 Programmable Completion Builtins</h3>
11985<a name="index-completion-builtins"></a>
11986
11987<p>Three builtin commands are available to manipulate the programmable completion
ac50fbac
CR
11988facilities: one to specify how the arguments to a particular command are to
11989be completed, and two to modify the completion as it is happening.
a0c0a00f
CR
11990</p>
11991<dl compact="compact">
11992<dt><code>compgen</code></dt>
11993<dd><a name="index-compgen"></a>
11994<div class="example">
11995<pre class="example"><code>compgen [<var>option</var>] [<var>word</var>]</code>
11996</pre></div>
11997
11998<p>Generate possible completion matches for <var>word</var> according to
11999the <var>option</var>s, which may be any option accepted by the
12000<code>complete</code>
12001builtin with the exception of <samp>-p</samp> and <samp>-r</samp>, and write
17345e5a 12002the matches to the standard output.
a0c0a00f 12003When using the <samp>-F</samp> or <samp>-C</samp> options, the various shell variables
17345e5a
JA
12004set by the programmable completion facilities, while available, will not
12005have useful values.
a0c0a00f
CR
12006</p>
12007<p>The matches will be generated in the same way as if the programmable
17345e5a
JA
12008completion code had generated them directly from a completion specification
12009with the same flags.
a0c0a00f 12010If <var>word</var> is specified, only those completions matching <var>word</var>
17345e5a 12011will be displayed.
a0c0a00f
CR
12012</p>
12013<p>The return value is true unless an invalid option is supplied, or no
17345e5a 12014matches were generated.
a0c0a00f
CR
12015</p>
12016</dd>
12017<dt><code>complete</code></dt>
12018<dd><a name="index-complete"></a>
12019<div class="example">
2f5dfe5a
CR
12020<pre class="example"><code>complete [-abcdefgjksuv] [-o <var>comp-option</var>] [-DEI] [-A <var>action</var>] [-G <var>globpat</var>]
12021[-W <var>wordlist</var>] [-F <var>function</var>] [-C <var>command</var>] [-X <var>filterpat</var>]
a0c0a00f 12022[-P <var>prefix</var>] [-S <var>suffix</var>] <var>name</var> [<var>name</var> &hellip;]</code>
2f5dfe5a 12023<code>complete -pr [-DEI] [<var>name</var> &hellip;]</code>
a0c0a00f
CR
12024</pre></div>
12025
12026<p>Specify how arguments to each <var>name</var> should be completed.
12027If the <samp>-p</samp> option is supplied, or if no options are supplied, existing
17345e5a
JA
12028completion specifications are printed in a way that allows them to be
12029reused as input.
a0c0a00f
CR
12030The <samp>-r</samp> option removes a completion specification for
12031each <var>name</var>, or, if no <var>name</var>s are supplied, all
17345e5a 12032completion specifications.
2f5dfe5a 12033The <samp>-D</samp> option indicates that other supplied options and actions should
a0c0a00f 12034apply to the &ldquo;default&rdquo; command completion; that is, completion attempted
0001803f 12035on a command for which no completion has previously been defined.
2f5dfe5a 12036The <samp>-E</samp> option indicates that other supplied options and actions should
a0c0a00f 12037apply to &ldquo;empty&rdquo; command completion; that is, completion attempted on a
17345e5a 12038blank line.
2f5dfe5a
CR
12039The <samp>-I</samp> option indicates that other supplied options and actions should
12040apply to completion on the inital non-assignment word on the line, or after a
12041command delimiter such as &lsquo;<samp>;</samp>&rsquo; or &lsquo;<samp>|</samp>&rsquo;, which is usually command
12042name completion.
12043If multiple options are supplied, the <samp>-D</samp> option takes precedence
12044over <samp>-E</samp>, and both take precedence over <samp>-I</samp>.
12045If any of <samp>-D</samp>, <samp>-E</samp>, or <samp>-I</samp> are supplied, any other
12046<var>name</var> arguments are ignored; these completions only apply to the case
12047specified by the option.
a0c0a00f
CR
12048</p>
12049<p>The process of applying these completion specifications when word completion
2f5dfe5a 12050is attempted is described above (see <a href="#Programmable-Completion">Programmable Completion</a>).
a0c0a00f
CR
12051</p>
12052<p>Other options, if specified, have the following meanings.
12053The arguments to the <samp>-G</samp>, <samp>-W</samp>, and <samp>-X</samp> options
12054(and, if necessary, the <samp>-P</samp> and <samp>-S</samp> options)
17345e5a 12055should be quoted to protect them from expansion before the
a0c0a00f
CR
12056<code>complete</code> builtin is invoked.
12057</p>
17345e5a 12058
a0c0a00f
CR
12059<dl compact="compact">
12060<dt><code>-o <var>comp-option</var></code></dt>
12061<dd><p>The <var>comp-option</var> controls several aspects of the compspec&rsquo;s behavior
17345e5a 12062beyond the simple generation of completions.
a0c0a00f
CR
12063<var>comp-option</var> may be one of:
12064</p>
12065<dl compact="compact">
12066<dt><code>bashdefault</code></dt>
12067<dd><p>Perform the rest of the default Bash completions if the compspec
17345e5a 12068generates no matches.
a0c0a00f
CR
12069</p>
12070</dd>
12071<dt><code>default</code></dt>
12072<dd><p>Use Readline&rsquo;s default filename completion if the compspec generates
17345e5a 12073no matches.
a0c0a00f
CR
12074</p>
12075</dd>
12076<dt><code>dirnames</code></dt>
12077<dd><p>Perform directory name completion if the compspec generates no matches.
12078</p>
12079</dd>
12080<dt><code>filenames</code></dt>
12081<dd><p>Tell Readline that the compspec generates filenames, so it can perform any
2f5dfe5a 12082filename-specific processing (like adding a slash to directory names,
17345e5a
JA
12083quoting special characters, or suppressing trailing spaces).
12084This option is intended to be used with shell functions specified
a0c0a00f
CR
12085with <samp>-F</samp>.
12086</p>
12087</dd>
12088<dt><code>noquote</code></dt>
12089<dd><p>Tell Readline not to quote the completed words if they are filenames
ac50fbac 12090(quoting filenames is the default).
a0c0a00f
CR
12091</p>
12092</dd>
12093<dt><code>nosort</code></dt>
12094<dd><p>Tell Readline not to sort the list of possible completions alphabetically.
12095</p>
12096</dd>
12097<dt><code>nospace</code></dt>
12098<dd><p>Tell Readline not to append a space (the default) to words completed at
17345e5a 12099the end of the line.
a0c0a00f
CR
12100</p>
12101</dd>
12102<dt><code>plusdirs</code></dt>
12103<dd><p>After any matches defined by the compspec are generated,
17345e5a
JA
12104directory name completion is attempted and any
12105matches are added to the results of the other actions.
a0c0a00f
CR
12106</p>
12107</dd>
12108</dl>
17345e5a 12109
a0c0a00f
CR
12110</dd>
12111<dt><code>-A <var>action</var></code></dt>
12112<dd><p>The <var>action</var> may be one of the following to generate a list of possible
17345e5a 12113completions:
a0c0a00f
CR
12114</p>
12115<dl compact="compact">
12116<dt><code>alias</code></dt>
12117<dd><p>Alias names. May also be specified as <samp>-a</samp>.
12118</p>
12119</dd>
12120<dt><code>arrayvar</code></dt>
12121<dd><p>Array variable names.
12122</p>
12123</dd>
12124<dt><code>binding</code></dt>
12125<dd><p>Readline key binding names (see <a href="#Bindable-Readline-Commands">Bindable Readline Commands</a>).
12126</p>
12127</dd>
12128<dt><code>builtin</code></dt>
12129<dd><p>Names of shell builtin commands. May also be specified as <samp>-b</samp>.
12130</p>
12131</dd>
12132<dt><code>command</code></dt>
12133<dd><p>Command names. May also be specified as <samp>-c</samp>.
12134</p>
12135</dd>
12136<dt><code>directory</code></dt>
12137<dd><p>Directory names. May also be specified as <samp>-d</samp>.
12138</p>
12139</dd>
12140<dt><code>disabled</code></dt>
12141<dd><p>Names of disabled shell builtins.
12142</p>
12143</dd>
12144<dt><code>enabled</code></dt>
12145<dd><p>Names of enabled shell builtins.
12146</p>
12147</dd>
12148<dt><code>export</code></dt>
12149<dd><p>Names of exported shell variables. May also be specified as <samp>-e</samp>.
12150</p>
12151</dd>
12152<dt><code>file</code></dt>
12153<dd><p>File names. May also be specified as <samp>-f</samp>.
12154</p>
12155</dd>
12156<dt><code>function</code></dt>
12157<dd><p>Names of shell functions.
12158</p>
12159</dd>
12160<dt><code>group</code></dt>
12161<dd><p>Group names. May also be specified as <samp>-g</samp>.
12162</p>
12163</dd>
12164<dt><code>helptopic</code></dt>
12165<dd><p>Help topics as accepted by the <code>help</code> builtin (see <a href="#Bash-Builtins">Bash Builtins</a>).
12166</p>
12167</dd>
12168<dt><code>hostname</code></dt>
12169<dd><p>Hostnames, as taken from the file specified by the
12170<code>HOSTFILE</code> shell variable (see <a href="#Bash-Variables">Bash Variables</a>).
12171</p>
12172</dd>
12173<dt><code>job</code></dt>
12174<dd><p>Job names, if job control is active. May also be specified as <samp>-j</samp>.
12175</p>
12176</dd>
12177<dt><code>keyword</code></dt>
12178<dd><p>Shell reserved words. May also be specified as <samp>-k</samp>.
12179</p>
12180</dd>
12181<dt><code>running</code></dt>
12182<dd><p>Names of running jobs, if job control is active.
12183</p>
12184</dd>
12185<dt><code>service</code></dt>
12186<dd><p>Service names. May also be specified as <samp>-s</samp>.
12187</p>
12188</dd>
12189<dt><code>setopt</code></dt>
12190<dd><p>Valid arguments for the <samp>-o</samp> option to the <code>set</code> builtin
12191(see <a href="#The-Set-Builtin">The Set Builtin</a>).
12192</p>
12193</dd>
12194<dt><code>shopt</code></dt>
12195<dd><p>Shell option names as accepted by the <code>shopt</code> builtin
12196(see <a href="#Bash-Builtins">Bash Builtins</a>).
12197</p>
12198</dd>
12199<dt><code>signal</code></dt>
12200<dd><p>Signal names.
12201</p>
12202</dd>
12203<dt><code>stopped</code></dt>
12204<dd><p>Names of stopped jobs, if job control is active.
12205</p>
12206</dd>
12207<dt><code>user</code></dt>
12208<dd><p>User names. May also be specified as <samp>-u</samp>.
12209</p>
12210</dd>
12211<dt><code>variable</code></dt>
12212<dd><p>Names of all shell variables. May also be specified as <samp>-v</samp>.
12213</p></dd>
12214</dl>
12215
12216</dd>
12217<dt><code>-C <var>command</var></code></dt>
12218<dd><p><var>command</var> is executed in a subshell environment, and its output is
495aee44 12219used as the possible completions.
a0c0a00f
CR
12220</p>
12221</dd>
12222<dt><code>-F <var>function</var></code></dt>
12223<dd><p>The shell function <var>function</var> is executed in the current shell
495aee44 12224environment.
ac50fbac
CR
12225When it is executed, $1 is the name of the command whose arguments are
12226being completed, $2 is the word being completed, and $3 is the word
12227preceding the word being completed, as described above
a0c0a00f 12228(see <a href="#Programmable-Completion">Programmable Completion</a>).
495aee44 12229When it finishes, the possible completions are retrieved from the value
a0c0a00f
CR
12230of the <code>COMPREPLY</code> array variable.
12231</p>
12232</dd>
12233<dt><code>-G <var>globpat</var></code></dt>
12234<dd><p>The filename expansion pattern <var>globpat</var> is expanded to generate
17345e5a 12235the possible completions.
a0c0a00f
CR
12236</p>
12237</dd>
12238<dt><code>-P <var>prefix</var></code></dt>
12239<dd><p><var>prefix</var> is added at the beginning of each possible completion
495aee44 12240after all other options have been applied.
a0c0a00f
CR
12241</p>
12242</dd>
12243<dt><code>-S <var>suffix</var></code></dt>
12244<dd><p><var>suffix</var> is appended to each possible completion
495aee44 12245after all other options have been applied.
a0c0a00f
CR
12246</p>
12247</dd>
12248<dt><code>-W <var>wordlist</var></code></dt>
12249<dd><p>The <var>wordlist</var> is split using the characters in the
12250<code>IFS</code> special variable as delimiters, and each resultant word
17345e5a
JA
12251is expanded.
12252The possible completions are the members of the resultant list which
12253match the word being completed.
a0c0a00f
CR
12254</p>
12255</dd>
12256<dt><code>-X <var>filterpat</var></code></dt>
12257<dd><p><var>filterpat</var> is a pattern as used for filename expansion.
17345e5a
JA
12258It is applied to the list of possible completions generated by the
12259preceding options and arguments, and each completion matching
a0c0a00f
CR
12260<var>filterpat</var> is removed from the list.
12261A leading &lsquo;<samp>!</samp>&rsquo; in <var>filterpat</var> negates the pattern; in this
12262case, any completion not matching <var>filterpat</var> is removed.
12263</p></dd>
12264</dl>
12265
12266<p>The return value is true unless an invalid option is supplied, an option
12267other than <samp>-p</samp> or <samp>-r</samp> is supplied without a <var>name</var>
17345e5a 12268argument, an attempt is made to remove a completion specification for
a0c0a00f 12269a <var>name</var> for which no specification exists, or
17345e5a 12270an error occurs adding a completion specification.
a0c0a00f
CR
12271</p>
12272</dd>
12273<dt><code>compopt</code></dt>
12274<dd><a name="index-compopt"></a>
12275<div class="example">
2f5dfe5a 12276<pre class="example"><code>compopt</code> [-o <var>option</var>] [-DEI] [+o <var>option</var>] [<var>name</var>]
a0c0a00f
CR
12277</pre></div>
12278<p>Modify completion options for each <var>name</var> according to the
12279<var>option</var>s, or for the currently-executing completion if no <var>name</var>s
17345e5a 12280are supplied.
a0c0a00f
CR
12281If no <var>option</var>s are given, display the completion options for each
12282<var>name</var> or the current completion.
12283The possible values of <var>option</var> are those valid for the <code>complete</code>
17345e5a 12284builtin described above.
2f5dfe5a 12285The <samp>-D</samp> option indicates that other supplied options should
a0c0a00f 12286apply to the &ldquo;default&rdquo; command completion; that is, completion attempted
0001803f 12287on a command for which no completion has previously been defined.
2f5dfe5a 12288The <samp>-E</samp> option indicates that other supplied options should
a0c0a00f 12289apply to &ldquo;empty&rdquo; command completion; that is, completion attempted on a
0001803f 12290blank line.
2f5dfe5a
CR
12291The <samp>-I</samp> option indicates that other supplied options should
12292apply to completion on the inital non-assignment word on the line, or after a
12293command delimiter such as &lsquo;<samp>;</samp>&rsquo; or &lsquo;<samp>|</samp>&rsquo;, which is usually command
12294name completion.
a0c0a00f 12295</p>
2f5dfe5a
CR
12296<p>If multiple options are supplied, the <samp>-D</samp> option takes precedence
12297over <samp>-E</samp>, and both take precedence over <samp>-I</samp>
a0c0a00f
CR
12298</p>
12299<p>The return value is true unless an invalid option is supplied, an attempt
12300is made to modify the options for a <var>name</var> for which no completion
ac50fbac 12301specification exists, or an output error occurs.
a0c0a00f
CR
12302</p>
12303</dd>
12304</dl>
12305
12306<hr>
12307<a name="A-Programmable-Completion-Example"></a>
12308<div class="header">
12309<p>
12310Previous: <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>
12311</div>
12312<a name="A-Programmable-Completion-Example-1"></a>
12313<h3 class="section">8.8 A Programmable Completion Example</h3>
12314
12315<p>The most common way to obtain additional completion functionality beyond
12316the default actions <code>complete</code> and <code>compgen</code> provide is to use
12317a shell function and bind it to a particular command using <code>complete -F</code>.
12318</p>
12319<p>The following function provides completions for the <code>cd</code> builtin.
ac50fbac 12320It is a reasonably good example of what shell functions must do when
9a51695b 12321used for completion. This function uses the word passed as <code>$2</code>
ac50fbac 12322to determine the directory name to complete. You can also use the
a0c0a00f
CR
12323<code>COMP_WORDS</code> array variable; the current word is indexed by the
12324<code>COMP_CWORD</code> variable.
12325</p>
12326<p>The function relies on the <code>complete</code> and <code>compgen</code> builtins
12327to do much of the work, adding only the things that the Bash <code>cd</code>
ac50fbac 12328does beyond accepting basic directory names:
a0c0a00f
CR
12329tilde expansion (see <a href="#Tilde-Expansion">Tilde Expansion</a>),
12330searching directories in <var>$CDPATH</var>, which is described above
12331(see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>),
12332and basic support for the <code>cdable_vars</code> shell option
12333(see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>).
12334<code>_comp_cd</code> modifies the value of <var>IFS</var> so that it contains only
12335a newline to accommodate file names containing spaces and tabs &ndash;
12336<code>compgen</code> prints the possible completions it generates one per line.
12337</p>
12338<p>Possible completions go into the <var>COMPREPLY</var> array variable, one
ac50fbac
CR
12339completion per array element. The programmable completion system retrieves
12340the completions from there when the function returns.
a0c0a00f
CR
12341</p>
12342<div class="example">
12343<pre class="example"># A completion function for the cd builtin
ac50fbac
CR
12344# based on the cd completion function from the bash_completion package
12345_comp_cd()
12346{
12347 local IFS=$' \t\n' # normalize IFS
12348 local cur _skipdot _cdpath
12349 local i j k
12350
2f5dfe5a 12351 # Tilde expansion, which also expands tilde to full pathname
a0c0a00f
CR
12352 case &quot;$2&quot; in
12353 \~*) eval cur=&quot;$2&quot; ;;
ac50fbac
CR
12354 *) cur=$2 ;;
12355 esac
12356
12357 # no cdpath or absolute pathname -- straight directory completion
a0c0a00f 12358 if [[ -z &quot;${CDPATH:-}&quot; ]] || [[ &quot;$cur&quot; == @(./*|../*|/*) ]]; then
ac50fbac
CR
12359 # compgen prints paths one per line; could also use while loop
12360 IFS=$'\n'
a0c0a00f 12361 COMPREPLY=( $(compgen -d -- &quot;$cur&quot;) )
ac50fbac
CR
12362 IFS=$' \t\n'
12363 # CDPATH+directories in the current directory if not in CDPATH
12364 else
12365 IFS=$'\n'
12366 _skipdot=false
12367 # preprocess CDPATH to convert null directory names to .
12368 _cdpath=${CDPATH/#:/.:}
12369 _cdpath=${_cdpath//::/:.:}
12370 _cdpath=${_cdpath/%:/:.}
12371 for i in ${_cdpath//:/$'\n'}; do
12372 if [[ $i -ef . ]]; then _skipdot=true; fi
a0c0a00f
CR
12373 k=&quot;${#COMPREPLY[@]}&quot;
12374 for j in $( compgen -d -- &quot;$i/$cur&quot; ); do
ac50fbac
CR
12375 COMPREPLY[k++]=${j#$i/} # cut off directory
12376 done
12377 done
a0c0a00f 12378 $_skipdot || COMPREPLY+=( $(compgen -d -- &quot;$cur&quot;) )
ac50fbac
CR
12379 IFS=$' \t\n'
12380 fi
12381
12382 # variable names if appropriate shell option set and no completions
a0c0a00f
CR
12383 if shopt -q cdable_vars &amp;&amp; [[ ${#COMPREPLY[@]} -eq 0 ]]; then
12384 COMPREPLY=( $(compgen -v -- &quot;$cur&quot;) )
ac50fbac
CR
12385 fi
12386
12387 return 0
12388}
a0c0a00f 12389</pre></div>
ac50fbac 12390
a0c0a00f
CR
12391<p>We install the completion function using the <samp>-F</samp> option to
12392<code>complete</code>:
12393</p>
12394<div class="example">
12395<pre class="example"># Tell readline to quote appropriate and append slashes to directories;
ac50fbac
CR
12396# use the bash default completion for other arguments
12397complete -o filenames -o nospace -o bashdefault -F _comp_cd cd
a0c0a00f 12398</pre></div>
ac50fbac 12399
a0c0a00f 12400<p>Since we&rsquo;d like Bash and Readline to take care of some
ac50fbac 12401of the other details for us, we use several other options to tell Bash
a0c0a00f 12402and Readline what to do. The <samp>-o filenames</samp> option tells Readline
ac50fbac
CR
12403that the possible completions should be treated as filenames, and quoted
12404appropriately. That option will also cause Readline to append a slash to
12405filenames it can determine are directories (which is why we might want to
a0c0a00f
CR
12406extend <code>_comp_cd</code> to append a slash if we&rsquo;re using directories found
12407via <var>CDPATH</var>: Readline can&rsquo;t tell those completions are directories).
12408The <samp>-o nospace</samp> option tells Readline to not append a space
ac50fbac 12409character to the directory name, in case we want to append to it.
a0c0a00f
CR
12410The <samp>-o bashdefault</samp> option brings in the rest of the &quot;Bash default&quot;
12411completions &ndash; possible completion that Bash adds to the default Readline
ac50fbac 12412set. These include things like command name completion, variable completion
a0c0a00f
CR
12413for words beginning with &lsquo;<samp>{</samp>&rsquo;, completions containing pathname
12414expansion patterns (see <a href="#Filename-Expansion">Filename Expansion</a>), and so on.
12415</p>
12416<p>Once installed using <code>complete</code>, <code>_comp_cd</code> will be called every
12417time we attempt word completion for a <code>cd</code> command.
12418</p>
12419<p>Many more examples &ndash; an extensive collection of completions for most of
12420the common GNU, Unix, and Linux commands &ndash; are available as part of the
ac50fbac
CR
12421bash_completion project. This is installed by default on many GNU/Linux
12422distributions. Originally written by Ian Macdonald, the project now lives
a0c0a00f 12423at <a href="http://bash-completion.alioth.debian.org/">http://bash-completion.alioth.debian.org/</a>. There are ports for
ac50fbac 12424other systems such as Solaris and Mac OS X.
a0c0a00f
CR
12425</p>
12426<p>An older version of the bash_completion package is distributed with bash
12427in the <samp>examples/complete</samp> subdirectory.
12428</p>
12429<a name="index-History_002c-how-to-use"></a>
12430
12431<hr>
12432<a name="Using-History-Interactively"></a>
12433<div class="header">
12434<p>
12435Next: <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>
12436</div>
12437<a name="Using-History-Interactively-1"></a>
12438<h2 class="chapter">9 Using History Interactively</h2>
12439
12440
12441<p>This chapter describes how to use the <small>GNU</small> History Library
12442interactively, from a user&rsquo;s standpoint.
12443It should be considered a user&rsquo;s guide.
12444For information on using the <small>GNU</small> History Library in other programs,
12445see the <small>GNU</small> Readline Library Manual.
12446</p>
12447<table class="menu" border="0" cellspacing="0">
12448<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
12449 history.
12450</td></tr>
12451<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
12452 the command history.
12453</td></tr>
12454<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.
12455</td></tr>
12456</table>
12457
12458<hr>
12459<a name="Bash-History-Facilities"></a>
12460<div class="header">
12461<p>
12462Next: <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>
12463</div>
12464<a name="Bash-History-Facilities-1"></a>
12465<h3 class="section">9.1 Bash History Facilities</h3>
12466<a name="index-command-history"></a>
12467<a name="index-history-list"></a>
12468
12469<p>When the <samp>-o history</samp> option to the <code>set</code> builtin
12470is enabled (see <a href="#The-Set-Builtin">The Set Builtin</a>),
12471the shell provides access to the <em>command history</em>,
17345e5a 12472the list of commands previously typed.
a0c0a00f 12473The value of the <code>HISTSIZE</code> shell variable is used as the
17345e5a 12474number of commands to save in a history list.
a0c0a00f 12475The text of the last <code>$HISTSIZE</code>
17345e5a
JA
12476commands (default 500) is saved.
12477The shell stores each command in the history list prior to
12478parameter and variable expansion
12479but after history expansion is performed, subject to the
12480values of the shell variables
a0c0a00f
CR
12481<code>HISTIGNORE</code> and <code>HISTCONTROL</code>.
12482</p>
12483<p>When the shell starts up, the history is initialized from the
12484file named by the <code>HISTFILE</code> variable (default <samp>~/.bash_history</samp>).
12485The file named by the value of <code>HISTFILE</code> is truncated, if
17345e5a 12486necessary, to contain no more than the number of lines specified by
a0c0a00f 12487the value of the <code>HISTFILESIZE</code> variable.
ac50fbac 12488When a shell with history enabled exits, the last
a0c0a00f
CR
12489<code>$HISTSIZE</code> lines are copied from the history list to the file
12490named by <code>$HISTFILE</code>.
12491If the <code>histappend</code> shell option is set (see <a href="#Bash-Builtins">Bash Builtins</a>),
17345e5a
JA
12492the lines are appended to the history file,
12493otherwise the history file is overwritten.
a0c0a00f 12494If <code>HISTFILE</code>
ac50fbac
CR
12495is unset, or if the history file is unwritable, the history is not saved.
12496After saving the history, the history file is truncated
a0c0a00f
CR
12497to contain no more than <code>$HISTFILESIZE</code> lines.
12498If <code>HISTFILESIZE</code> is unset, or set to null, a non-numeric value, or
ac50fbac 12499a numeric value less than zero, the history file is not truncated.
a0c0a00f
CR
12500</p>
12501<p>If the <code>HISTTIMEFORMAT</code> is set, the time stamp information
17345e5a
JA
12502associated with each history entry is written to the history file,
12503marked with the history comment character.
12504When the history file is read, lines beginning with the history
12505comment character followed immediately by a digit are interpreted
a0c0a00f
CR
12506as timestamps for the following history entry.
12507</p>
12508<p>The builtin command <code>fc</code> may be used to list or edit and re-execute
17345e5a 12509a portion of the history list.
a0c0a00f 12510The <code>history</code> builtin may be used to display or modify the history
17345e5a
JA
12511list and manipulate the history file.
12512When using command-line editing, search commands
12513are available in each editing mode that provide access to the
a0c0a00f
CR
12514history list (see <a href="#Commands-For-History">Commands For History</a>).
12515</p>
12516<p>The shell allows control over which commands are saved on the history
12517list. The <code>HISTCONTROL</code> and <code>HISTIGNORE</code>
17345e5a
JA
12518variables may be set to cause the shell to save only a subset of the
12519commands entered.
a0c0a00f 12520The <code>cmdhist</code>
17345e5a
JA
12521shell option, if enabled, causes the shell to attempt to save each
12522line of a multi-line command in the same history entry, adding
12523semicolons where necessary to preserve syntactic correctness.
a0c0a00f 12524The <code>lithist</code>
17345e5a
JA
12525shell option causes the shell to save the command with embedded newlines
12526instead of semicolons.
a0c0a00f 12527The <code>shopt</code> builtin is used to set these options.
9a51695b 12528See <a href="#The-Shopt-Builtin">The Shopt Builtin</a>, for a description of <code>shopt</code>.
a0c0a00f
CR
12529</p>
12530<hr>
12531<a name="Bash-History-Builtins"></a>
12532<div class="header">
12533<p>
12534Next: <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>
12535</div>
12536<a name="Bash-History-Builtins-1"></a>
12537<h3 class="section">9.2 Bash History Builtins</h3>
12538<a name="index-history-builtins"></a>
12539
12540<p>Bash provides two builtin commands which manipulate the
17345e5a 12541history list and history file.
a0c0a00f
CR
12542</p>
12543<dl compact="compact">
12544<dt><code>fc</code></dt>
12545<dd><a name="index-fc"></a>
12546<div class="example">
12547<pre class="example"><code>fc [-e <var>ename</var>] [-lnr] [<var>first</var>] [<var>last</var>]</code>
12548<code>fc -s [<var>pat</var>=<var>rep</var>] [<var>command</var>]</code>
12549</pre></div>
12550
12551<p>The first form selects a range of commands from <var>first</var> to
12552<var>last</var> from the history list and displays or edits and re-executes
ac50fbac 12553them.
a0c0a00f
CR
12554Both <var>first</var> and
12555<var>last</var> may be specified as a string (to locate the most recent
17345e5a
JA
12556command beginning with that string) or as a number (an index into the
12557history list, where a negative number is used as an offset from the
9a51695b
CR
12558current command number). If <var>last</var> is not specified, it is set to
12559<var>first</var>. If <var>first</var> is not specified, it is set to the previous
a0c0a00f
CR
12560command for editing and -16 for listing. If the <samp>-l</samp> flag is
12561given, the commands are listed on standard output. The <samp>-n</samp> flag
12562suppresses the command numbers when listing. The <samp>-r</samp> flag
17345e5a 12563reverses the order of the listing. Otherwise, the editor given by
a0c0a00f
CR
12564<var>ename</var> is invoked on a file containing those commands. If
12565<var>ename</var> is not given, the value of the following variable expansion
12566is used: <code>${FCEDIT:-${EDITOR:-vi}}</code>. This says to use the
12567value of the <code>FCEDIT</code> variable if set, or the value of the
12568<code>EDITOR</code> variable if that is set, or <code>vi</code> if neither is set.
17345e5a 12569When editing is complete, the edited commands are echoed and executed.
a0c0a00f
CR
12570</p>
12571<p>In the second form, <var>command</var> is re-executed after each instance
12572of <var>pat</var> in the selected command is replaced by <var>rep</var>.
12573<var>command</var> is intepreted the same as <var>first</var> above.
12574</p>
12575<p>A useful alias to use with the <code>fc</code> command is <code>r='fc -s'</code>, so
12576that typing &lsquo;<samp>r cc</samp>&rsquo; runs the last command beginning with <code>cc</code>
12577and typing &lsquo;<samp>r</samp>&rsquo; re-executes the last command (see <a href="#Aliases">Aliases</a>).
12578</p>
12579</dd>
12580<dt><code>history</code></dt>
12581<dd><a name="index-history"></a>
12582<div class="example">
12583<pre class="example">history [<var>n</var>]
17345e5a 12584history -c
a0c0a00f 12585history -d <var>offset</var>
9a51695b 12586history -d <var>start</var>-<var>end</var>
a0c0a00f
CR
12587history [-anrw] [<var>filename</var>]
12588history -ps <var>arg</var>
12589</pre></div>
12590
12591<p>With no options, display the history list with line numbers.
12592Lines prefixed with a &lsquo;<samp>*</samp>&rsquo; have been modified.
12593An argument of <var>n</var> lists only the last <var>n</var> lines.
12594If the shell variable <code>HISTTIMEFORMAT</code> is set and not null,
12595it is used as a format string for <var>strftime</var> to display
17345e5a
JA
12596the time stamp associated with each displayed history entry.
12597No intervening blank is printed between the formatted time stamp
12598and the history line.
a0c0a00f
CR
12599</p>
12600<p>Options, if supplied, have the following meanings:
12601</p>
12602<dl compact="compact">
12603<dt><code>-c</code></dt>
12604<dd><p>Clear the history list. This may be combined
17345e5a 12605with the other options to replace the history list completely.
a0c0a00f
CR
12606</p>
12607</dd>
12608<dt><code>-d <var>offset</var></code></dt>
12609<dd><p>Delete the history entry at position <var>offset</var>.
9a51695b
CR
12610If <var>offset</var> is positive, it should be specified as it appears when
12611the history is displayed.
12612If <var>offset</var> is negative, it is interpreted as relative to one greater
12613than the last history position, so negative indices count back from the
12614end of the history, and an index of &lsquo;<samp>-1</samp>&rsquo; refers to the current
12615<code>history -d</code> command.
12616</p>
12617</dd>
12618<dt><code>-d <var>start</var>-<var>end</var></code></dt>
12619<dd><p>Delete the history entries between positions <var>start</var> and <var>end</var>,
12620inclusive. Positive and negative values for <var>start</var> and <var>end</var>
12621are interpreted as described above.
a0c0a00f
CR
12622</p>
12623</dd>
12624<dt><code>-a</code></dt>
12625<dd><p>Append the new history lines to the history file.
12626These are history lines entered since the beginning of the current
12627Bash session, but not already appended to the history file.
12628</p>
12629</dd>
12630<dt><code>-n</code></dt>
12631<dd><p>Append the history lines not already read from the history file
17345e5a
JA
12632to the current history list. These are lines appended to the history
12633file since the beginning of the current Bash session.
a0c0a00f
CR
12634</p>
12635</dd>
12636<dt><code>-r</code></dt>
12637<dd><p>Read the history file and append its contents to
17345e5a 12638the history list.
a0c0a00f
CR
12639</p>
12640</dd>
12641<dt><code>-w</code></dt>
12642<dd><p>Write out the current history list to the history file.
12643</p>
12644</dd>
12645<dt><code>-p</code></dt>
12646<dd><p>Perform history substitution on the <var>arg</var>s and display the result
17345e5a 12647on the standard output, without storing the results in the history list.
a0c0a00f
CR
12648</p>
12649</dd>
12650<dt><code>-s</code></dt>
12651<dd><p>The <var>arg</var>s are added to the end of
17345e5a 12652the history list as a single entry.
a0c0a00f
CR
12653</p>
12654</dd>
12655</dl>
17345e5a 12656
a0c0a00f
CR
12657<p>When any of the <samp>-w</samp>, <samp>-r</samp>, <samp>-a</samp>, or <samp>-n</samp> options is
12658used, if <var>filename</var>
17345e5a 12659is given, then it is used as the history file. If not, then
a0c0a00f
CR
12660the value of the <code>HISTFILE</code> variable is used.
12661</p>
12662</dd>
12663</dl>
12664
12665<hr>
12666<a name="History-Interaction"></a>
12667<div class="header">
12668<p>
12669Previous: <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>
12670</div>
12671<a name="History-Expansion"></a>
12672<h3 class="section">9.3 History Expansion</h3>
12673<a name="index-history-expansion"></a>
12674
12675<p>The History library provides a history expansion feature that is similar
12676to the history expansion provided by <code>csh</code>. This section
17345e5a 12677describes the syntax used to manipulate the history information.
a0c0a00f
CR
12678</p>
12679<p>History expansions introduce words from the history list into
17345e5a
JA
12680the input stream, making it easy to repeat commands, insert the
12681arguments to a previous command into the current input line, or
12682fix errors in previous commands quickly.
a0c0a00f
CR
12683</p>
12684<p>History expansion is performed immediately after a complete line
9a51695b 12685is read, before the shell breaks it into words, and is performed
2f5dfe5a
CR
12686on each line individually. Bash attempts to inform the history
12687expansion functions about quoting still in effect from previous lines.
a0c0a00f
CR
12688</p>
12689<p>History expansion takes place in two parts. The first is to determine
17345e5a
JA
12690which line from the history list should be used during substitution.
12691The second is to select portions of that line for inclusion into the
12692current one. The line selected from the history is called the
a0c0a00f
CR
12693<em>event</em>, and the portions of that line that are acted upon are
12694called <em>words</em>. Various <em>modifiers</em> are available to manipulate
17345e5a
JA
12695the selected words. The line is broken into words in the same fashion
12696that Bash does, so that several words
12697surrounded by quotes are considered one word.
12698History expansions are introduced by the appearance of the
a0c0a00f 12699history expansion character, which is &lsquo;<samp>!</samp>&rsquo; by default.
2f5dfe5a
CR
12700</p>
12701<p>History expansion implements shell-like quoting conventions:
12702a backslash can be used to remove the special handling for the next character;
12703single quotes enclose verbatim sequences of characters, and can be used to
12704inhibit history expansion;
12705and characters enclosed within double quotes may be subject to history
12706expansion, since backslash can escape the history expansion character,
12707but single quotes may not, since they are not treated specially within
12708double quotes.
12709</p>
12710<p>When using the shell, only &lsquo;<samp>\</samp>&rsquo; and &lsquo;<samp>'</samp>&rsquo; may be used to escape the
12711history expansion character, but the history expansion character is
a0c0a00f
CR
12712also treated as quoted if it immediately precedes the closing double quote
12713in a double-quoted string.
12714</p>
12715<p>Several shell options settable with the <code>shopt</code>
9a51695b 12716builtin (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>) may be used to tailor
17345e5a 12717the behavior of history expansion. If the
a0c0a00f 12718<code>histverify</code> shell option is enabled, and Readline
17345e5a
JA
12719is being used, history substitutions are not immediately passed to
12720the shell parser.
12721Instead, the expanded line is reloaded into the Readline
12722editing buffer for further modification.
a0c0a00f 12723If Readline is being used, and the <code>histreedit</code>
17345e5a
JA
12724shell option is enabled, a failed history expansion will be
12725reloaded into the Readline editing buffer for correction.
a0c0a00f 12726The <samp>-p</samp> option to the <code>history</code> builtin command
17345e5a 12727may be used to see what a history expansion will do before using it.
a0c0a00f 12728The <samp>-s</samp> option to the <code>history</code> builtin may be used to
17345e5a
JA
12729add commands to the end of the history list without actually executing
12730them, so that they are available for subsequent recall.
12731This is most useful in conjunction with Readline.
a0c0a00f
CR
12732</p>
12733<p>The shell allows control of the various characters used by the
12734history expansion mechanism with the <code>histchars</code> variable,
12735as explained above (see <a href="#Bash-Variables">Bash Variables</a>). The shell uses
17345e5a
JA
12736the history comment character to mark history timestamps when
12737writing the history file.
a0c0a00f
CR
12738</p>
12739<table class="menu" border="0" cellspacing="0">
12740<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.
12741</td></tr>
12742<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.
12743</td></tr>
12744<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.
12745</td></tr>
12746</table>
12747
12748<hr>
12749<a name="Event-Designators"></a>
12750<div class="header">
12751<p>
12752Next: <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>
12753</div>
12754<a name="Event-Designators-1"></a>
12755<h4 class="subsection">9.3.1 Event Designators</h4>
12756<a name="index-event-designators"></a>
12757
12758<p>An event designator is a reference to a command line entry in the
17345e5a 12759history list.
495aee44
CR
12760Unless the reference is absolute, events are relative to the current
12761position in the history list.
a0c0a00f
CR
12762<a name="index-history-events"></a>
12763</p>
12764<dl compact="compact">
12765<dt><code>!</code></dt>
12766<dd><p>Start a history substitution, except when followed by a space, tab,
12767the end of the line, &lsquo;<samp>=</samp>&rsquo; or &lsquo;<samp>(</samp>&rsquo; (when the
12768<code>extglob</code> shell option is enabled using the <code>shopt</code> builtin).
12769</p>
12770</dd>
12771<dt><code>!<var>n</var></code></dt>
12772<dd><p>Refer to command line <var>n</var>.
12773</p>
12774</dd>
12775<dt><code>!-<var>n</var></code></dt>
12776<dd><p>Refer to the command <var>n</var> lines back.
12777</p>
12778</dd>
12779<dt><code>!!</code></dt>
12780<dd><p>Refer to the previous command. This is a synonym for &lsquo;<samp>!-1</samp>&rsquo;.
12781</p>
12782</dd>
12783<dt><code>!<var>string</var></code></dt>
12784<dd><p>Refer to the most recent command
495aee44 12785preceding the current position in the history list
a0c0a00f
CR
12786starting with <var>string</var>.
12787</p>
12788</dd>
12789<dt><code>!?<var>string</var>[?]</code></dt>
12790<dd><p>Refer to the most recent command
495aee44 12791preceding the current position in the history list
a0c0a00f 12792containing <var>string</var>.
495aee44 12793The trailing
a0c0a00f 12794&lsquo;<samp>?</samp>&rsquo; may be omitted if the <var>string</var> is followed immediately by
17345e5a 12795a newline.
a0c0a00f
CR
12796</p>
12797</dd>
12798<dt><code>^<var>string1</var>^<var>string2</var>^</code></dt>
12799<dd><p>Quick Substitution. Repeat the last command, replacing <var>string1</var>
12800with <var>string2</var>. Equivalent to
12801<code>!!:s/<var>string1</var>/<var>string2</var>/</code>.
12802</p>
12803</dd>
12804<dt><code>!#</code></dt>
12805<dd><p>The entire command line typed so far.
12806</p>
12807</dd>
12808</dl>
12809
12810<hr>
12811<a name="Word-Designators"></a>
12812<div class="header">
12813<p>
12814Next: <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>
12815</div>
12816<a name="Word-Designators-1"></a>
12817<h4 class="subsection">9.3.2 Word Designators</h4>
12818
12819<p>Word designators are used to select desired words from the event.
12820A &lsquo;<samp>:</samp>&rsquo; separates the event specification from the word designator. It
12821may be omitted if the word designator begins with a &lsquo;<samp>^</samp>&rsquo;, &lsquo;<samp>$</samp>&rsquo;,
12822&lsquo;<samp>*</samp>&rsquo;, &lsquo;<samp>-</samp>&rsquo;, or &lsquo;<samp>%</samp>&rsquo;. Words are numbered from the beginning
17345e5a
JA
12823of the line, with the first word being denoted by 0 (zero). Words are
12824inserted into the current line separated by single spaces.
a0c0a00f
CR
12825</p>
12826<p>For example,
12827</p>
12828<dl compact="compact">
12829<dt><code>!!</code></dt>
12830<dd><p>designates the preceding command. When you type this, the preceding
17345e5a 12831command is repeated in toto.
a0c0a00f
CR
12832</p>
12833</dd>
12834<dt><code>!!:$</code></dt>
12835<dd><p>designates the last argument of the preceding command. This may be
12836shortened to <code>!$</code>.
12837</p>
12838</dd>
12839<dt><code>!fi:2</code></dt>
12840<dd><p>designates the second argument of the most recent command starting with
12841the letters <code>fi</code>.
12842</p></dd>
12843</dl>
12844
12845<p>Here are the word designators:
12846</p>
12847<dl compact="compact">
12848<dt><code>0 (zero)</code></dt>
12849<dd><p>The <code>0</code>th word. For many applications, this is the command word.
12850</p>
12851</dd>
12852<dt><code><var>n</var></code></dt>
12853<dd><p>The <var>n</var>th word.
12854</p>
12855</dd>
12856<dt><code>^</code></dt>
12857<dd><p>The first argument; that is, word 1.
12858</p>
12859</dd>
12860<dt><code>$</code></dt>
12861<dd><p>The last argument.
12862</p>
12863</dd>
12864<dt><code>%</code></dt>
12865<dd><p>The word matched by the most recent &lsquo;<samp>?<var>string</var>?</samp>&rsquo; search.
12866</p>
12867</dd>
12868<dt><code><var>x</var>-<var>y</var></code></dt>
12869<dd><p>A range of words; &lsquo;<samp>-<var>y</var></samp>&rsquo; abbreviates &lsquo;<samp>0-<var>y</var></samp>&rsquo;.
12870</p>
12871</dd>
12872<dt><code>*</code></dt>
12873<dd><p>All of the words, except the <code>0</code>th. This is a synonym for &lsquo;<samp>1-$</samp>&rsquo;.
12874It is not an error to use &lsquo;<samp>*</samp>&rsquo; if there is just one word in the event;
17345e5a 12875the empty string is returned in that case.
a0c0a00f
CR
12876</p>
12877</dd>
12878<dt><code><var>x</var>*</code></dt>
12879<dd><p>Abbreviates &lsquo;<samp><var>x</var>-$</samp>&rsquo;
12880</p>
12881</dd>
12882<dt><code><var>x</var>-</code></dt>
12883<dd><p>Abbreviates &lsquo;<samp><var>x</var>-$</samp>&rsquo; like &lsquo;<samp><var>x</var>*</samp>&rsquo;, but omits the last word.
12884</p>
12885</dd>
12886</dl>
12887
12888<p>If a word designator is supplied without an event specification, the
17345e5a 12889previous command is used as the event.
a0c0a00f
CR
12890</p>
12891<hr>
12892<a name="Modifiers"></a>
12893<div class="header">
12894<p>
12895Previous: <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>
12896</div>
12897<a name="Modifiers-1"></a>
12898<h4 class="subsection">9.3.3 Modifiers</h4>
12899
12900<p>After the optional word designator, you can add a sequence of one or more
12901of the following modifiers, each preceded by a &lsquo;<samp>:</samp>&rsquo;.
12902</p>
12903<dl compact="compact">
12904<dt><code>h</code></dt>
12905<dd><p>Remove a trailing pathname component, leaving only the head.
12906</p>
12907</dd>
12908<dt><code>t</code></dt>
12909<dd><p>Remove all leading pathname components, leaving the tail.
12910</p>
12911</dd>
12912<dt><code>r</code></dt>
12913<dd><p>Remove a trailing suffix of the form &lsquo;<samp>.<var>suffix</var></samp>&rsquo;, leaving
17345e5a 12914the basename.
a0c0a00f
CR
12915</p>
12916</dd>
12917<dt><code>e</code></dt>
12918<dd><p>Remove all but the trailing suffix.
12919</p>
12920</dd>
12921<dt><code>p</code></dt>
12922<dd><p>Print the new command but do not execute it.
12923</p>
12924</dd>
12925<dt><code>q</code></dt>
12926<dd><p>Quote the substituted words, escaping further substitutions.
12927</p>
12928</dd>
12929<dt><code>x</code></dt>
12930<dd><p>Quote the substituted words as with &lsquo;<samp>q</samp>&rsquo;,
17345e5a 12931but break into words at spaces, tabs, and newlines.
a0c0a00f
CR
12932</p>
12933</dd>
12934<dt><code>s/<var>old</var>/<var>new</var>/</code></dt>
12935<dd><p>Substitute <var>new</var> for the first occurrence of <var>old</var> in the
12936event line. Any delimiter may be used in place of &lsquo;<samp>/</samp>&rsquo;.
12937The delimiter may be quoted in <var>old</var> and <var>new</var>
12938with a single backslash. If &lsquo;<samp>&amp;</samp>&rsquo; appears in <var>new</var>,
12939it is replaced by <var>old</var>. A single backslash will quote
12940the &lsquo;<samp>&amp;</samp>&rsquo;. The final delimiter is optional if it is the last
17345e5a 12941character on the input line.
a0c0a00f
CR
12942</p>
12943</dd>
12944<dt><code>&amp;</code></dt>
12945<dd><p>Repeat the previous substitution.
12946</p>
12947</dd>
12948<dt><code>g</code></dt>
12949<dt><code>a</code></dt>
12950<dd><p>Cause changes to be applied over the entire event line. Used in
12951conjunction with &lsquo;<samp>s</samp>&rsquo;, as in <code>gs/<var>old</var>/<var>new</var>/</code>,
12952or with &lsquo;<samp>&amp;</samp>&rsquo;.
12953</p>
12954</dd>
12955<dt><code>G</code></dt>
12956<dd><p>Apply the following &lsquo;<samp>s</samp>&rsquo; modifier once to each word in the event.
12957</p>
12958</dd>
12959</dl>
12960
12961<hr>
12962<a name="Installing-Bash"></a>
12963<div class="header">
12964<p>
12965Next: <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>
12966</div>
12967<a name="Installing-Bash-1"></a>
12968<h2 class="chapter">10 Installing Bash</h2>
12969
12970<p>This chapter provides basic instructions for installing Bash on
17345e5a 12971the various supported platforms. The distribution supports the
a0c0a00f 12972<small>GNU</small> operating systems, nearly every version of Unix, and several
17345e5a
JA
12973non-Unix systems such as BeOS and Interix.
12974Other independent ports exist for
a0c0a00f
CR
12975<small>MS-DOS</small>, <small>OS/2</small>, and Windows platforms.
12976</p>
12977<table class="menu" border="0" cellspacing="0">
12978<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.
12979</td></tr>
12980<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
12981 systems.
12982</td></tr>
12983<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
17345e5a 12984 than one kind of system from
a0c0a00f
CR
12985 the same source tree.
12986</td></tr>
12987<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.
12988</td></tr>
12989<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.
12990</td></tr>
12991<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
12992 programs.
12993</td></tr>
12994<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.
12995</td></tr>
12996<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
12997 building Bash.
12998</td></tr>
12999</table>
13000
13001<hr>
13002<a name="Basic-Installation"></a>
13003<div class="header">
13004<p>
13005Next: <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>
13006</div>
13007<a name="Basic-Installation-1"></a>
13008<h3 class="section">10.1 Basic Installation</h3>
13009<a name="index-installation"></a>
13010<a name="index-configuration"></a>
13011<a name="index-Bash-installation"></a>
13012<a name="index-Bash-configuration"></a>
13013
13014<p>These are installation instructions for Bash.
13015</p>
13016<p>The simplest way to compile Bash is:
13017</p>
13018<ol>
13019<li> <code>cd</code> to the directory containing the source code and type
13020&lsquo;<samp>./configure</samp>&rsquo; to configure Bash for your system. If you&rsquo;re
13021using <code>csh</code> on an old version of System V, you might need to
13022type &lsquo;<samp>sh ./configure</samp>&rsquo; instead to prevent <code>csh</code> from trying
13023to execute <code>configure</code> itself.
13024
13025<p>Running <code>configure</code> takes some time.
17345e5a
JA
13026While running, it prints messages telling which features it is
13027checking for.
a0c0a00f
CR
13028</p>
13029</li><li> Type &lsquo;<samp>make</samp>&rsquo; to compile Bash and build the <code>bashbug</code> bug
17345e5a 13030reporting script.
17345e5a 13031
a0c0a00f 13032</li><li> Optionally, type &lsquo;<samp>make tests</samp>&rsquo; to run the Bash test suite.
17345e5a 13033
a0c0a00f 13034</li><li> Type &lsquo;<samp>make install</samp>&rsquo; to install <code>bash</code> and <code>bashbug</code>.
17345e5a 13035This will also install the manual pages and Info file.
17345e5a 13036
a0c0a00f 13037</li></ol>
17345e5a 13038
a0c0a00f 13039<p>The <code>configure</code> shell script attempts to guess correct
17345e5a 13040values for various system-dependent variables used during
a0c0a00f 13041compilation. It uses those values to create a <samp>Makefile</samp> in
17345e5a 13042each directory of the package (the top directory, the
a0c0a00f
CR
13043<samp>builtins</samp>, <samp>doc</samp>, and <samp>support</samp> directories,
13044each directory under <samp>lib</samp>, and several others). It also creates a
13045<samp>config.h</samp> file containing system-dependent definitions.
13046Finally, it creates a shell script named <code>config.status</code> that you
17345e5a 13047can run in the future to recreate the current configuration, a
a0c0a00f
CR
13048file <samp>config.cache</samp> that saves the results of its tests to
13049speed up reconfiguring, and a file <samp>config.log</samp> containing
13050compiler output (useful mainly for debugging <code>configure</code>).
17345e5a 13051If at some point
a0c0a00f 13052<samp>config.cache</samp> contains results you don&rsquo;t want to keep, you
17345e5a 13053may remove or edit it.
a0c0a00f
CR
13054</p>
13055<p>To find out more about the options and arguments that the
13056<code>configure</code> script understands, type
13057</p>
13058<div class="example">
9a51695b 13059<pre class="example">bash-4.2$ ./configure --help
a0c0a00f
CR
13060</pre></div>
13061
13062<p>at the Bash prompt in your Bash source directory.
13063</p>
9a51695b
CR
13064<p>If you want to build Bash in a directory separate from the source
13065directory &ndash; to build for multiple architectures, for example &ndash;
13066just use the full path to the configure script. The following commands
13067will build bash in a directory under <samp>/usr/local/build</samp> from
13068the source code in <samp>/usr/local/src/bash-4.4</samp>:
13069</p>
13070<div class="example">
13071<pre class="example">mkdir /usr/local/build/bash-4.4
13072cd /usr/local/build/bash-4.4
13073bash /usr/local/src/bash-4.4/configure
13074make
13075</pre></div>
13076
13077<p>See <a href="#Compiling-For-Multiple-Architectures">Compiling For Multiple Architectures</a> for more information
13078about building in a directory separate from the source.
13079</p>
a0c0a00f
CR
13080<p>If you need to do unusual things to compile Bash, please
13081try to figure out how <code>configure</code> could check whether or not
17345e5a 13082to do them, and mail diffs or instructions to
a0c0a00f 13083<a href="mailto:bash-maintainers@gnu.org">bash-maintainers@gnu.org</a> so they can be
17345e5a 13084considered for the next release.
a0c0a00f
CR
13085</p>
13086<p>The file <samp>configure.ac</samp> is used to create <code>configure</code>
17345e5a 13087by a program called Autoconf. You only need
a0c0a00f
CR
13088<samp>configure.ac</samp> if you want to change it or regenerate
13089<code>configure</code> using a newer version of Autoconf. If
17345e5a
JA
13090you do this, make sure you are using Autoconf version 2.50 or
13091newer.
a0c0a00f
CR
13092</p>
13093<p>You can remove the program binaries and object files from the
13094source code directory by typing &lsquo;<samp>make clean</samp>&rsquo;. To also remove the
13095files that <code>configure</code> created (so you can compile Bash for
13096a different kind of computer), type &lsquo;<samp>make distclean</samp>&rsquo;.
13097</p>
13098<hr>
13099<a name="Compilers-and-Options"></a>
13100<div class="header">
13101<p>
13102Next: <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>
13103</div>
13104<a name="Compilers-and-Options-1"></a>
13105<h3 class="section">10.2 Compilers and Options</h3>
13106
13107<p>Some systems require unusual options for compilation or linking
13108that the <code>configure</code> script does not know about. You can
13109give <code>configure</code> initial values for variables by setting
17345e5a
JA
13110them in the environment. Using a Bourne-compatible shell, you
13111can do that on the command line like this:
a0c0a00f
CR
13112</p>
13113<div class="example">
13114<pre class="example">CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
13115</pre></div>
13116
13117<p>On systems that have the <code>env</code> program, you can do it like this:
13118</p>
13119<div class="example">
13120<pre class="example">env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
13121</pre></div>
13122
13123<p>The configuration process uses GCC to build Bash if it
17345e5a 13124is available.
a0c0a00f
CR
13125</p>
13126<hr>
13127<a name="Compiling-For-Multiple-Architectures"></a>
13128<div class="header">
13129<p>
13130Next: <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>
13131</div>
13132<a name="Compiling-For-Multiple-Architectures-1"></a>
13133<h3 class="section">10.3 Compiling For Multiple Architectures</h3>
13134
13135<p>You can compile Bash for more than one kind of computer at the
17345e5a 13136same time, by placing the object files for each architecture in their
a0c0a00f
CR
13137own directory. To do this, you must use a version of <code>make</code> that
13138supports the <code>VPATH</code> variable, such as GNU <code>make</code>.
13139<code>cd</code> to the
17345e5a 13140directory where you want the object files and executables to go and run
9a51695b
CR
13141the <code>configure</code> script from the source directory
13142(see <a href="#Basic-Installation">Basic Installation</a>).
13143You may need to
a0c0a00f
CR
13144supply the <samp>--srcdir=PATH</samp> argument to tell <code>configure</code> where the
13145source files are. <code>configure</code> automatically checks for the
13146source code in the directory that <code>configure</code> is in and in &lsquo;..&rsquo;.
13147</p>
13148<p>If you have to use a <code>make</code> that does not supports the <code>VPATH</code>
17345e5a
JA
13149variable, you can compile Bash for one architecture at a
13150time in the source code directory. After you have installed
a0c0a00f 13151Bash for one architecture, use &lsquo;<samp>make distclean</samp>&rsquo; before
17345e5a 13152reconfiguring for another architecture.
a0c0a00f
CR
13153</p>
13154<p>Alternatively, if your system supports symbolic links, you can use the
13155<samp>support/mkclone</samp> script to create a build tree which has
13156symbolic links back to each file in the source directory. Here&rsquo;s an
17345e5a 13157example that creates a build directory in the current directory from a
a0c0a00f
CR
13158source directory <samp>/usr/gnu/src/bash-2.0</samp>:
13159</p>
13160<div class="example">
13161<pre class="example">bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 .
13162</pre></div>
17345e5a 13163
a0c0a00f 13164<p>The <code>mkclone</code> script requires Bash, so you must have already built
17345e5a
JA
13165Bash for at least one architecture before you can create build
13166directories for other architectures.
a0c0a00f
CR
13167</p>
13168<hr>
13169<a name="Installation-Names"></a>
13170<div class="header">
13171<p>
13172Next: <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>
13173</div>
13174<a name="Installation-Names-1"></a>
13175<h3 class="section">10.4 Installation Names</h3>
13176
13177<p>By default, &lsquo;<samp>make install</samp>&rsquo; will install into
13178<samp>/usr/local/bin</samp>, <samp>/usr/local/man</samp>, etc. You can
13179specify an installation prefix other than <samp>/usr/local</samp> by
13180giving <code>configure</code> the option <samp>--prefix=<var>PATH</var></samp>,
13181or by specifying a value for the <code>DESTDIR</code> &lsquo;<samp>make</samp>&rsquo;
13182variable when running &lsquo;<samp>make install</samp>&rsquo;.
13183</p>
13184<p>You can specify separate installation prefixes for
17345e5a 13185architecture-specific files and architecture-independent files.
a0c0a00f
CR
13186If you give <code>configure</code> the option
13187<samp>--exec-prefix=<var>PATH</var></samp>, &lsquo;<samp>make install</samp>&rsquo; will use
13188<var>PATH</var> as the prefix for installing programs and libraries.
17345e5a 13189Documentation and other data files will still use the regular prefix.
a0c0a00f
CR
13190</p>
13191<hr>
13192<a name="Specifying-the-System-Type"></a>
13193<div class="header">
13194<p>
13195Next: <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>
13196</div>
13197<a name="Specifying-the-System-Type-1"></a>
13198<h3 class="section">10.5 Specifying the System Type</h3>
13199
13200<p>There may be some features <code>configure</code> can not figure out
17345e5a 13201automatically, but need to determine by the type of host Bash
a0c0a00f 13202will run on. Usually <code>configure</code> can figure that
17345e5a 13203out, but if it prints a message saying it can not guess the host
a0c0a00f
CR
13204type, give it the <samp>--host=TYPE</samp> option. &lsquo;<samp>TYPE</samp>&rsquo; can
13205either be a short name for the system type, such as &lsquo;<samp>sun4</samp>&rsquo;,
13206or a canonical name with three fields: &lsquo;<samp>CPU-COMPANY-SYSTEM</samp>&rsquo;
13207(e.g., &lsquo;<samp>i386-unknown-freebsd4.2</samp>&rsquo;).
13208</p>
13209<p>See the file <samp>support/config.sub</samp> for the possible
17345e5a 13210values of each field.
a0c0a00f
CR
13211</p>
13212<hr>
13213<a name="Sharing-Defaults"></a>
13214<div class="header">
13215<p>
13216Next: <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>
13217</div>
13218<a name="Sharing-Defaults-1"></a>
13219<h3 class="section">10.6 Sharing Defaults</h3>
13220
13221<p>If you want to set default values for <code>configure</code> scripts to
17345e5a 13222share, you can create a site shell script called
a0c0a00f
CR
13223<code>config.site</code> that gives default values for variables like
13224<code>CC</code>, <code>cache_file</code>, and <code>prefix</code>. <code>configure</code>
13225looks for <samp>PREFIX/share/config.site</samp> if it exists, then
13226<samp>PREFIX/etc/config.site</samp> if it exists. Or, you can set the
13227<code>CONFIG_SITE</code> environment variable to the location of the site
13228script. A warning: the Bash <code>configure</code> looks for a site script,
13229but not all <code>configure</code> scripts do.
13230</p>
13231<hr>
13232<a name="Operation-Controls"></a>
13233<div class="header">
13234<p>
13235Next: <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>
13236</div>
13237<a name="Operation-Controls-1"></a>
13238<h3 class="section">10.7 Operation Controls</h3>
13239
13240<p><code>configure</code> recognizes the following options to control how it
17345e5a 13241operates.
a0c0a00f
CR
13242</p>
13243<dl compact="compact">
13244<dt><code>--cache-file=<var>file</var></code></dt>
13245<dd><p>Use and save the results of the tests in
13246<var>file</var> instead of <samp>./config.cache</samp>. Set <var>file</var> to
13247<samp>/dev/null</samp> to disable caching, for debugging
13248<code>configure</code>.
13249</p>
13250</dd>
13251<dt><code>--help</code></dt>
13252<dd><p>Print a summary of the options to <code>configure</code>, and exit.
13253</p>
13254</dd>
13255<dt><code>--quiet</code></dt>
13256<dt><code>--silent</code></dt>
13257<dt><code>-q</code></dt>
13258<dd><p>Do not print messages saying which checks are being made.
13259</p>
13260</dd>
13261<dt><code>--srcdir=<var>dir</var></code></dt>
13262<dd><p>Look for the Bash source code in directory <var>dir</var>. Usually
13263<code>configure</code> can determine that directory automatically.
13264</p>
13265</dd>
13266<dt><code>--version</code></dt>
13267<dd><p>Print the version of Autoconf used to generate the <code>configure</code>
17345e5a 13268script, and exit.
a0c0a00f
CR
13269</p></dd>
13270</dl>
13271
13272<p><code>configure</code> also accepts some other, not widely used, boilerplate
13273options. &lsquo;<samp>configure --help</samp>&rsquo; prints the complete list.
13274</p>
13275<hr>
13276<a name="Optional-Features"></a>
13277<div class="header">
13278<p>
13279Previous: <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>
13280</div>
13281<a name="Optional-Features-1"></a>
13282<h3 class="section">10.8 Optional Features</h3>
13283
13284<p>The Bash <code>configure</code> has a number of <samp>--enable-<var>feature</var></samp>
13285options, where <var>feature</var> indicates an optional part of Bash.
13286There are also several <samp>--with-<var>package</var></samp> options,
13287where <var>package</var> is something like &lsquo;<samp>bash-malloc</samp>&rsquo; or &lsquo;<samp>purify</samp>&rsquo;.
17345e5a 13288To turn off the default use of a package, use
a0c0a00f
CR
13289<samp>--without-<var>package</var></samp>. To configure Bash without a feature
13290that is enabled by default, use <samp>--disable-<var>feature</var></samp>.
13291</p>
13292<p>Here is a complete list of the <samp>--enable-</samp> and
13293<samp>--with-</samp> options that the Bash <code>configure</code> recognizes.
13294</p>
13295<dl compact="compact">
13296<dt><code>--with-afs</code></dt>
13297<dd><p>Define if you are using the Andrew File System from Transarc.
13298</p>
13299</dd>
13300<dt><code>--with-bash-malloc</code></dt>
13301<dd><p>Use the Bash version of
13302<code>malloc</code> in the directory <samp>lib/malloc</samp>. This is not the same
13303<code>malloc</code> that appears in <small>GNU</small> libc, but an older version
13304originally derived from the 4.2 <small>BSD</small> <code>malloc</code>. This <code>malloc</code>
17345e5a
JA
13305is very fast, but wastes some space on each allocation.
13306This option is enabled by default.
a0c0a00f
CR
13307The <samp>NOTES</samp> file contains a list of systems for
13308which this should be turned off, and <code>configure</code> disables this
17345e5a 13309option automatically for a number of systems.
a0c0a00f
CR
13310</p>
13311</dd>
13312<dt><code>--with-curses</code></dt>
13313<dd><p>Use the curses library instead of the termcap library. This should
17345e5a
JA
13314be supplied if your system has an inadequate or incomplete termcap
13315database.
a0c0a00f
CR
13316</p>
13317</dd>
13318<dt><code>--with-gnu-malloc</code></dt>
13319<dd><p>A synonym for <code>--with-bash-malloc</code>.
13320</p>
13321</dd>
13322<dt><code>--with-installed-readline[=<var>PREFIX</var>]</code></dt>
13323<dd><p>Define this to make Bash link with a locally-installed version of Readline
13324rather than the version in <samp>lib/readline</samp>. This works only with
13325Readline 5.0 and later versions. If <var>PREFIX</var> is <code>yes</code> or not
13326supplied, <code>configure</code> uses the values of the make variables
13327<code>includedir</code> and <code>libdir</code>, which are subdirectories of <code>prefix</code>
17345e5a
JA
13328by default, to find the installed version of Readline if it is not in
13329the standard system include and library directories.
a0c0a00f
CR
13330If <var>PREFIX</var> is <code>no</code>, Bash links with the version in
13331<samp>lib/readline</samp>.
13332If <var>PREFIX</var> is set to any other value, <code>configure</code> treats it as
17345e5a
JA
13333a directory pathname and looks for
13334the installed version of Readline in subdirectories of that directory
a0c0a00f
CR
13335(include files in <var>PREFIX</var>/<code>include</code> and the library in
13336<var>PREFIX</var>/<code>lib</code>).
13337</p>
13338</dd>
13339<dt><code>--with-purify</code></dt>
13340<dd><p>Define this to use the Purify memory allocation checker from Rational
17345e5a 13341Software.
a0c0a00f
CR
13342</p>
13343</dd>
13344<dt><code>--enable-minimal-config</code></dt>
13345<dd><p>This produces a shell with minimal features, close to the historical
17345e5a 13346Bourne shell.
a0c0a00f
CR
13347</p></dd>
13348</dl>
17345e5a 13349
a0c0a00f 13350<p>There are several <samp>--enable-</samp> options that alter how Bash is
17345e5a 13351compiled and linked, rather than changing run-time features.
a0c0a00f
CR
13352</p>
13353<dl compact="compact">
13354<dt><code>--enable-largefile</code></dt>
2f5dfe5a 13355<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
17345e5a
JA
13356to build programs which can access large files. This is enabled by
13357default, if the operating system provides large file support.
a0c0a00f
CR
13358</p>
13359</dd>
13360<dt><code>--enable-profiling</code></dt>
13361<dd><p>This builds a Bash binary that produces profiling information to be
13362processed by <code>gprof</code> each time it is executed.
13363</p>
13364</dd>
13365<dt><code>--enable-static-link</code></dt>
13366<dd><p>This causes Bash to be linked statically, if <code>gcc</code> is being used.
13367This could be used to build a version to use as root&rsquo;s shell.
13368</p></dd>
13369</dl>
13370
13371<p>The &lsquo;<samp>minimal-config</samp>&rsquo; option can be used to disable all of
17345e5a 13372the following options, but it is processed first, so individual
a0c0a00f
CR
13373options may be enabled using &lsquo;<samp>enable-<var>feature</var></samp>&rsquo;.
13374</p>
13375<p>All of the following options except for &lsquo;<samp>disabled-builtins</samp>&rsquo;,
13376&lsquo;<samp>direxpand-default</samp>&rsquo;, and
13377&lsquo;<samp>xpg-echo-default</samp>&rsquo; are
17345e5a
JA
13378enabled by default, unless the operating system does not provide the
13379necessary support.
a0c0a00f
CR
13380</p>
13381<dl compact="compact">
13382<dt><code>--enable-alias</code></dt>
13383<dd><p>Allow alias expansion and include the <code>alias</code> and <code>unalias</code>
13384builtins (see <a href="#Aliases">Aliases</a>).
13385</p>
13386</dd>
13387<dt><code>--enable-arith-for-command</code></dt>
13388<dd><p>Include support for the alternate form of the <code>for</code> command
13389that behaves like the C language <code>for</code> statement
13390(see <a href="#Looping-Constructs">Looping Constructs</a>).
13391</p>
13392</dd>
13393<dt><code>--enable-array-variables</code></dt>
13394<dd><p>Include support for one-dimensional array shell variables
13395(see <a href="#Arrays">Arrays</a>).
13396</p>
13397</dd>
13398<dt><code>--enable-bang-history</code></dt>
13399<dd><p>Include support for <code>csh</code>-like history substitution
13400(see <a href="#History-Interaction">History Interaction</a>).
13401</p>
13402</dd>
13403<dt><code>--enable-brace-expansion</code></dt>
13404<dd><p>Include <code>csh</code>-like brace expansion
13405( <code>b{a,b}c</code> &rarr; <code>bac bbc</code> ).
13406See <a href="#Brace-Expansion">Brace Expansion</a>, for a complete description.
13407</p>
13408</dd>
13409<dt><code>--enable-casemod-attributes</code></dt>
13410<dd><p>Include support for case-modifying attributes in the <code>declare</code> builtin
13411and assignment statements. Variables with the <var>uppercase</var> attribute,
17345e5a 13412for example, will have their values converted to uppercase upon assignment.
a0c0a00f
CR
13413</p>
13414</dd>
13415<dt><code>--enable-casemod-expansion</code></dt>
13416<dd><p>Include support for case-modifying word expansions.
13417</p>
13418</dd>
13419<dt><code>--enable-command-timing</code></dt>
13420<dd><p>Include support for recognizing <code>time</code> as a reserved word and for
13421displaying timing statistics for the pipeline following <code>time</code>
13422(see <a href="#Pipelines">Pipelines</a>).
17345e5a 13423This allows pipelines as well as shell builtins and functions to be timed.
a0c0a00f
CR
13424</p>
13425</dd>
13426<dt><code>--enable-cond-command</code></dt>
13427<dd><p>Include support for the <code>[[</code> conditional command.
13428(see <a href="#Conditional-Constructs">Conditional Constructs</a>).
13429</p>
13430</dd>
13431<dt><code>--enable-cond-regexp</code></dt>
13432<dd><p>Include support for matching <small>POSIX</small> regular expressions using the
13433&lsquo;<samp>=~</samp>&rsquo; binary operator in the <code>[[</code> conditional command.
13434(see <a href="#Conditional-Constructs">Conditional Constructs</a>).
13435</p>
13436</dd>
13437<dt><code>--enable-coprocesses</code></dt>
13438<dd><p>Include support for coprocesses and the <code>coproc</code> reserved word
13439(see <a href="#Pipelines">Pipelines</a>).
13440</p>
13441</dd>
13442<dt><code>--enable-debugger</code></dt>
13443<dd><p>Include support for the bash debugger (distributed separately).
13444</p>
13445</dd>
9a51695b
CR
13446<dt><code>--enable-dev-fd-stat-broken</code></dt>
13447<dd><p>If calling <code>stat</code> on /dev/fd/<var>N</var> returns different results than
13448calling <code>fstat</code> on file descriptor <var>N</var>, supply this option to
13449enable a workaround.
13450This has implications for conditional commands that test file attributes.
13451</p>
13452</dd>
a0c0a00f
CR
13453<dt><code>--enable-direxpand-default</code></dt>
13454<dd><p>Cause the <code>direxpand</code> shell option (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>)
ac50fbac
CR
13455to be enabled by default when the shell starts.
13456It is normally disabled by default.
a0c0a00f
CR
13457</p>
13458</dd>
13459<dt><code>--enable-directory-stack</code></dt>
13460<dd><p>Include support for a <code>csh</code>-like directory stack and the
13461<code>pushd</code>, <code>popd</code>, and <code>dirs</code> builtins
13462(see <a href="#The-Directory-Stack">The Directory Stack</a>).
13463</p>
13464</dd>
13465<dt><code>--enable-disabled-builtins</code></dt>
13466<dd><p>Allow builtin commands to be invoked via &lsquo;<samp>builtin xxx</samp>&rsquo;
13467even after <code>xxx</code> has been disabled using &lsquo;<samp>enable -n xxx</samp>&rsquo;.
13468See <a href="#Bash-Builtins">Bash Builtins</a>, for details of the <code>builtin</code> and
13469<code>enable</code> builtin commands.
13470</p>
13471</dd>
13472<dt><code>--enable-dparen-arithmetic</code></dt>
13473<dd><p>Include support for the <code>((&hellip;))</code> command
13474(see <a href="#Conditional-Constructs">Conditional Constructs</a>).
13475</p>
13476</dd>
13477<dt><code>--enable-extended-glob</code></dt>
13478<dd><p>Include support for the extended pattern matching features described
13479above under <a href="#Pattern-Matching">Pattern Matching</a>.
13480</p>
13481</dd>
13482<dt><code>--enable-extended-glob-default</code></dt>
13483<dd><p>Set the default value of the <var>extglob</var> shell option described
13484above under <a href="#The-Shopt-Builtin">The Shopt Builtin</a> to be enabled.
13485</p>
13486</dd>
13487<dt><code>--enable-function-import</code></dt>
13488<dd><p>Include support for importing function definitions exported by another
13489instance of the shell from the environment. This option is enabled by
13490default.
13491</p>
13492</dd>
13493<dt><code>--enable-glob-asciirange-default</code></dt>
13494<dd><p>Set the default value of the <var>globasciiranges</var> shell option described
13495above under <a href="#The-Shopt-Builtin">The Shopt Builtin</a> to be enabled.
ac50fbac
CR
13496This controls the behavior of character ranges when used in pattern matching
13497bracket expressions.
a0c0a00f
CR
13498</p>
13499</dd>
13500<dt><code>--enable-help-builtin</code></dt>
13501<dd><p>Include the <code>help</code> builtin, which displays help on shell builtins and
13502variables (see <a href="#Bash-Builtins">Bash Builtins</a>).
13503</p>
13504</dd>
13505<dt><code>--enable-history</code></dt>
13506<dd><p>Include command history and the <code>fc</code> and <code>history</code>
13507builtin commands (see <a href="#Bash-History-Facilities">Bash History Facilities</a>).
13508</p>
13509</dd>
13510<dt><code>--enable-job-control</code></dt>
13511<dd><p>This enables the job control features (see <a href="#Job-Control">Job Control</a>),
17345e5a 13512if the operating system supports them.
a0c0a00f
CR
13513</p>
13514</dd>
13515<dt><code>--enable-multibyte</code></dt>
13516<dd><p>This enables support for multibyte characters if the operating
17345e5a 13517system provides the necessary support.
a0c0a00f
CR
13518</p>
13519</dd>
13520<dt><code>--enable-net-redirections</code></dt>
13521<dd><p>This enables the special handling of filenames of the form
13522<code>/dev/tcp/<var>host</var>/<var>port</var></code> and
13523<code>/dev/udp/<var>host</var>/<var>port</var></code>
13524when used in redirections (see <a href="#Redirections">Redirections</a>).
13525</p>
13526</dd>
13527<dt><code>--enable-process-substitution</code></dt>
13528<dd><p>This enables process substitution (see <a href="#Process-Substitution">Process Substitution</a>) if
17345e5a 13529the operating system provides the necessary support.
a0c0a00f
CR
13530</p>
13531</dd>
13532<dt><code>--enable-progcomp</code></dt>
13533<dd><p>Enable the programmable completion facilities
13534(see <a href="#Programmable-Completion">Programmable Completion</a>).
17345e5a 13535If Readline is not enabled, this option has no effect.
a0c0a00f
CR
13536</p>
13537</dd>
13538<dt><code>--enable-prompt-string-decoding</code></dt>
13539<dd><p>Turn on the interpretation of a number of backslash-escaped characters
9a51695b 13540in the <code>$PS0</code>, <code>$PS1</code>, <code>$PS2</code>, and <code>$PS4</code> prompt
a0c0a00f 13541strings. See <a href="#Controlling-the-Prompt">Controlling the Prompt</a>, for a complete list of prompt
17345e5a 13542string escape sequences.
a0c0a00f
CR
13543</p>
13544</dd>
13545<dt><code>--enable-readline</code></dt>
13546<dd><p>Include support for command-line editing and history with the Bash
13547version of the Readline library (see <a href="#Command-Line-Editing">Command Line Editing</a>).
13548</p>
13549</dd>
13550<dt><code>--enable-restricted</code></dt>
13551<dd><p>Include support for a <em>restricted shell</em>. If this is enabled, Bash,
13552when called as <code>rbash</code>, enters a restricted mode. See
13553<a href="#The-Restricted-Shell">The Restricted Shell</a>, for a description of restricted mode.
13554</p>
13555</dd>
13556<dt><code>--enable-select</code></dt>
13557<dd><p>Include the <code>select</code> compound command, which allows the generation of
13558simple menus (see <a href="#Conditional-Constructs">Conditional Constructs</a>).
13559</p>
13560</dd>
13561<dt><code>--enable-separate-helpfiles</code></dt>
13562<dd><p>Use external files for the documentation displayed by the <code>help</code> builtin
17345e5a 13563instead of storing the text internally.
a0c0a00f
CR
13564</p>
13565</dd>
13566<dt><code>--enable-single-help-strings</code></dt>
13567<dd><p>Store the text displayed by the <code>help</code> builtin as a single string for
17345e5a
JA
13568each help topic. This aids in translating the text to different languages.
13569You may need to disable this if your compiler cannot handle very long string
13570literals.
a0c0a00f
CR
13571</p>
13572</dd>
13573<dt><code>--enable-strict-posix-default</code></dt>
13574<dd><p>Make Bash <small>POSIX</small>-conformant by default (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>).
13575</p>
13576</dd>
13577<dt><code>--enable-usg-echo-default</code></dt>
13578<dd><p>A synonym for <code>--enable-xpg-echo-default</code>.
13579</p>
13580</dd>
13581<dt><code>--enable-xpg-echo-default</code></dt>
13582<dd><p>Make the <code>echo</code> builtin expand backslash-escaped characters by default,
13583without requiring the <samp>-e</samp> option.
13584This sets the default value of the <code>xpg_echo</code> shell option to <code>on</code>,
13585which makes the Bash <code>echo</code> behave more like the version specified in
17345e5a 13586the Single Unix Specification, version 3.
a0c0a00f
CR
13587See <a href="#Bash-Builtins">Bash Builtins</a>, for a description of the escape sequences that
13588<code>echo</code> recognizes.
13589</p></dd>
13590</dl>
13591
13592<p>The file <samp>config-top.h</samp> contains C Preprocessor
13593&lsquo;<samp>#define</samp>&rsquo; statements for options which are not settable from
13594<code>configure</code>.
17345e5a
JA
13595Some of these are not meant to be changed; beware of the consequences if
13596you do.
13597Read the comments associated with each definition for more
13598information about its effect.
a0c0a00f
CR
13599</p>
13600<hr>
13601<a name="Reporting-Bugs"></a>
13602<div class="header">
13603<p>
13604Next: <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>
13605</div>
13606<a name="Reporting-Bugs-1"></a>
13607<h2 class="appendix">Appendix A Reporting Bugs</h2>
13608
13609<p>Please report all bugs you find in Bash.
17345e5a
JA
13610But first, you should
13611make sure that it really is a bug, and that it appears in the latest
13612version of Bash.
13613The latest version of Bash is always available for FTP from
a0c0a00f
CR
13614<a href="ftp://ftp.gnu.org/pub/gnu/bash/">ftp://ftp.gnu.org/pub/gnu/bash/</a>.
13615</p>
13616<p>Once you have determined that a bug actually exists, use the
13617<code>bashbug</code> command to submit a bug report.
17345e5a 13618If you have a fix, you are encouraged to mail that as well!
a0c0a00f
CR
13619Suggestions and &lsquo;philosophical&rsquo; bug reports may be mailed
13620to <a href="mailto:bug-bash@gnu.org">bug-bash@gnu.org</a> or posted to the Usenet
13621newsgroup <code>gnu.bash.bug</code>.
13622</p>
13623<p>All bug reports should include:
13624</p><ul>
13625<li> The version number of Bash.
13626</li><li> The hardware and operating system.
13627</li><li> The compiler used to compile Bash.
13628</li><li> A description of the bug behaviour.
13629</li><li> A short script or &lsquo;recipe&rsquo; which exercises the bug and may be used
17345e5a 13630to reproduce it.
a0c0a00f 13631</li></ul>
17345e5a 13632
a0c0a00f 13633<p><code>bashbug</code> inserts the first three items automatically into
17345e5a 13634the template it provides for filing a bug report.
a0c0a00f
CR
13635</p>
13636<p>Please send all reports concerning this manual to
13637<a href="mailto:bug-bash@gnu.org">bug-bash@gnu.org</a>.
13638</p>
13639<hr>
13640<a name="Major-Differences-From-The-Bourne-Shell"></a>
13641<div class="header">
13642<p>
13643Next: <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>
13644</div>
13645<a name="Major-Differences-From-The-Bourne-Shell-1"></a>
13646<h2 class="appendix">Appendix B Major Differences From The Bourne Shell</h2>
13647
13648<p>Bash implements essentially the same grammar, parameter and
17345e5a 13649variable expansion, redirection, and quoting as the Bourne Shell.
a0c0a00f 13650Bash uses the <small>POSIX</small> standard as the specification of
17345e5a
JA
13651how these features are to be implemented. There are some
13652differences between the traditional Bourne shell and Bash; this
13653section quickly details the differences of significance. A
13654number of these differences are explained in greater depth in
13655previous sections.
a0c0a00f 13656This section uses the version of <code>sh</code> included in SVR4.2 (the
17345e5a 13657last version of the historical Bourne shell) as the baseline reference.
a0c0a00f
CR
13658</p>
13659<ul>
13660<li> Bash is <small>POSIX</small>-conformant, even where the <small>POSIX</small> specification
13661differs from traditional <code>sh</code> behavior (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>).
17345e5a 13662
a0c0a00f 13663</li><li> Bash has multi-character invocation options (see <a href="#Invoking-Bash">Invoking Bash</a>).
17345e5a 13664
a0c0a00f
CR
13665</li><li> Bash has command-line editing (see <a href="#Command-Line-Editing">Command Line Editing</a>) and
13666the <code>bind</code> builtin.
17345e5a 13667
a0c0a00f
CR
13668</li><li> Bash provides a programmable word completion mechanism
13669(see <a href="#Programmable-Completion">Programmable Completion</a>), and builtin commands
13670<code>complete</code>, <code>compgen</code>, and <code>compopt</code>, to
17345e5a 13671manipulate it.
17345e5a 13672
a0c0a00f
CR
13673</li><li> Bash has command history (see <a href="#Bash-History-Facilities">Bash History Facilities</a>) and the
13674<code>history</code> and <code>fc</code> builtins to manipulate it.
17345e5a 13675The Bash history list maintains timestamp information and uses the
a0c0a00f 13676value of the <code>HISTTIMEFORMAT</code> variable to display it.
17345e5a 13677
a0c0a00f
CR
13678</li><li> Bash implements <code>csh</code>-like history expansion
13679(see <a href="#History-Interaction">History Interaction</a>).
17345e5a 13680
a0c0a00f 13681</li><li> Bash has one-dimensional array variables (see <a href="#Arrays">Arrays</a>), and the
17345e5a
JA
13682appropriate variable expansions and assignment syntax to use them.
13683Several of the Bash builtins take options to act on arrays.
13684Bash provides a number of built-in array variables.
17345e5a 13685
a0c0a00f 13686</li><li> The <code>$'&hellip;'</code> quoting syntax, which expands ANSI-C
17345e5a 13687backslash-escaped characters in the text between the single quotes,
a0c0a00f 13688is supported (see <a href="#ANSI_002dC-Quoting">ANSI-C Quoting</a>).
17345e5a 13689
a0c0a00f 13690</li><li> Bash supports the <code>$&quot;&hellip;&quot;</code> quoting syntax to do
17345e5a 13691locale-specific translation of the characters between the double
a0c0a00f 13692quotes. The <samp>-D</samp>, <samp>--dump-strings</samp>, and <samp>--dump-po-strings</samp>
17345e5a 13693invocation options list the translatable strings found in a script
a0c0a00f
CR
13694(see <a href="#Locale-Translation">Locale Translation</a>).
13695
13696</li><li> Bash implements the <code>!</code> keyword to negate the return value of
13697a pipeline (see <a href="#Pipelines">Pipelines</a>).
13698Very useful when an <code>if</code> statement needs to act only if a test fails.
13699The Bash &lsquo;<samp>-o pipefail</samp>&rsquo; option to <code>set</code> will cause a pipeline to
17345e5a 13700return a failure status if any command fails.
17345e5a 13701
a0c0a00f 13702</li><li> Bash has the <code>time</code> reserved word and command timing (see <a href="#Pipelines">Pipelines</a>).
17345e5a 13703The display of the timing statistics may be controlled with the
a0c0a00f
CR
13704<code>TIMEFORMAT</code> variable.
13705
13706</li><li> Bash implements the <code>for (( <var>expr1</var> ; <var>expr2</var> ; <var>expr3</var> ))</code>
13707arithmetic for command, similar to the C language (see <a href="#Looping-Constructs">Looping Constructs</a>).
13708
13709</li><li> Bash includes the <code>select</code> compound command, which allows the
13710generation of simple menus (see <a href="#Conditional-Constructs">Conditional Constructs</a>).
13711
13712</li><li> Bash includes the <code>[[</code> compound command, which makes conditional
13713testing part of the shell grammar (see <a href="#Conditional-Constructs">Conditional Constructs</a>), including
17345e5a 13714optional regular expression matching.
a0c0a00f
CR
13715
13716</li><li> Bash provides optional case-insensitive matching for the <code>case</code> and
13717<code>[[</code> constructs.
13718
13719</li><li> Bash includes brace expansion (see <a href="#Brace-Expansion">Brace Expansion</a>) and tilde
13720expansion (see <a href="#Tilde-Expansion">Tilde Expansion</a>).
13721
13722</li><li> Bash implements command aliases and the <code>alias</code> and <code>unalias</code>
13723builtins (see <a href="#Aliases">Aliases</a>).
13724
13725</li><li> Bash provides shell arithmetic, the <code>((</code> compound command
13726(see <a href="#Conditional-Constructs">Conditional Constructs</a>),
13727and arithmetic expansion (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>).
13728
13729</li><li> Variables present in the shell&rsquo;s initial environment are automatically
17345e5a 13730exported to child processes. The Bourne shell does not normally do
a0c0a00f 13731this unless the variables are explicitly marked using the <code>export</code>
17345e5a 13732command.
17345e5a 13733
a0c0a00f 13734</li><li> Bash supports the &lsquo;<samp>+=</samp>&rsquo; assignment operator, which appends to the value
17345e5a 13735of the variable named on the left hand side.
a0c0a00f
CR
13736
13737</li><li> Bash includes the <small>POSIX</small> pattern removal &lsquo;<samp>%</samp>&rsquo;, &lsquo;<samp>#</samp>&rsquo;, &lsquo;<samp>%%</samp>&rsquo;
13738and &lsquo;<samp>##</samp>&rsquo; expansions to remove leading or trailing substrings from
13739variable values (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
13740
13741</li><li> The expansion <code>${#xx}</code>, which returns the length of <code>${xx}</code>,
13742is supported (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
13743
13744</li><li> The expansion <code>${var:</code><var>offset</var><code>[:</code><var>length</var><code>]}</code>,
13745which expands to the substring of <code>var</code>&rsquo;s value of length
13746<var>length</var>, beginning at <var>offset</var>, is present
13747(see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
13748
13749</li><li> The expansion
13750<code>${var/[/]</code><var>pattern</var><code>[/</code><var>replacement</var><code>]}</code>,
13751which matches <var>pattern</var> and replaces it with <var>replacement</var> in
13752the value of <code>var</code>, is available (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
13753
13754</li><li> The expansion <code>${!<var>prefix</var>*}</code> expansion, which expands to
13755the names of all shell variables whose names begin with <var>prefix</var>,
13756is available (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
13757
13758</li><li> Bash has <var>indirect</var> variable expansion using <code>${!word}</code>
13759(see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
13760
13761</li><li> Bash can expand positional parameters beyond <code>$9</code> using
13762<code>${<var>num</var>}</code>.
13763
13764</li><li> The <small>POSIX</small> <code>$()</code> form of command substitution
13765is implemented (see <a href="#Command-Substitution">Command Substitution</a>),
13766and preferred to the Bourne shell&rsquo;s <code>``</code> (which
17345e5a 13767is also implemented for backwards compatibility).
a0c0a00f
CR
13768
13769</li><li> Bash has process substitution (see <a href="#Process-Substitution">Process Substitution</a>).
13770
13771</li><li> Bash automatically assigns variables that provide information about the
13772current user (<code>UID</code>, <code>EUID</code>, and <code>GROUPS</code>), the current host
13773(<code>HOSTTYPE</code>, <code>OSTYPE</code>, <code>MACHTYPE</code>, and <code>HOSTNAME</code>),
13774and the instance of Bash that is running (<code>BASH</code>,
13775<code>BASH_VERSION</code>, and <code>BASH_VERSINFO</code>). See <a href="#Bash-Variables">Bash Variables</a>,
17345e5a 13776for details.
17345e5a 13777
a0c0a00f
CR
13778</li><li> The <code>IFS</code> variable is used to split only the results of expansion,
13779not all words (see <a href="#Word-Splitting">Word Splitting</a>).
17345e5a 13780This closes a longstanding shell security hole.
17345e5a 13781
a0c0a00f 13782</li><li> The filename expansion bracket expression code uses &lsquo;<samp>!</samp>&rsquo; and &lsquo;<samp>^</samp>&rsquo;
ac50fbac 13783to negate the set of characters between the brackets.
a0c0a00f
CR
13784The Bourne shell uses only &lsquo;<samp>!</samp>&rsquo;.
13785
13786</li><li> Bash implements the full set of <small>POSIX</small> filename expansion operators,
13787including <var>character classes</var>, <var>equivalence classes</var>, and
13788<var>collating symbols</var> (see <a href="#Filename-Expansion">Filename Expansion</a>).
13789
13790</li><li> Bash implements extended pattern matching features when the <code>extglob</code>
13791shell option is enabled (see <a href="#Pattern-Matching">Pattern Matching</a>).
13792
13793</li><li> It is possible to have a variable and a function with the same name;
13794<code>sh</code> does not separate the two name spaces.
13795
13796</li><li> Bash functions are permitted to have local variables using the
13797<code>local</code> builtin, and thus useful recursive functions may be written
13798(see <a href="#Bash-Builtins">Bash Builtins</a>).
13799
13800</li><li> Variable assignments preceding commands affect only that command, even
13801builtins and functions (see <a href="#Environment">Environment</a>).
13802In <code>sh</code>, all variable assignments
17345e5a
JA
13803preceding commands are global unless the command is executed from the
13804file system.
17345e5a 13805
a0c0a00f
CR
13806</li><li> Bash performs filename expansion on filenames specified as operands
13807to input and output redirection operators (see <a href="#Redirections">Redirections</a>).
17345e5a 13808
a0c0a00f
CR
13809</li><li> Bash contains the &lsquo;<samp>&lt;&gt;</samp>&rsquo; redirection operator, allowing a file to be
13810opened for both reading and writing, and the &lsquo;<samp>&amp;&gt;</samp>&rsquo; redirection
17345e5a 13811operator, for directing standard output and standard error to the same
a0c0a00f 13812file (see <a href="#Redirections">Redirections</a>).
17345e5a 13813
a0c0a00f 13814</li><li> Bash includes the &lsquo;<samp>&lt;&lt;&lt;</samp>&rsquo; redirection operator, allowing a string to
17345e5a 13815be used as the standard input to a command.
17345e5a 13816
a0c0a00f 13817</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;
17345e5a 13818redirection operators, which move one file descriptor to another.
a0c0a00f
CR
13819
13820</li><li> Bash treats a number of filenames specially when they are
13821used in redirection operators (see <a href="#Redirections">Redirections</a>).
13822
13823</li><li> Bash can open network connections to arbitrary machines and services
13824with the redirection operators (see <a href="#Redirections">Redirections</a>).
13825
13826</li><li> The <code>noclobber</code> option is available to avoid overwriting existing
13827files with output redirection (see <a href="#The-Set-Builtin">The Set Builtin</a>).
13828The &lsquo;<samp>&gt;|</samp>&rsquo; redirection operator may be used to override <code>noclobber</code>.
13829
13830</li><li> The Bash <code>cd</code> and <code>pwd</code> builtins (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>)
13831each take <samp>-L</samp> and <samp>-P</samp> options to switch between logical and
17345e5a 13832physical modes.
a0c0a00f
CR
13833
13834</li><li> Bash allows a function to override a builtin with the same name, and provides
13835access to that builtin&rsquo;s functionality within the function via the
13836<code>builtin</code> and <code>command</code> builtins (see <a href="#Bash-Builtins">Bash Builtins</a>).
13837
13838</li><li> The <code>command</code> builtin allows selective disabling of functions
13839when command lookup is performed (see <a href="#Bash-Builtins">Bash Builtins</a>).
13840
13841</li><li> Individual builtins may be enabled or disabled using the <code>enable</code>
13842builtin (see <a href="#Bash-Builtins">Bash Builtins</a>).
13843
13844</li><li> The Bash <code>exec</code> builtin takes additional options that allow users
17345e5a
JA
13845to control the contents of the environment passed to the executed
13846command, and what the zeroth argument to the command is to be
a0c0a00f 13847(see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
17345e5a 13848
a0c0a00f
CR
13849</li><li> Shell functions may be exported to children via the environment
13850using <code>export -f</code> (see <a href="#Shell-Functions">Shell Functions</a>).
17345e5a 13851
a0c0a00f
CR
13852</li><li> The Bash <code>export</code>, <code>readonly</code>, and <code>declare</code> builtins can
13853take a <samp>-f</samp> option to act on shell functions, a <samp>-p</samp> option to
17345e5a 13854display variables with various attributes set in a format that can be
a0c0a00f
CR
13855used as shell input, a <samp>-n</samp> option to remove various variable
13856attributes, and &lsquo;<samp>name=value</samp>&rsquo; arguments to set variable attributes
17345e5a 13857and values simultaneously.
17345e5a 13858
a0c0a00f 13859</li><li> The Bash <code>hash</code> builtin allows a name to be associated with
17345e5a 13860an arbitrary filename, even when that filename cannot be found by
a0c0a00f
CR
13861searching the <code>$PATH</code>, using &lsquo;<samp>hash -p</samp>&rsquo;
13862(see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
13863
13864</li><li> Bash includes a <code>help</code> builtin for quick reference to shell
13865facilities (see <a href="#Bash-Builtins">Bash Builtins</a>).
13866
13867</li><li> The <code>printf</code> builtin is available to display formatted output
13868(see <a href="#Bash-Builtins">Bash Builtins</a>).
13869
13870</li><li> The Bash <code>read</code> builtin (see <a href="#Bash-Builtins">Bash Builtins</a>)
13871will read a line ending in &lsquo;<samp>\</samp>&rsquo; with
13872the <samp>-r</samp> option, and will use the <code>REPLY</code> variable as a
17345e5a 13873default if no non-option arguments are supplied.
a0c0a00f
CR
13874The Bash <code>read</code> builtin
13875also accepts a prompt string with the <samp>-p</samp> option and will use
13876Readline to obtain the line when given the <samp>-e</samp> option.
13877The <code>read</code> builtin also has additional options to control input:
13878the <samp>-s</samp> option will turn off echoing of input characters as
13879they are read, the <samp>-t</samp> option will allow <code>read</code> to time out
17345e5a 13880if input does not arrive within a specified number of seconds, the
a0c0a00f
CR
13881<samp>-n</samp> option will allow reading only a specified number of
13882characters rather than a full line, and the <samp>-d</samp> option will read
17345e5a 13883until a particular character rather than newline.
a0c0a00f
CR
13884
13885</li><li> The <code>return</code> builtin may be used to abort execution of scripts
13886executed with the <code>.</code> or <code>source</code> builtins
13887(see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
13888
13889</li><li> Bash includes the <code>shopt</code> builtin, for finer control of shell
13890optional capabilities (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), and allows these options
13891to be set and unset at shell invocation (see <a href="#Invoking-Bash">Invoking Bash</a>).
13892
13893</li><li> Bash has much more optional behavior controllable with the <code>set</code>
13894builtin (see <a href="#The-Set-Builtin">The Set Builtin</a>).
13895
13896</li><li> The &lsquo;<samp>-x</samp>&rsquo; (<samp>xtrace</samp>) option displays commands other than
17345e5a 13897simple commands when performing an execution trace
a0c0a00f 13898(see <a href="#The-Set-Builtin">The Set Builtin</a>).
17345e5a 13899
a0c0a00f
CR
13900</li><li> The <code>test</code> builtin (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>)
13901is slightly different, as it implements the <small>POSIX</small> algorithm,
17345e5a 13902which specifies the behavior based on the number of arguments.
17345e5a 13903
a0c0a00f 13904</li><li> Bash includes the <code>caller</code> builtin, which displays the context of
17345e5a 13905any active subroutine call (a shell function or a script executed with
a0c0a00f 13906the <code>.</code> or <code>source</code> builtins). This supports the bash
17345e5a 13907debugger.
a0c0a00f
CR
13908
13909</li><li> The <code>trap</code> builtin (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>) allows a
13910<code>DEBUG</code> pseudo-signal specification, similar to <code>EXIT</code>.
13911Commands specified with a <code>DEBUG</code> trap are executed before every
13912simple command, <code>for</code> command, <code>case</code> command,
13913<code>select</code> command, every arithmetic <code>for</code> command, and before
17345e5a 13914the first command executes in a shell function.
a0c0a00f
CR
13915The <code>DEBUG</code> trap is not inherited by shell functions unless the
13916function has been given the <code>trace</code> attribute or the
13917<code>functrace</code> option has been enabled using the <code>shopt</code> builtin.
13918The <code>extdebug</code> shell option has additional effects on the
13919<code>DEBUG</code> trap.
13920
13921<p>The <code>trap</code> builtin (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>) allows an
13922<code>ERR</code> pseudo-signal specification, similar to <code>EXIT</code> and <code>DEBUG</code>.
13923Commands specified with an <code>ERR</code> trap are executed after a simple
17345e5a 13924command fails, with a few exceptions.
a0c0a00f
CR
13925The <code>ERR</code> trap is not inherited by shell functions unless the
13926<code>-o errtrace</code> option to the <code>set</code> builtin is enabled.
13927</p>
13928<p>The <code>trap</code> builtin (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>) allows a
13929<code>RETURN</code> pseudo-signal specification, similar to
13930<code>EXIT</code> and <code>DEBUG</code>.
13931Commands specified with an <code>RETURN</code> trap are executed before
17345e5a 13932execution resumes after a shell function or a shell script executed with
a0c0a00f
CR
13933<code>.</code> or <code>source</code> returns.
13934The <code>RETURN</code> trap is not inherited by shell functions unless the
13935function has been given the <code>trace</code> attribute or the
13936<code>functrace</code> option has been enabled using the <code>shopt</code> builtin.
13937</p>
13938</li><li> The Bash <code>type</code> builtin is more extensive and gives more information
13939about the names it finds (see <a href="#Bash-Builtins">Bash Builtins</a>).
13940
13941</li><li> The Bash <code>umask</code> builtin permits a <samp>-p</samp> option to cause
13942the output to be displayed in the form of a <code>umask</code> command
13943that may be reused as input (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>).
13944
13945</li><li> Bash implements a <code>csh</code>-like directory stack, and provides the
13946<code>pushd</code>, <code>popd</code>, and <code>dirs</code> builtins to manipulate it
13947(see <a href="#The-Directory-Stack">The Directory Stack</a>).
17345e5a 13948Bash also makes the directory stack visible as the value of the
a0c0a00f 13949<code>DIRSTACK</code> shell variable.
17345e5a 13950
a0c0a00f
CR
13951</li><li> Bash interprets special backslash-escaped characters in the prompt
13952strings when interactive (see <a href="#Controlling-the-Prompt">Controlling the Prompt</a>).
17345e5a 13953
a0c0a00f 13954</li><li> The Bash restricted mode is more useful (see <a href="#The-Restricted-Shell">The Restricted Shell</a>);
17345e5a 13955the SVR4.2 shell restricted mode is too limited.
17345e5a 13956
a0c0a00f
CR
13957</li><li> The <code>disown</code> builtin can remove a job from the internal shell
13958job table (see <a href="#Job-Control-Builtins">Job Control Builtins</a>) or suppress the sending
13959of <code>SIGHUP</code> to a job when the shell exits as the result of a
13960<code>SIGHUP</code>.
17345e5a 13961
a0c0a00f 13962</li><li> Bash includes a number of features to support a separate debugger for
17345e5a 13963shell scripts.
17345e5a 13964
a0c0a00f
CR
13965</li><li> The SVR4.2 shell has two privilege-related builtins
13966(<code>mldmode</code> and <code>priv</code>) not present in Bash.
13967
13968</li><li> Bash does not have the <code>stop</code> or <code>newgrp</code> builtins.
13969
13970</li><li> Bash does not use the <code>SHACCT</code> variable or perform shell accounting.
17345e5a 13971
a0c0a00f
CR
13972</li><li> The SVR4.2 <code>sh</code> uses a <code>TIMEOUT</code> variable like Bash uses
13973<code>TMOUT</code>.
13974
13975</li></ul>
13976
13977<p>More features unique to Bash may be found in <a href="#Bash-Features">Bash Features</a>.
13978</p>
13979
13980<a name="Implementation-Differences-From-The-SVR4_002e2-Shell"></a>
13981<h3 class="appendixsec">B.1 Implementation Differences From The SVR4.2 Shell</h3>
13982
13983<p>Since Bash is a completely new implementation, it does not suffer from
13984many of the limitations of the SVR4.2 shell. For instance:
13985</p>
13986<ul>
13987<li> Bash does not fork a subshell when redirecting into or out of
13988a shell control structure such as an <code>if</code> or <code>while</code>
17345e5a 13989statement.
17345e5a 13990
a0c0a00f
CR
13991</li><li> Bash does not allow unbalanced quotes. The SVR4.2 shell will silently
13992insert a needed closing quote at <code>EOF</code> under certain circumstances.
17345e5a 13993This can be the cause of some hard-to-find errors.
17345e5a 13994
a0c0a00f
CR
13995</li><li> The SVR4.2 shell uses a baroque memory management scheme based on
13996trapping <code>SIGSEGV</code>. If the shell is started from a process with
13997<code>SIGSEGV</code> blocked (e.g., by using the <code>system()</code> C library
17345e5a 13998function call), it misbehaves badly.
17345e5a 13999
a0c0a00f
CR
14000</li><li> In a questionable attempt at security, the SVR4.2 shell,
14001when invoked without the <samp>-p</samp> option, will alter its real
14002and effective <small>UID</small> and <small>GID</small> if they are less than some
17345e5a
JA
14003magic threshold value, commonly 100.
14004This can lead to unexpected results.
a0c0a00f
CR
14005
14006</li><li> The SVR4.2 shell does not allow users to trap <code>SIGSEGV</code>,
14007<code>SIGALRM</code>, or <code>SIGCHLD</code>.
14008
14009</li><li> The SVR4.2 shell does not allow the <code>IFS</code>, <code>MAILCHECK</code>,
14010<code>PATH</code>, <code>PS1</code>, or <code>PS2</code> variables to be unset.
14011
14012</li><li> The SVR4.2 shell treats &lsquo;<samp>^</samp>&rsquo; as the undocumented equivalent of
14013&lsquo;<samp>|</samp>&rsquo;.
14014
14015</li><li> Bash allows multiple option arguments when it is invoked (<code>-x -v</code>);
14016the SVR4.2 shell allows only one option argument (<code>-xv</code>). In
17345e5a 14017fact, some versions of the shell dump core if the second argument begins
a0c0a00f 14018with a &lsquo;<samp>-</samp>&rsquo;.
17345e5a 14019
a0c0a00f
CR
14020</li><li> The SVR4.2 shell exits a script if any builtin fails; Bash exits
14021a script only if one of the <small>POSIX</small> special builtins fails, and
14022only for certain failures, as enumerated in the <small>POSIX</small> standard.
17345e5a 14023
a0c0a00f 14024</li><li> The SVR4.2 shell behaves differently when invoked as <code>jsh</code>
17345e5a 14025(it turns on job control).
a0c0a00f
CR
14026</li></ul>
14027
14028<hr>
14029<a name="GNU-Free-Documentation-License"></a>
14030<div class="header">
14031<p>
14032Next: <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>
14033</div>
14034<a name="GNU-Free-Documentation-License-1"></a>
14035<h2 class="appendix">Appendix C GNU Free Documentation License</h2>
14036
14037<div align="center">Version 1.3, 3 November 2008
14038</div>
14039
14040<div class="display">
14041<pre class="display">Copyright &copy; 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
14042<a href="http://fsf.org/">http://fsf.org/</a>
17345e5a
JA
14043
14044Everyone is permitted to copy and distribute verbatim copies
14045of this license document, but changing it is not allowed.
a0c0a00f 14046</pre></div>
17345e5a 14047
9a51695b 14048<ol start="0">
a0c0a00f 14049<li> PREAMBLE
17345e5a 14050
a0c0a00f
CR
14051<p>The purpose of this License is to make a manual, textbook, or other
14052functional and useful document <em>free</em> in the sense of freedom: to
17345e5a
JA
14053assure everyone the effective freedom to copy and redistribute it,
14054with or without modifying it, either commercially or noncommercially.
14055Secondarily, this License preserves for the author and publisher a way
14056to get credit for their work, while not being considered responsible
14057for modifications made by others.
a0c0a00f
CR
14058</p>
14059<p>This License is a kind of &ldquo;copyleft&rdquo;, which means that derivative
17345e5a
JA
14060works of the document must themselves be free in the same sense. It
14061complements the GNU General Public License, which is a copyleft
14062license designed for free software.
a0c0a00f
CR
14063</p>
14064<p>We have designed this License in order to use it for manuals for free
17345e5a
JA
14065software, because free software needs free documentation: a free
14066program should come with manuals providing the same freedoms that the
14067software does. But this License is not limited to software manuals;
14068it can be used for any textual work, regardless of subject matter or
14069whether it is published as a printed book. We recommend this License
14070principally for works whose purpose is instruction or reference.
a0c0a00f
CR
14071</p>
14072</li><li> APPLICABILITY AND DEFINITIONS
17345e5a 14073
a0c0a00f 14074<p>This License applies to any manual or other work, in any medium, that
17345e5a
JA
14075contains a notice placed by the copyright holder saying it can be
14076distributed under the terms of this License. Such a notice grants a
14077world-wide, royalty-free license, unlimited in duration, to use that
a0c0a00f 14078work under the conditions stated herein. The &ldquo;Document&rdquo;, below,
17345e5a 14079refers to any such manual or work. Any member of the public is a
a0c0a00f 14080licensee, and is addressed as &ldquo;you&rdquo;. You accept the license if you
17345e5a
JA
14081copy, modify or distribute the work in a way requiring permission
14082under copyright law.
a0c0a00f
CR
14083</p>
14084<p>A &ldquo;Modified Version&rdquo; of the Document means any work containing the
17345e5a
JA
14085Document or a portion of it, either copied verbatim, or with
14086modifications and/or translated into another language.
a0c0a00f
CR
14087</p>
14088<p>A &ldquo;Secondary Section&rdquo; is a named appendix or a front-matter section
17345e5a 14089of the Document that deals exclusively with the relationship of the
a0c0a00f 14090publishers or authors of the Document to the Document&rsquo;s overall
17345e5a
JA
14091subject (or to related matters) and contains nothing that could fall
14092directly within that overall subject. (Thus, if the Document is in
14093part a textbook of mathematics, a Secondary Section may not explain
14094any mathematics.) The relationship could be a matter of historical
14095connection with the subject or with related matters, or of legal,
14096commercial, philosophical, ethical or political position regarding
14097them.
a0c0a00f
CR
14098</p>
14099<p>The &ldquo;Invariant Sections&rdquo; are certain Secondary Sections whose titles
17345e5a
JA
14100are designated, as being those of Invariant Sections, in the notice
14101that says that the Document is released under this License. If a
14102section does not fit the above definition of Secondary then it is not
14103allowed to be designated as Invariant. The Document may contain zero
14104Invariant Sections. If the Document does not identify any Invariant
14105Sections then there are none.
a0c0a00f
CR
14106</p>
14107<p>The &ldquo;Cover Texts&rdquo; are certain short passages of text that are listed,
17345e5a
JA
14108as Front-Cover Texts or Back-Cover Texts, in the notice that says that
14109the Document is released under this License. A Front-Cover Text may
14110be at most 5 words, and a Back-Cover Text may be at most 25 words.
a0c0a00f
CR
14111</p>
14112<p>A &ldquo;Transparent&rdquo; copy of the Document means a machine-readable copy,
17345e5a
JA
14113represented in a format whose specification is available to the
14114general public, that is suitable for revising the document
14115straightforwardly with generic text editors or (for images composed of
14116pixels) generic paint programs or (for drawings) some widely available
14117drawing editor, and that is suitable for input to text formatters or
14118for automatic translation to a variety of formats suitable for input
14119to text formatters. A copy made in an otherwise Transparent file
14120format whose markup, or absence of markup, has been arranged to thwart
14121or discourage subsequent modification by readers is not Transparent.
14122An image format is not Transparent if used for any substantial amount
a0c0a00f
CR
14123of text. A copy that is not &ldquo;Transparent&rdquo; is called &ldquo;Opaque&rdquo;.
14124</p>
14125<p>Examples of suitable formats for Transparent copies include plain
14126<small>ASCII</small> without markup, Texinfo input format, LaTeX input
14127format, <acronym>SGML</acronym> or <acronym>XML</acronym> using a publicly available
14128<acronym>DTD</acronym>, and standard-conforming simple <acronym>HTML</acronym>,
14129PostScript or <acronym>PDF</acronym> designed for human modification. Examples
14130of transparent image formats include <acronym>PNG</acronym>, <acronym>XCF</acronym> and
14131<acronym>JPG</acronym>. Opaque formats include proprietary formats that can be
14132read and edited only by proprietary word processors, <acronym>SGML</acronym> or
14133<acronym>XML</acronym> for which the <acronym>DTD</acronym> and/or processing tools are
14134not generally available, and the machine-generated <acronym>HTML</acronym>,
14135PostScript or <acronym>PDF</acronym> produced by some word processors for
17345e5a 14136output purposes only.
a0c0a00f
CR
14137</p>
14138<p>The &ldquo;Title Page&rdquo; means, for a printed book, the title page itself,
17345e5a
JA
14139plus such following pages as are needed to hold, legibly, the material
14140this License requires to appear in the title page. For works in
a0c0a00f
CR
14141formats which do not have any title page as such, &ldquo;Title Page&rdquo; means
14142the text near the most prominent appearance of the work&rsquo;s title,
17345e5a 14143preceding the beginning of the body of the text.
a0c0a00f
CR
14144</p>
14145<p>The &ldquo;publisher&rdquo; means any person or entity that distributes copies
0001803f 14146of the Document to the public.
a0c0a00f
CR
14147</p>
14148<p>A section &ldquo;Entitled XYZ&rdquo; means a named subunit of the Document whose
17345e5a
JA
14149title either is precisely XYZ or contains XYZ in parentheses following
14150text that translates XYZ in another language. (Here XYZ stands for a
a0c0a00f
CR
14151specific section name mentioned below, such as &ldquo;Acknowledgements&rdquo;,
14152&ldquo;Dedications&rdquo;, &ldquo;Endorsements&rdquo;, or &ldquo;History&rdquo;.) To &ldquo;Preserve the Title&rdquo;
17345e5a 14153of such a section when you modify the Document means that it remains a
a0c0a00f
CR
14154section &ldquo;Entitled XYZ&rdquo; according to this definition.
14155</p>
14156<p>The Document may include Warranty Disclaimers next to the notice which
17345e5a
JA
14157states that this License applies to the Document. These Warranty
14158Disclaimers are considered to be included by reference in this
14159License, but only as regards disclaiming warranties: any other
14160implication that these Warranty Disclaimers may have is void and has
14161no effect on the meaning of this License.
a0c0a00f
CR
14162</p>
14163</li><li> VERBATIM COPYING
17345e5a 14164
a0c0a00f 14165<p>You may copy and distribute the Document in any medium, either
17345e5a
JA
14166commercially or noncommercially, provided that this License, the
14167copyright notices, and the license notice saying this License applies
14168to the Document are reproduced in all copies, and that you add no other
14169conditions whatsoever to those of this License. You may not use
14170technical measures to obstruct or control the reading or further
14171copying of the copies you make or distribute. However, you may accept
14172compensation in exchange for copies. If you distribute a large enough
14173number of copies you must also follow the conditions in section 3.
a0c0a00f
CR
14174</p>
14175<p>You may also lend copies, under the same conditions stated above, and
17345e5a 14176you may publicly display copies.
a0c0a00f
CR
14177</p>
14178</li><li> COPYING IN QUANTITY
17345e5a 14179
a0c0a00f 14180<p>If you publish printed copies (or copies in media that commonly have
17345e5a 14181printed covers) of the Document, numbering more than 100, and the
a0c0a00f 14182Document&rsquo;s license notice requires Cover Texts, you must enclose the
17345e5a
JA
14183copies in covers that carry, clearly and legibly, all these Cover
14184Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
14185the back cover. Both covers must also clearly and legibly identify
14186you as the publisher of these copies. The front cover must present
14187the full title with all words of the title equally prominent and
14188visible. You may add other material on the covers in addition.
14189Copying with changes limited to the covers, as long as they preserve
14190the title of the Document and satisfy these conditions, can be treated
14191as verbatim copying in other respects.
a0c0a00f
CR
14192</p>
14193<p>If the required texts for either cover are too voluminous to fit
17345e5a
JA
14194legibly, you should put the first ones listed (as many as fit
14195reasonably) on the actual cover, and continue the rest onto adjacent
14196pages.
a0c0a00f
CR
14197</p>
14198<p>If you publish or distribute Opaque copies of the Document numbering
17345e5a
JA
14199more than 100, you must either include a machine-readable Transparent
14200copy along with each Opaque copy, or state in or with each Opaque copy
14201a computer-network location from which the general network-using
14202public has access to download using public-standard network protocols
14203a complete Transparent copy of the Document, free of added material.
14204If you use the latter option, you must take reasonably prudent steps,
14205when you begin distribution of Opaque copies in quantity, to ensure
14206that this Transparent copy will remain thus accessible at the stated
14207location until at least one year after the last time you distribute an
14208Opaque copy (directly or through your agents or retailers) of that
14209edition to the public.
a0c0a00f
CR
14210</p>
14211<p>It is requested, but not required, that you contact the authors of the
17345e5a
JA
14212Document well before redistributing any large number of copies, to give
14213them a chance to provide you with an updated version of the Document.
a0c0a00f
CR
14214</p>
14215</li><li> MODIFICATIONS
17345e5a 14216
a0c0a00f 14217<p>You may copy and distribute a Modified Version of the Document under
17345e5a
JA
14218the conditions of sections 2 and 3 above, provided that you release
14219the Modified Version under precisely this License, with the Modified
14220Version filling the role of the Document, thus licensing distribution
14221and modification of the Modified Version to whoever possesses a copy
14222of it. In addition, you must do these things in the Modified Version:
a0c0a00f 14223</p>
9a51695b 14224<ol type="A" start="1">
a0c0a00f 14225<li> Use in the Title Page (and on the covers, if any) a title distinct
17345e5a
JA
14226from that of the Document, and from those of previous versions
14227(which should, if there were any, be listed in the History section
14228of the Document). You may use the same title as a previous version
14229if the original publisher of that version gives permission.
17345e5a 14230
a0c0a00f 14231</li><li> List on the Title Page, as authors, one or more persons or entities
17345e5a
JA
14232responsible for authorship of the modifications in the Modified
14233Version, together with at least five of the principal authors of the
14234Document (all of its principal authors, if it has fewer than five),
14235unless they release you from this requirement.
17345e5a 14236
a0c0a00f 14237</li><li> State on the Title page the name of the publisher of the
17345e5a 14238Modified Version, as the publisher.
17345e5a 14239
a0c0a00f 14240</li><li> Preserve all the copyright notices of the Document.
17345e5a 14241
a0c0a00f 14242</li><li> Add an appropriate copyright notice for your modifications
17345e5a 14243adjacent to the other copyright notices.
17345e5a 14244
a0c0a00f 14245</li><li> Include, immediately after the copyright notices, a license notice
17345e5a
JA
14246giving the public permission to use the Modified Version under the
14247terms of this License, in the form shown in the Addendum below.
17345e5a 14248
a0c0a00f
CR
14249</li><li> Preserve in that license notice the full lists of Invariant Sections
14250and required Cover Texts given in the Document&rsquo;s license notice.
17345e5a 14251
a0c0a00f 14252</li><li> Include an unaltered copy of this License.
17345e5a 14253
a0c0a00f 14254</li><li> Preserve the section Entitled &ldquo;History&rdquo;, Preserve its Title, and add
17345e5a
JA
14255to it an item stating at least the title, year, new authors, and
14256publisher of the Modified Version as given on the Title Page. If
a0c0a00f 14257there is no section Entitled &ldquo;History&rdquo; in the Document, create one
17345e5a
JA
14258stating the title, year, authors, and publisher of the Document as
14259given on its Title Page, then add an item describing the Modified
14260Version as stated in the previous sentence.
17345e5a 14261
a0c0a00f 14262</li><li> Preserve the network location, if any, given in the Document for
17345e5a
JA
14263public access to a Transparent copy of the Document, and likewise
14264the network locations given in the Document for previous versions
a0c0a00f 14265it was based on. These may be placed in the &ldquo;History&rdquo; section.
17345e5a
JA
14266You may omit a network location for a work that was published at
14267least four years before the Document itself, or if the original
14268publisher of the version it refers to gives permission.
17345e5a 14269
a0c0a00f 14270</li><li> For any section Entitled &ldquo;Acknowledgements&rdquo; or &ldquo;Dedications&rdquo;, Preserve
17345e5a
JA
14271the Title of the section, and preserve in the section all the
14272substance and tone of each of the contributor acknowledgements and/or
14273dedications given therein.
17345e5a 14274
a0c0a00f 14275</li><li> Preserve all the Invariant Sections of the Document,
17345e5a
JA
14276unaltered in their text and in their titles. Section numbers
14277or the equivalent are not considered part of the section titles.
17345e5a 14278
a0c0a00f 14279</li><li> Delete any section Entitled &ldquo;Endorsements&rdquo;. Such a section
17345e5a 14280may not be included in the Modified Version.
17345e5a 14281
a0c0a00f 14282</li><li> Do not retitle any existing section to be Entitled &ldquo;Endorsements&rdquo; or
17345e5a 14283to conflict in title with any Invariant Section.
17345e5a 14284
a0c0a00f
CR
14285</li><li> Preserve any Warranty Disclaimers.
14286</li></ol>
17345e5a 14287
a0c0a00f 14288<p>If the Modified Version includes new front-matter sections or
17345e5a
JA
14289appendices that qualify as Secondary Sections and contain no material
14290copied from the Document, you may at your option designate some or all
14291of these sections as invariant. To do this, add their titles to the
a0c0a00f 14292list of Invariant Sections in the Modified Version&rsquo;s license notice.
17345e5a 14293These titles must be distinct from any other section titles.
a0c0a00f
CR
14294</p>
14295<p>You may add a section Entitled &ldquo;Endorsements&rdquo;, provided it contains
17345e5a 14296nothing but endorsements of your Modified Version by various
a0c0a00f 14297parties&mdash;for example, statements of peer review or that the text has
17345e5a
JA
14298been approved by an organization as the authoritative definition of a
14299standard.
a0c0a00f
CR
14300</p>
14301<p>You may add a passage of up to five words as a Front-Cover Text, and a
17345e5a
JA
14302passage of up to 25 words as a Back-Cover Text, to the end of the list
14303of Cover Texts in the Modified Version. Only one passage of
14304Front-Cover Text and one of Back-Cover Text may be added by (or
14305through arrangements made by) any one entity. If the Document already
14306includes a cover text for the same cover, previously added by you or
14307by arrangement made by the same entity you are acting on behalf of,
14308you may not add another; but you may replace the old one, on explicit
14309permission from the previous publisher that added the old one.
a0c0a00f
CR
14310</p>
14311<p>The author(s) and publisher(s) of the Document do not by this License
17345e5a
JA
14312give permission to use their names for publicity for or to assert or
14313imply endorsement of any Modified Version.
a0c0a00f
CR
14314</p>
14315</li><li> COMBINING DOCUMENTS
17345e5a 14316
a0c0a00f 14317<p>You may combine the Document with other documents released under this
17345e5a
JA
14318License, under the terms defined in section 4 above for modified
14319versions, provided that you include in the combination all of the
14320Invariant Sections of all of the original documents, unmodified, and
14321list them all as Invariant Sections of your combined work in its
14322license notice, and that you preserve all their Warranty Disclaimers.
a0c0a00f
CR
14323</p>
14324<p>The combined work need only contain one copy of this License, and
17345e5a
JA
14325multiple identical Invariant Sections may be replaced with a single
14326copy. If there are multiple Invariant Sections with the same name but
14327different contents, make the title of each such section unique by
14328adding at the end of it, in parentheses, the name of the original
14329author or publisher of that section if known, or else a unique number.
14330Make the same adjustment to the section titles in the list of
14331Invariant Sections in the license notice of the combined work.
a0c0a00f
CR
14332</p>
14333<p>In the combination, you must combine any sections Entitled &ldquo;History&rdquo;
17345e5a 14334in the various original documents, forming one section Entitled
a0c0a00f
CR
14335&ldquo;History&rdquo;; likewise combine any sections Entitled &ldquo;Acknowledgements&rdquo;,
14336and any sections Entitled &ldquo;Dedications&rdquo;. You must delete all
14337sections Entitled &ldquo;Endorsements.&rdquo;
14338</p>
14339</li><li> COLLECTIONS OF DOCUMENTS
17345e5a 14340
a0c0a00f 14341<p>You may make a collection consisting of the Document and other documents
17345e5a
JA
14342released under this License, and replace the individual copies of this
14343License in the various documents with a single copy that is included in
14344the collection, provided that you follow the rules of this License for
14345verbatim copying of each of the documents in all other respects.
a0c0a00f
CR
14346</p>
14347<p>You may extract a single document from such a collection, and distribute
17345e5a
JA
14348it individually under this License, provided you insert a copy of this
14349License into the extracted document, and follow this License in all
14350other respects regarding verbatim copying of that document.
a0c0a00f
CR
14351</p>
14352</li><li> AGGREGATION WITH INDEPENDENT WORKS
17345e5a 14353
a0c0a00f 14354<p>A compilation of the Document or its derivatives with other separate
17345e5a 14355and independent documents or works, in or on a volume of a storage or
a0c0a00f 14356distribution medium, is called an &ldquo;aggregate&rdquo; if the copyright
17345e5a 14357resulting from the compilation is not used to limit the legal rights
a0c0a00f 14358of the compilation&rsquo;s users beyond what the individual works permit.
17345e5a
JA
14359When the Document is included in an aggregate, this License does not
14360apply to the other works in the aggregate which are not themselves
14361derivative works of the Document.
a0c0a00f
CR
14362</p>
14363<p>If the Cover Text requirement of section 3 is applicable to these
17345e5a 14364copies of the Document, then if the Document is less than one half of
a0c0a00f 14365the entire aggregate, the Document&rsquo;s Cover Texts may be placed on
17345e5a
JA
14366covers that bracket the Document within the aggregate, or the
14367electronic equivalent of covers if the Document is in electronic form.
14368Otherwise they must appear on printed covers that bracket the whole
14369aggregate.
a0c0a00f
CR
14370</p>
14371</li><li> TRANSLATION
17345e5a 14372
a0c0a00f 14373<p>Translation is considered a kind of modification, so you may
17345e5a
JA
14374distribute translations of the Document under the terms of section 4.
14375Replacing Invariant Sections with translations requires special
14376permission from their copyright holders, but you may include
14377translations of some or all Invariant Sections in addition to the
14378original versions of these Invariant Sections. You may include a
14379translation of this License, and all the license notices in the
14380Document, and any Warranty Disclaimers, provided that you also include
14381the original English version of this License and the original versions
14382of those notices and disclaimers. In case of a disagreement between
14383the translation and the original version of this License or a notice
14384or disclaimer, the original version will prevail.
a0c0a00f
CR
14385</p>
14386<p>If a section in the Document is Entitled &ldquo;Acknowledgements&rdquo;,
14387&ldquo;Dedications&rdquo;, or &ldquo;History&rdquo;, the requirement (section 4) to Preserve
17345e5a
JA
14388its Title (section 1) will typically require changing the actual
14389title.
a0c0a00f
CR
14390</p>
14391</li><li> TERMINATION
17345e5a 14392
a0c0a00f 14393<p>You may not copy, modify, sublicense, or distribute the Document
0001803f
CR
14394except as expressly provided under this License. Any attempt
14395otherwise to copy, modify, sublicense, or distribute it is void, and
14396will automatically terminate your rights under this License.
a0c0a00f
CR
14397</p>
14398<p>However, if you cease all violation of this License, then your license
0001803f
CR
14399from a particular copyright holder is reinstated (a) provisionally,
14400unless and until the copyright holder explicitly and finally
14401terminates your license, and (b) permanently, if the copyright holder
14402fails to notify you of the violation by some reasonable means prior to
1440360 days after the cessation.
a0c0a00f
CR
14404</p>
14405<p>Moreover, your license from a particular copyright holder is
0001803f
CR
14406reinstated permanently if the copyright holder notifies you of the
14407violation by some reasonable means, this is the first time you have
14408received notice of violation of this License (for any work) from that
14409copyright holder, and you cure the violation prior to 30 days after
14410your receipt of the notice.
a0c0a00f
CR
14411</p>
14412<p>Termination of your rights under this section does not terminate the
0001803f
CR
14413licenses of parties who have received copies or rights from you under
14414this License. If your rights have been terminated and not permanently
14415reinstated, receipt of a copy of some or all of the same material does
14416not give you any rights to use it.
a0c0a00f
CR
14417</p>
14418</li><li> FUTURE REVISIONS OF THIS LICENSE
17345e5a 14419
a0c0a00f 14420<p>The Free Software Foundation may publish new, revised versions
17345e5a
JA
14421of the GNU Free Documentation License from time to time. Such new
14422versions will be similar in spirit to the present version, but may
14423differ in detail to address new problems or concerns. See
a0c0a00f
CR
14424<a href="http://www.gnu.org/copyleft/">http://www.gnu.org/copyleft/</a>.
14425</p>
14426<p>Each version of the License is given a distinguishing version number.
17345e5a 14427If the Document specifies that a particular numbered version of this
a0c0a00f 14428License &ldquo;or any later version&rdquo; applies to it, you have the option of
17345e5a
JA
14429following the terms and conditions either of that specified version or
14430of any later version that has been published (not as a draft) by the
14431Free Software Foundation. If the Document does not specify a version
14432number of this License, you may choose any version ever published (not
0001803f
CR
14433as a draft) by the Free Software Foundation. If the Document
14434specifies that a proxy can decide which future versions of this
a0c0a00f 14435License can be used, that proxy&rsquo;s public statement of acceptance of a
0001803f
CR
14436version permanently authorizes you to choose that version for the
14437Document.
a0c0a00f
CR
14438</p>
14439</li><li> RELICENSING
0001803f 14440
a0c0a00f 14441<p>&ldquo;Massive Multiauthor Collaboration Site&rdquo; (or &ldquo;MMC Site&rdquo;) means any
0001803f
CR
14442World Wide Web server that publishes copyrightable works and also
14443provides prominent facilities for anybody to edit those works. A
14444public wiki that anybody can edit is an example of such a server. A
a0c0a00f 14445&ldquo;Massive Multiauthor Collaboration&rdquo; (or &ldquo;MMC&rdquo;) contained in the
0001803f
CR
14446site means any set of copyrightable works thus published on the MMC
14447site.
a0c0a00f
CR
14448</p>
14449<p>&ldquo;CC-BY-SA&rdquo; means the Creative Commons Attribution-Share Alike 3.0
0001803f
CR
14450license published by Creative Commons Corporation, a not-for-profit
14451corporation with a principal place of business in San Francisco,
14452California, as well as future copyleft versions of that license
14453published by that same organization.
a0c0a00f
CR
14454</p>
14455<p>&ldquo;Incorporate&rdquo; means to publish or republish a Document, in whole or
0001803f 14456in part, as part of another Document.
a0c0a00f
CR
14457</p>
14458<p>An MMC is &ldquo;eligible for relicensing&rdquo; if it is licensed under this
0001803f
CR
14459License, and if all works that were first published under this License
14460somewhere other than this MMC, and subsequently incorporated in whole
14461or in part into the MMC, (1) had no cover texts or invariant sections,
14462and (2) were thus incorporated prior to November 1, 2008.
a0c0a00f
CR
14463</p>
14464<p>The operator of an MMC Site may republish an MMC contained in the site
0001803f
CR
14465under CC-BY-SA on the same site at any time before August 1, 2009,
14466provided the MMC is eligible for relicensing.
a0c0a00f
CR
14467</p>
14468</li></ol>
17345e5a 14469
a0c0a00f
CR
14470<a name="ADDENDUM_003a-How-to-use-this-License-for-your-documents"></a>
14471<h3 class="heading">ADDENDUM: How to use this License for your documents</h3>
17345e5a 14472
a0c0a00f 14473<p>To use this License in a document you have written, include a copy of
17345e5a
JA
14474the License in the document and put the following copyright and
14475license notices just after the title page:
a0c0a00f
CR
14476</p>
14477<div class="smallexample">
14478<pre class="smallexample"> Copyright (C) <var>year</var> <var>your name</var>.
17345e5a 14479 Permission is granted to copy, distribute and/or modify this document
0001803f 14480 under the terms of the GNU Free Documentation License, Version 1.3
17345e5a
JA
14481 or any later version published by the Free Software Foundation;
14482 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
14483 Texts. A copy of the license is included in the section entitled ``GNU
14484 Free Documentation License''.
a0c0a00f
CR
14485</pre></div>
14486
14487<p>If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
14488replace the &ldquo;with&hellip;Texts.&rdquo; line with this:
14489</p>
14490<div class="smallexample">
14491<pre class="smallexample"> with the Invariant Sections being <var>list their titles</var>, with
14492 the Front-Cover Texts being <var>list</var>, and with the Back-Cover Texts
14493 being <var>list</var>.
14494</pre></div>
14495
14496<p>If you have Invariant Sections without Cover Texts, or some other
17345e5a
JA
14497combination of the three, merge those two alternatives to suit the
14498situation.
a0c0a00f
CR
14499</p>
14500<p>If your document contains nontrivial examples of program code, we
17345e5a
JA
14501recommend releasing these examples in parallel under your choice of
14502free software license, such as the GNU General Public License,
14503to permit their use in free software.
a0c0a00f
CR
14504</p>
14505
14506
14507<hr>
14508<a name="Indexes"></a>
14509<div class="header">
14510<p>
14511Previous: <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>
14512</div>
14513<a name="Indexes-1"></a>
14514<h2 class="appendix">Appendix D Indexes</h2>
14515
14516<table class="menu" border="0" cellspacing="0">
14517<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.
14518</td></tr>
14519<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.
14520</td></tr>
14521<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
14522 variable you want.
14523</td></tr>
14524<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.
14525</td></tr>
14526<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
14527 this manual.
14528</td></tr>
14529</table>
14530
14531<hr>
14532<a name="Builtin-Index"></a>
14533<div class="header">
14534<p>
14535Next: <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>
14536</div>
14537<a name="Index-of-Shell-Builtin-Commands"></a>
14538<h3 class="appendixsec">D.1 Index of Shell Builtin Commands</h3>
14539<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Builtin-Index_bt_symbol-1"><b>.</b></a>
14540 &nbsp;
14541<a class="summary-letter" href="#Builtin-Index_bt_symbol-2"><b>:</b></a>
14542 &nbsp;
14543<a class="summary-letter" href="#Builtin-Index_bt_symbol-3"><b>[</b></a>
17345e5a 14544 &nbsp;
a0c0a00f
CR
14545<br>
14546<a class="summary-letter" href="#Builtin-Index_bt_letter-A"><b>A</b></a>
14547 &nbsp;
14548<a class="summary-letter" href="#Builtin-Index_bt_letter-B"><b>B</b></a>
14549 &nbsp;
14550<a class="summary-letter" href="#Builtin-Index_bt_letter-C"><b>C</b></a>
14551 &nbsp;
14552<a class="summary-letter" href="#Builtin-Index_bt_letter-D"><b>D</b></a>
14553 &nbsp;
14554<a class="summary-letter" href="#Builtin-Index_bt_letter-E"><b>E</b></a>
14555 &nbsp;
14556<a class="summary-letter" href="#Builtin-Index_bt_letter-F"><b>F</b></a>
14557 &nbsp;
14558<a class="summary-letter" href="#Builtin-Index_bt_letter-G"><b>G</b></a>
14559 &nbsp;
14560<a class="summary-letter" href="#Builtin-Index_bt_letter-H"><b>H</b></a>
14561 &nbsp;
14562<a class="summary-letter" href="#Builtin-Index_bt_letter-J"><b>J</b></a>
14563 &nbsp;
14564<a class="summary-letter" href="#Builtin-Index_bt_letter-K"><b>K</b></a>
14565 &nbsp;
14566<a class="summary-letter" href="#Builtin-Index_bt_letter-L"><b>L</b></a>
14567 &nbsp;
14568<a class="summary-letter" href="#Builtin-Index_bt_letter-M"><b>M</b></a>
14569 &nbsp;
14570<a class="summary-letter" href="#Builtin-Index_bt_letter-P"><b>P</b></a>
14571 &nbsp;
14572<a class="summary-letter" href="#Builtin-Index_bt_letter-R"><b>R</b></a>
14573 &nbsp;
14574<a class="summary-letter" href="#Builtin-Index_bt_letter-S"><b>S</b></a>
14575 &nbsp;
14576<a class="summary-letter" href="#Builtin-Index_bt_letter-T"><b>T</b></a>
14577 &nbsp;
14578<a class="summary-letter" href="#Builtin-Index_bt_letter-U"><b>U</b></a>
14579 &nbsp;
14580<a class="summary-letter" href="#Builtin-Index_bt_letter-W"><b>W</b></a>
14581 &nbsp;
14582</td></tr></table>
14583<table class="index-bt" border="0">
14584<tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
14585<tr><td colspan="4"> <hr></td></tr>
14586<tr><th><a name="Builtin-Index_bt_symbol-1">.</a></th><td></td><td></td></tr>
14587<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>
14588<tr><td colspan="4"> <hr></td></tr>
14589<tr><th><a name="Builtin-Index_bt_symbol-2">:</a></th><td></td><td></td></tr>
14590<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>
14591<tr><td colspan="4"> <hr></td></tr>
14592<tr><th><a name="Builtin-Index_bt_symbol-3">[</a></th><td></td><td></td></tr>
14593<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>
14594<tr><td colspan="4"> <hr></td></tr>
14595<tr><th><a name="Builtin-Index_bt_letter-A">A</a></th><td></td><td></td></tr>
14596<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>
14597<tr><td colspan="4"> <hr></td></tr>
14598<tr><th><a name="Builtin-Index_bt_letter-B">B</a></th><td></td><td></td></tr>
14599<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>
14600<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>
14601<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>
14602<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>
14603<tr><td colspan="4"> <hr></td></tr>
14604<tr><th><a name="Builtin-Index_bt_letter-C">C</a></th><td></td><td></td></tr>
14605<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>
14606<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>
14607<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>
14608<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>
14609<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>
14610<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>
14611<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>
14612<tr><td colspan="4"> <hr></td></tr>
14613<tr><th><a name="Builtin-Index_bt_letter-D">D</a></th><td></td><td></td></tr>
14614<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>
14615<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>
14616<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>
14617<tr><td colspan="4"> <hr></td></tr>
14618<tr><th><a name="Builtin-Index_bt_letter-E">E</a></th><td></td><td></td></tr>
14619<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>
14620<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>
14621<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>
14622<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>
14623<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>
14624<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>
14625<tr><td colspan="4"> <hr></td></tr>
14626<tr><th><a name="Builtin-Index_bt_letter-F">F</a></th><td></td><td></td></tr>
14627<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>
14628<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>
14629<tr><td colspan="4"> <hr></td></tr>
14630<tr><th><a name="Builtin-Index_bt_letter-G">G</a></th><td></td><td></td></tr>
14631<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>
14632<tr><td colspan="4"> <hr></td></tr>
14633<tr><th><a name="Builtin-Index_bt_letter-H">H</a></th><td></td><td></td></tr>
14634<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>
14635<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>
14636<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>
14637<tr><td colspan="4"> <hr></td></tr>
14638<tr><th><a name="Builtin-Index_bt_letter-J">J</a></th><td></td><td></td></tr>
14639<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>
14640<tr><td colspan="4"> <hr></td></tr>
14641<tr><th><a name="Builtin-Index_bt_letter-K">K</a></th><td></td><td></td></tr>
14642<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>
14643<tr><td colspan="4"> <hr></td></tr>
14644<tr><th><a name="Builtin-Index_bt_letter-L">L</a></th><td></td><td></td></tr>
14645<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>
14646<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>
14647<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>
14648<tr><td colspan="4"> <hr></td></tr>
14649<tr><th><a name="Builtin-Index_bt_letter-M">M</a></th><td></td><td></td></tr>
14650<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>
14651<tr><td colspan="4"> <hr></td></tr>
14652<tr><th><a name="Builtin-Index_bt_letter-P">P</a></th><td></td><td></td></tr>
14653<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>
14654<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>
14655<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>
14656<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>
14657<tr><td colspan="4"> <hr></td></tr>
14658<tr><th><a name="Builtin-Index_bt_letter-R">R</a></th><td></td><td></td></tr>
14659<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>
14660<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>
14661<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>
14662<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>
14663<tr><td colspan="4"> <hr></td></tr>
14664<tr><th><a name="Builtin-Index_bt_letter-S">S</a></th><td></td><td></td></tr>
14665<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>
14666<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>
14667<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>
14668<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>
14669<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>
14670<tr><td colspan="4"> <hr></td></tr>
14671<tr><th><a name="Builtin-Index_bt_letter-T">T</a></th><td></td><td></td></tr>
14672<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>
14673<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>
14674<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>
14675<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>
14676<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>
14677<tr><td colspan="4"> <hr></td></tr>
14678<tr><th><a name="Builtin-Index_bt_letter-U">U</a></th><td></td><td></td></tr>
14679<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>
14680<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>
14681<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>
14682<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>
14683<tr><td colspan="4"> <hr></td></tr>
14684<tr><th><a name="Builtin-Index_bt_letter-W">W</a></th><td></td><td></td></tr>
14685<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>
14686<tr><td colspan="4"> <hr></td></tr>
14687</table>
14688<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Builtin-Index_bt_symbol-1"><b>.</b></a>
14689 &nbsp;
14690<a class="summary-letter" href="#Builtin-Index_bt_symbol-2"><b>:</b></a>
14691 &nbsp;
14692<a class="summary-letter" href="#Builtin-Index_bt_symbol-3"><b>[</b></a>
17345e5a 14693 &nbsp;
a0c0a00f
CR
14694<br>
14695<a class="summary-letter" href="#Builtin-Index_bt_letter-A"><b>A</b></a>
17345e5a 14696 &nbsp;
a0c0a00f 14697<a class="summary-letter" href="#Builtin-Index_bt_letter-B"><b>B</b></a>
17345e5a 14698 &nbsp;
a0c0a00f 14699<a class="summary-letter" href="#Builtin-Index_bt_letter-C"><b>C</b></a>
17345e5a 14700 &nbsp;
a0c0a00f 14701<a class="summary-letter" href="#Builtin-Index_bt_letter-D"><b>D</b></a>
17345e5a 14702 &nbsp;
a0c0a00f 14703<a class="summary-letter" href="#Builtin-Index_bt_letter-E"><b>E</b></a>
17345e5a 14704 &nbsp;
a0c0a00f 14705<a class="summary-letter" href="#Builtin-Index_bt_letter-F"><b>F</b></a>
17345e5a 14706 &nbsp;
a0c0a00f 14707<a class="summary-letter" href="#Builtin-Index_bt_letter-G"><b>G</b></a>
17345e5a 14708 &nbsp;
a0c0a00f 14709<a class="summary-letter" href="#Builtin-Index_bt_letter-H"><b>H</b></a>
17345e5a 14710 &nbsp;
a0c0a00f 14711<a class="summary-letter" href="#Builtin-Index_bt_letter-J"><b>J</b></a>
17345e5a 14712 &nbsp;
a0c0a00f 14713<a class="summary-letter" href="#Builtin-Index_bt_letter-K"><b>K</b></a>
17345e5a 14714 &nbsp;
a0c0a00f 14715<a class="summary-letter" href="#Builtin-Index_bt_letter-L"><b>L</b></a>
17345e5a 14716 &nbsp;
a0c0a00f 14717<a class="summary-letter" href="#Builtin-Index_bt_letter-M"><b>M</b></a>
17345e5a 14718 &nbsp;
a0c0a00f 14719<a class="summary-letter" href="#Builtin-Index_bt_letter-P"><b>P</b></a>
17345e5a 14720 &nbsp;
a0c0a00f 14721<a class="summary-letter" href="#Builtin-Index_bt_letter-R"><b>R</b></a>
17345e5a 14722 &nbsp;
a0c0a00f 14723<a class="summary-letter" href="#Builtin-Index_bt_letter-S"><b>S</b></a>
17345e5a 14724 &nbsp;
a0c0a00f 14725<a class="summary-letter" href="#Builtin-Index_bt_letter-T"><b>T</b></a>
17345e5a 14726 &nbsp;
a0c0a00f 14727<a class="summary-letter" href="#Builtin-Index_bt_letter-U"><b>U</b></a>
17345e5a 14728 &nbsp;
a0c0a00f 14729<a class="summary-letter" href="#Builtin-Index_bt_letter-W"><b>W</b></a>
17345e5a 14730 &nbsp;
a0c0a00f
CR
14731</td></tr></table>
14732
14733<hr>
14734<a name="Reserved-Word-Index"></a>
14735<div class="header">
14736<p>
14737Next: <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>
14738</div>
14739<a name="Index-of-Shell-Reserved-Words"></a>
14740<h3 class="appendixsec">D.2 Index of Shell Reserved Words</h3>
14741<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-1"><b>!</b></a>
17345e5a 14742 &nbsp;
a0c0a00f 14743<a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-2"><b>[</b></a>
17345e5a 14744 &nbsp;
a0c0a00f 14745<a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-3"><b>]</b></a>
17345e5a 14746 &nbsp;
a0c0a00f 14747<a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-4"><b>{</b></a>
17345e5a 14748 &nbsp;
a0c0a00f 14749<a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-5"><b>}</b></a>
17345e5a 14750 &nbsp;
a0c0a00f
CR
14751<br>
14752<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-C"><b>C</b></a>
14753 &nbsp;
14754<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-D"><b>D</b></a>
14755 &nbsp;
14756<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-E"><b>E</b></a>
14757 &nbsp;
14758<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-F"><b>F</b></a>
14759 &nbsp;
14760<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-I"><b>I</b></a>
14761 &nbsp;
14762<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-S"><b>S</b></a>
14763 &nbsp;
14764<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-T"><b>T</b></a>
14765 &nbsp;
14766<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-U"><b>U</b></a>
14767 &nbsp;
14768<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-W"><b>W</b></a>
14769 &nbsp;
14770</td></tr></table>
14771<table class="index-rw" border="0">
14772<tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
14773<tr><td colspan="4"> <hr></td></tr>
14774<tr><th><a name="Reserved-Word-Index_rw_symbol-1">!</a></th><td></td><td></td></tr>
14775<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>
14776<tr><td colspan="4"> <hr></td></tr>
14777<tr><th><a name="Reserved-Word-Index_rw_symbol-2">[</a></th><td></td><td></td></tr>
14778<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>
14779<tr><td colspan="4"> <hr></td></tr>
14780<tr><th><a name="Reserved-Word-Index_rw_symbol-3">]</a></th><td></td><td></td></tr>
14781<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>
14782<tr><td colspan="4"> <hr></td></tr>
14783<tr><th><a name="Reserved-Word-Index_rw_symbol-4">{</a></th><td></td><td></td></tr>
14784<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>
14785<tr><td colspan="4"> <hr></td></tr>
14786<tr><th><a name="Reserved-Word-Index_rw_symbol-5">}</a></th><td></td><td></td></tr>
14787<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>
14788<tr><td colspan="4"> <hr></td></tr>
14789<tr><th><a name="Reserved-Word-Index_rw_letter-C">C</a></th><td></td><td></td></tr>
14790<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>
14791<tr><td colspan="4"> <hr></td></tr>
14792<tr><th><a name="Reserved-Word-Index_rw_letter-D">D</a></th><td></td><td></td></tr>
14793<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>
14794<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>
14795<tr><td colspan="4"> <hr></td></tr>
14796<tr><th><a name="Reserved-Word-Index_rw_letter-E">E</a></th><td></td><td></td></tr>
14797<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>
14798<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>
14799<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>
14800<tr><td colspan="4"> <hr></td></tr>
14801<tr><th><a name="Reserved-Word-Index_rw_letter-F">F</a></th><td></td><td></td></tr>
14802<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>
14803<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>
14804<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>
14805<tr><td colspan="4"> <hr></td></tr>
14806<tr><th><a name="Reserved-Word-Index_rw_letter-I">I</a></th><td></td><td></td></tr>
14807<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>
14808<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>
14809<tr><td colspan="4"> <hr></td></tr>
14810<tr><th><a name="Reserved-Word-Index_rw_letter-S">S</a></th><td></td><td></td></tr>
14811<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>
14812<tr><td colspan="4"> <hr></td></tr>
14813<tr><th><a name="Reserved-Word-Index_rw_letter-T">T</a></th><td></td><td></td></tr>
14814<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>
14815<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>
14816<tr><td colspan="4"> <hr></td></tr>
14817<tr><th><a name="Reserved-Word-Index_rw_letter-U">U</a></th><td></td><td></td></tr>
14818<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>
14819<tr><td colspan="4"> <hr></td></tr>
14820<tr><th><a name="Reserved-Word-Index_rw_letter-W">W</a></th><td></td><td></td></tr>
14821<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>
14822<tr><td colspan="4"> <hr></td></tr>
14823</table>
14824<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-1"><b>!</b></a>
14825 &nbsp;
14826<a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-2"><b>[</b></a>
14827 &nbsp;
14828<a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-3"><b>]</b></a>
14829 &nbsp;
14830<a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-4"><b>{</b></a>
14831 &nbsp;
14832<a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-5"><b>}</b></a>
17345e5a 14833 &nbsp;
a0c0a00f
CR
14834<br>
14835<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-C"><b>C</b></a>
17345e5a 14836 &nbsp;
a0c0a00f 14837<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-D"><b>D</b></a>
17345e5a 14838 &nbsp;
a0c0a00f 14839<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-E"><b>E</b></a>
17345e5a 14840 &nbsp;
a0c0a00f 14841<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-F"><b>F</b></a>
17345e5a 14842 &nbsp;
a0c0a00f 14843<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-I"><b>I</b></a>
17345e5a 14844 &nbsp;
a0c0a00f 14845<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-S"><b>S</b></a>
17345e5a 14846 &nbsp;
a0c0a00f 14847<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-T"><b>T</b></a>
17345e5a 14848 &nbsp;
a0c0a00f 14849<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-U"><b>U</b></a>
17345e5a 14850 &nbsp;
a0c0a00f 14851<a class="summary-letter" href="#Reserved-Word-Index_rw_letter-W"><b>W</b></a>
17345e5a 14852 &nbsp;
a0c0a00f
CR
14853</td></tr></table>
14854
14855<hr>
14856<a name="Variable-Index"></a>
14857<div class="header">
14858<p>
14859Next: <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>
14860</div>
14861<a name="Parameter-and-Variable-Index"></a>
14862<h3 class="appendixsec">D.3 Parameter and Variable Index</h3>
14863<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Variable-Index_vr_symbol-1"><b>!</b></a>
17345e5a 14864 &nbsp;
a0c0a00f 14865<a class="summary-letter" href="#Variable-Index_vr_symbol-2"><b>#</b></a>
17345e5a 14866 &nbsp;
a0c0a00f 14867<a class="summary-letter" href="#Variable-Index_vr_symbol-3"><b>$</b></a>
17345e5a 14868 &nbsp;
a0c0a00f 14869<a class="summary-letter" href="#Variable-Index_vr_symbol-4"><b>*</b></a>
17345e5a 14870 &nbsp;
a0c0a00f 14871<a class="summary-letter" href="#Variable-Index_vr_symbol-5"><b>-</b></a>
17345e5a 14872 &nbsp;
a0c0a00f 14873<a class="summary-letter" href="#Variable-Index_vr_symbol-6"><b>0</b></a>
17345e5a 14874 &nbsp;
a0c0a00f 14875<a class="summary-letter" href="#Variable-Index_vr_symbol-7"><b>?</b></a>
17345e5a 14876 &nbsp;
a0c0a00f 14877<a class="summary-letter" href="#Variable-Index_vr_symbol-8"><b>@</b></a>
17345e5a 14878 &nbsp;
a0c0a00f 14879<a class="summary-letter" href="#Variable-Index_vr_symbol-9"><b>_</b></a>
17345e5a 14880 &nbsp;
a0c0a00f
CR
14881<br>
14882<a class="summary-letter" href="#Variable-Index_vr_letter-A"><b>A</b></a>
14883 &nbsp;
14884<a class="summary-letter" href="#Variable-Index_vr_letter-B"><b>B</b></a>
14885 &nbsp;
14886<a class="summary-letter" href="#Variable-Index_vr_letter-C"><b>C</b></a>
14887 &nbsp;
14888<a class="summary-letter" href="#Variable-Index_vr_letter-D"><b>D</b></a>
14889 &nbsp;
14890<a class="summary-letter" href="#Variable-Index_vr_letter-E"><b>E</b></a>
14891 &nbsp;
14892<a class="summary-letter" href="#Variable-Index_vr_letter-F"><b>F</b></a>
14893 &nbsp;
14894<a class="summary-letter" href="#Variable-Index_vr_letter-G"><b>G</b></a>
14895 &nbsp;
14896<a class="summary-letter" href="#Variable-Index_vr_letter-H"><b>H</b></a>
14897 &nbsp;
14898<a class="summary-letter" href="#Variable-Index_vr_letter-I"><b>I</b></a>
14899 &nbsp;
14900<a class="summary-letter" href="#Variable-Index_vr_letter-K"><b>K</b></a>
14901 &nbsp;
14902<a class="summary-letter" href="#Variable-Index_vr_letter-L"><b>L</b></a>
14903 &nbsp;
14904<a class="summary-letter" href="#Variable-Index_vr_letter-M"><b>M</b></a>
14905 &nbsp;
14906<a class="summary-letter" href="#Variable-Index_vr_letter-O"><b>O</b></a>
14907 &nbsp;
14908<a class="summary-letter" href="#Variable-Index_vr_letter-P"><b>P</b></a>
14909 &nbsp;
14910<a class="summary-letter" href="#Variable-Index_vr_letter-R"><b>R</b></a>
14911 &nbsp;
14912<a class="summary-letter" href="#Variable-Index_vr_letter-S"><b>S</b></a>
14913 &nbsp;
14914<a class="summary-letter" href="#Variable-Index_vr_letter-T"><b>T</b></a>
14915 &nbsp;
14916<a class="summary-letter" href="#Variable-Index_vr_letter-U"><b>U</b></a>
14917 &nbsp;
14918<a class="summary-letter" href="#Variable-Index_vr_letter-V"><b>V</b></a>
14919 &nbsp;
14920</td></tr></table>
14921<table class="index-vr" border="0">
14922<tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
14923<tr><td colspan="4"> <hr></td></tr>
14924<tr><th><a name="Variable-Index_vr_symbol-1">!</a></th><td></td><td></td></tr>
14925<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>
14926<tr><td colspan="4"> <hr></td></tr>
14927<tr><th><a name="Variable-Index_vr_symbol-2">#</a></th><td></td><td></td></tr>
14928<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>
14929<tr><td colspan="4"> <hr></td></tr>
14930<tr><th><a name="Variable-Index_vr_symbol-3">$</a></th><td></td><td></td></tr>
14931<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>
14932<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>
14933<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>
14934<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>
14935<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>
14936<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>
14937<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>
14938<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>
14939<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>
14940<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>
14941<tr><td colspan="4"> <hr></td></tr>
14942<tr><th><a name="Variable-Index_vr_symbol-4">*</a></th><td></td><td></td></tr>
14943<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>
14944<tr><td colspan="4"> <hr></td></tr>
14945<tr><th><a name="Variable-Index_vr_symbol-5">-</a></th><td></td><td></td></tr>
14946<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>
14947<tr><td colspan="4"> <hr></td></tr>
14948<tr><th><a name="Variable-Index_vr_symbol-6">0</a></th><td></td><td></td></tr>
14949<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>
14950<tr><td colspan="4"> <hr></td></tr>
14951<tr><th><a name="Variable-Index_vr_symbol-7">?</a></th><td></td><td></td></tr>
14952<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>
14953<tr><td colspan="4"> <hr></td></tr>
14954<tr><th><a name="Variable-Index_vr_symbol-8">@</a></th><td></td><td></td></tr>
14955<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>
14956<tr><td colspan="4"> <hr></td></tr>
14957<tr><th><a name="Variable-Index_vr_symbol-9">_</a></th><td></td><td></td></tr>
14958<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>
14959<tr><td colspan="4"> <hr></td></tr>
14960<tr><th><a name="Variable-Index_vr_letter-A">A</a></th><td></td><td></td></tr>
14961<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>
14962<tr><td colspan="4"> <hr></td></tr>
14963<tr><th><a name="Variable-Index_vr_letter-B">B</a></th><td></td><td></td></tr>
14964<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>
14965<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>
14966<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>
14967<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>
14968<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>
14969<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>
9a51695b 14970<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>
a0c0a00f
CR
14971<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>
14972<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>
14973<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>
14974<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>
14975<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>
14976<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>
14977<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>
14978<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>
14979<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>
14980<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>
14981<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>
14982<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>
14983<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>
14984<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>
14985<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>
14986<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>
14987<tr><td colspan="4"> <hr></td></tr>
14988<tr><th><a name="Variable-Index_vr_letter-C">C</a></th><td></td><td></td></tr>
14989<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>
14990<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>
14991<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>
14992<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>
14993<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>
14994<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>
14995<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>
14996<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>
14997<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>
14998<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>
14999<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>
15000<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>
15001<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>
15002<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>
15003<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>
15004<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>
15005<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>
15006<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>
15007<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>
15008<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>
15009<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>
15010<tr><td colspan="4"> <hr></td></tr>
15011<tr><th><a name="Variable-Index_vr_letter-D">D</a></th><td></td><td></td></tr>
15012<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>
15013<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>
15014<tr><td colspan="4"> <hr></td></tr>
15015<tr><th><a name="Variable-Index_vr_letter-E">E</a></th><td></td><td></td></tr>
15016<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>
15017<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>
15018<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>
15019<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>
15020<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>
15021<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>
15022<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>
9a51695b
CR
15023<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>
15024<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>
a0c0a00f
CR
15025<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>
15026<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>
15027<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>
15028<tr><td colspan="4"> <hr></td></tr>
15029<tr><th><a name="Variable-Index_vr_letter-F">F</a></th><td></td><td></td></tr>
15030<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>
15031<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>
15032<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>
15033<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>
15034<tr><td colspan="4"> <hr></td></tr>
15035<tr><th><a name="Variable-Index_vr_letter-G">G</a></th><td></td><td></td></tr>
15036<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>
15037<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>
15038<tr><td colspan="4"> <hr></td></tr>
15039<tr><th><a name="Variable-Index_vr_letter-H">H</a></th><td></td><td></td></tr>
15040<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>
15041<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>
15042<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>
15043<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>
15044<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>
15045<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>
15046<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>
15047<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>
15048<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>
15049<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>
15050<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>
15051<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>
15052<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>
15053<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>
15054<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>
15055<tr><td colspan="4"> <hr></td></tr>
15056<tr><th><a name="Variable-Index_vr_letter-I">I</a></th><td></td><td></td></tr>
15057<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>
15058<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>
15059<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>
15060<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>
2f5dfe5a 15061<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>
a0c0a00f
CR
15062<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>
15063<tr><td colspan="4"> <hr></td></tr>
15064<tr><th><a name="Variable-Index_vr_letter-K">K</a></th><td></td><td></td></tr>
15065<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>
15066<tr><td colspan="4"> <hr></td></tr>
15067<tr><th><a name="Variable-Index_vr_letter-L">L</a></th><td></td><td></td></tr>
15068<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>
15069<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>
15070<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>
15071<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>
15072<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>
15073<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>
15074<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>
15075<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>
15076<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>
15077<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>
15078<tr><td colspan="4"> <hr></td></tr>
15079<tr><th><a name="Variable-Index_vr_letter-M">M</a></th><td></td><td></td></tr>
15080<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>
15081<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>
15082<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>
15083<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>
15084<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>
15085<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>
15086<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>
15087<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>
15088<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>
15089<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>
15090<tr><td colspan="4"> <hr></td></tr>
15091<tr><th><a name="Variable-Index_vr_letter-O">O</a></th><td></td><td></td></tr>
15092<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>
15093<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>
15094<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>
15095<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>
15096<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>
15097<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>
15098<tr><td colspan="4"> <hr></td></tr>
15099<tr><th><a name="Variable-Index_vr_letter-P">P</a></th><td></td><td></td></tr>
15100<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>
15101<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>
15102<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>
15103<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>
15104<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>
15105<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>
15106<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>
15107<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>
15108<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>
15109<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>
15110<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>
15111<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>
15112<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>
15113<tr><td colspan="4"> <hr></td></tr>
15114<tr><th><a name="Variable-Index_vr_letter-R">R</a></th><td></td><td></td></tr>
15115<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>
15116<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>
15117<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>
15118<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>
15119<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>
15120<tr><td colspan="4"> <hr></td></tr>
15121<tr><th><a name="Variable-Index_vr_letter-S">S</a></th><td></td><td></td></tr>
15122<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>
15123<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>
15124<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>
15125<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>
15126<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>
15127<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>
15128<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>
15129<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>
15130<tr><td colspan="4"> <hr></td></tr>
15131<tr><th><a name="Variable-Index_vr_letter-T">T</a></th><td></td><td></td></tr>
15132<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>
15133<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>
15134<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>
15135<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>
15136<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>
15137<tr><td colspan="4"> <hr></td></tr>
15138<tr><th><a name="Variable-Index_vr_letter-U">U</a></th><td></td><td></td></tr>
15139<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>
15140<tr><td colspan="4"> <hr></td></tr>
15141<tr><th><a name="Variable-Index_vr_letter-V">V</a></th><td></td><td></td></tr>
15142<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>
15143<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>
15144<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>
15145<tr><td colspan="4"> <hr></td></tr>
15146</table>
15147<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Variable-Index_vr_symbol-1"><b>!</b></a>
15148 &nbsp;
15149<a class="summary-letter" href="#Variable-Index_vr_symbol-2"><b>#</b></a>
15150 &nbsp;
15151<a class="summary-letter" href="#Variable-Index_vr_symbol-3"><b>$</b></a>
15152 &nbsp;
15153<a class="summary-letter" href="#Variable-Index_vr_symbol-4"><b>*</b></a>
15154 &nbsp;
15155<a class="summary-letter" href="#Variable-Index_vr_symbol-5"><b>-</b></a>
15156 &nbsp;
15157<a class="summary-letter" href="#Variable-Index_vr_symbol-6"><b>0</b></a>
15158 &nbsp;
15159<a class="summary-letter" href="#Variable-Index_vr_symbol-7"><b>?</b></a>
15160 &nbsp;
15161<a class="summary-letter" href="#Variable-Index_vr_symbol-8"><b>@</b></a>
15162 &nbsp;
15163<a class="summary-letter" href="#Variable-Index_vr_symbol-9"><b>_</b></a>
17345e5a 15164 &nbsp;
a0c0a00f
CR
15165<br>
15166<a class="summary-letter" href="#Variable-Index_vr_letter-A"><b>A</b></a>
17345e5a 15167 &nbsp;
a0c0a00f 15168<a class="summary-letter" href="#Variable-Index_vr_letter-B"><b>B</b></a>
17345e5a 15169 &nbsp;
a0c0a00f 15170<a class="summary-letter" href="#Variable-Index_vr_letter-C"><b>C</b></a>
17345e5a 15171 &nbsp;
a0c0a00f 15172<a class="summary-letter" href="#Variable-Index_vr_letter-D"><b>D</b></a>
17345e5a 15173 &nbsp;
a0c0a00f 15174<a class="summary-letter" href="#Variable-Index_vr_letter-E"><b>E</b></a>
17345e5a 15175 &nbsp;
a0c0a00f 15176<a class="summary-letter" href="#Variable-Index_vr_letter-F"><b>F</b></a>
17345e5a 15177 &nbsp;
a0c0a00f 15178<a class="summary-letter" href="#Variable-Index_vr_letter-G"><b>G</b></a>
17345e5a 15179 &nbsp;
a0c0a00f 15180<a class="summary-letter" href="#Variable-Index_vr_letter-H"><b>H</b></a>
17345e5a 15181 &nbsp;
a0c0a00f 15182<a class="summary-letter" href="#Variable-Index_vr_letter-I"><b>I</b></a>
17345e5a 15183 &nbsp;
a0c0a00f 15184<a class="summary-letter" href="#Variable-Index_vr_letter-K"><b>K</b></a>
17345e5a 15185 &nbsp;
a0c0a00f 15186<a class="summary-letter" href="#Variable-Index_vr_letter-L"><b>L</b></a>
17345e5a 15187 &nbsp;
a0c0a00f 15188<a class="summary-letter" href="#Variable-Index_vr_letter-M"><b>M</b></a>
17345e5a 15189 &nbsp;
a0c0a00f 15190<a class="summary-letter" href="#Variable-Index_vr_letter-O"><b>O</b></a>
17345e5a 15191 &nbsp;
a0c0a00f 15192<a class="summary-letter" href="#Variable-Index_vr_letter-P"><b>P</b></a>
17345e5a 15193 &nbsp;
a0c0a00f 15194<a class="summary-letter" href="#Variable-Index_vr_letter-R"><b>R</b></a>
17345e5a 15195 &nbsp;
a0c0a00f 15196<a class="summary-letter" href="#Variable-Index_vr_letter-S"><b>S</b></a>
17345e5a 15197 &nbsp;
a0c0a00f 15198<a class="summary-letter" href="#Variable-Index_vr_letter-T"><b>T</b></a>
17345e5a 15199 &nbsp;
a0c0a00f 15200<a class="summary-letter" href="#Variable-Index_vr_letter-U"><b>U</b></a>
17345e5a 15201 &nbsp;
a0c0a00f 15202<a class="summary-letter" href="#Variable-Index_vr_letter-V"><b>V</b></a>
17345e5a 15203 &nbsp;
a0c0a00f
CR
15204</td></tr></table>
15205
15206<hr>
15207<a name="Function-Index"></a>
15208<div class="header">
15209<p>
15210Next: <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>
15211</div>
15212<a name="Function-Index-1"></a>
15213<h3 class="appendixsec">D.4 Function Index</h3>
15214<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Function-Index_fn_letter-A"><b>A</b></a>
17345e5a 15215 &nbsp;
a0c0a00f 15216<a class="summary-letter" href="#Function-Index_fn_letter-B"><b>B</b></a>
17345e5a 15217 &nbsp;
a0c0a00f 15218<a class="summary-letter" href="#Function-Index_fn_letter-C"><b>C</b></a>
17345e5a 15219 &nbsp;
a0c0a00f 15220<a class="summary-letter" href="#Function-Index_fn_letter-D"><b>D</b></a>
17345e5a 15221 &nbsp;
a0c0a00f 15222<a class="summary-letter" href="#Function-Index_fn_letter-E"><b>E</b></a>
17345e5a 15223 &nbsp;
a0c0a00f 15224<a class="summary-letter" href="#Function-Index_fn_letter-F"><b>F</b></a>
17345e5a 15225 &nbsp;
a0c0a00f 15226<a class="summary-letter" href="#Function-Index_fn_letter-G"><b>G</b></a>
17345e5a 15227 &nbsp;
a0c0a00f
CR
15228<a class="summary-letter" href="#Function-Index_fn_letter-H"><b>H</b></a>
15229 &nbsp;
15230<a class="summary-letter" href="#Function-Index_fn_letter-I"><b>I</b></a>
15231 &nbsp;
15232<a class="summary-letter" href="#Function-Index_fn_letter-K"><b>K</b></a>
15233 &nbsp;
15234<a class="summary-letter" href="#Function-Index_fn_letter-M"><b>M</b></a>
15235 &nbsp;
15236<a class="summary-letter" href="#Function-Index_fn_letter-N"><b>N</b></a>
15237 &nbsp;
15238<a class="summary-letter" href="#Function-Index_fn_letter-O"><b>O</b></a>
15239 &nbsp;
15240<a class="summary-letter" href="#Function-Index_fn_letter-P"><b>P</b></a>
15241 &nbsp;
15242<a class="summary-letter" href="#Function-Index_fn_letter-Q"><b>Q</b></a>
15243 &nbsp;
15244<a class="summary-letter" href="#Function-Index_fn_letter-R"><b>R</b></a>
15245 &nbsp;
15246<a class="summary-letter" href="#Function-Index_fn_letter-S"><b>S</b></a>
15247 &nbsp;
15248<a class="summary-letter" href="#Function-Index_fn_letter-T"><b>T</b></a>
15249 &nbsp;
15250<a class="summary-letter" href="#Function-Index_fn_letter-U"><b>U</b></a>
15251 &nbsp;
15252<a class="summary-letter" href="#Function-Index_fn_letter-Y"><b>Y</b></a>
15253 &nbsp;
15254</td></tr></table>
15255<table class="index-fn" border="0">
15256<tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
15257<tr><td colspan="4"> <hr></td></tr>
15258<tr><th><a name="Function-Index_fn_letter-A">A</a></th><td></td><td></td></tr>
15259<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>
15260<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>
15261<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>
15262<tr><td colspan="4"> <hr></td></tr>
15263<tr><th><a name="Function-Index_fn_letter-B">B</a></th><td></td><td></td></tr>
15264<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>
15265<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>
15266<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>
15267<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>
15268<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>
15269<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>
15270<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>
15271<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>
15272<tr><td colspan="4"> <hr></td></tr>
15273<tr><th><a name="Function-Index_fn_letter-C">C</a></th><td></td><td></td></tr>
15274<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>
15275<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>
15276<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>
15277<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>
15278<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>
15279<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>
15280<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>
15281<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>
15282<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>
15283<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>
15284<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>
15285<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>
15286<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>
15287<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>
15288<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>
15289<tr><td colspan="4"> <hr></td></tr>
15290<tr><th><a name="Function-Index_fn_letter-D">D</a></th><td></td><td></td></tr>
15291<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>
15292<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>
15293<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>
15294<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>
15295<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>
15296<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>
9a51695b 15297<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>
a0c0a00f
CR
15298<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>
15299<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>
15300<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>
15301<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>
15302<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>
15303<tr><td colspan="4"> <hr></td></tr>
15304<tr><th><a name="Function-Index_fn_letter-E">E</a></th><td></td><td></td></tr>
9a51695b 15305<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>
a0c0a00f
CR
15306<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>
15307<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>
15308<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>
15309<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>
15310<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>
15311<tr><td colspan="4"> <hr></td></tr>
15312<tr><th><a name="Function-Index_fn_letter-F">F</a></th><td></td><td></td></tr>
15313<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>
15314<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>
15315<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>
15316<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>
15317<tr><td colspan="4"> <hr></td></tr>
15318<tr><th><a name="Function-Index_fn_letter-G">G</a></th><td></td><td></td></tr>
15319<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>
15320<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>
15321<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>
15322<tr><td colspan="4"> <hr></td></tr>
15323<tr><th><a name="Function-Index_fn_letter-H">H</a></th><td></td><td></td></tr>
15324<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>
15325<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>
15326<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>
15327<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>
9a51695b
CR
15328<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>
15329<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>
a0c0a00f
CR
15330<tr><td colspan="4"> <hr></td></tr>
15331<tr><th><a name="Function-Index_fn_letter-I">I</a></th><td></td><td></td></tr>
15332<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>
15333<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>
15334<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>
15335<tr><td colspan="4"> <hr></td></tr>
15336<tr><th><a name="Function-Index_fn_letter-K">K</a></th><td></td><td></td></tr>
15337<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>
15338<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>
15339<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>
15340<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>
15341<tr><td colspan="4"> <hr></td></tr>
15342<tr><th><a name="Function-Index_fn_letter-M">M</a></th><td></td><td></td></tr>
15343<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>
15344<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>
15345<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>
15346<tr><td colspan="4"> <hr></td></tr>
15347<tr><th><a name="Function-Index_fn_letter-N">N</a></th><td></td><td></td></tr>
15348<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>
9a51695b 15349<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>
a0c0a00f
CR
15350<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>
15351<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>
15352<tr><td colspan="4"> <hr></td></tr>
15353<tr><th><a name="Function-Index_fn_letter-O">O</a></th><td></td><td></td></tr>
15354<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>
15355<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>
15356<tr><td colspan="4"> <hr></td></tr>
15357<tr><th><a name="Function-Index_fn_letter-P">P</a></th><td></td><td></td></tr>
15358<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>
15359<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>
15360<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>
15361<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>
15362<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>
15363<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>
15364<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>
15365<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>
9a51695b 15366<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>
a0c0a00f
CR
15367<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>
15368<tr><td colspan="4"> <hr></td></tr>
15369<tr><th><a name="Function-Index_fn_letter-Q">Q</a></th><td></td><td></td></tr>
15370<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>
15371<tr><td colspan="4"> <hr></td></tr>
15372<tr><th><a name="Function-Index_fn_letter-R">R</a></th><td></td><td></td></tr>
15373<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>
15374<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>
15375<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>
15376<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>
15377<tr><td colspan="4"> <hr></td></tr>
15378<tr><th><a name="Function-Index_fn_letter-S">S</a></th><td></td><td></td></tr>
15379<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>
15380<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>
15381<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>
15382<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>
15383<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>
15384<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>
15385<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>
15386<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>
15387<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>
15388<tr><td colspan="4"> <hr></td></tr>
15389<tr><th><a name="Function-Index_fn_letter-T">T</a></th><td></td><td></td></tr>
15390<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>
15391<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>
15392<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>
15393<tr><td colspan="4"> <hr></td></tr>
15394<tr><th><a name="Function-Index_fn_letter-U">U</a></th><td></td><td></td></tr>
15395<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>
15396<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>
15397<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>
15398<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>
15399<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>
15400<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>
15401<tr><td colspan="4"> <hr></td></tr>
15402<tr><th><a name="Function-Index_fn_letter-Y">Y</a></th><td></td><td></td></tr>
15403<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>
15404<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>
15405<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>
15406<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>
15407<tr><td colspan="4"> <hr></td></tr>
15408</table>
15409<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Function-Index_fn_letter-A"><b>A</b></a>
15410 &nbsp;
15411<a class="summary-letter" href="#Function-Index_fn_letter-B"><b>B</b></a>
15412 &nbsp;
15413<a class="summary-letter" href="#Function-Index_fn_letter-C"><b>C</b></a>
15414 &nbsp;
15415<a class="summary-letter" href="#Function-Index_fn_letter-D"><b>D</b></a>
15416 &nbsp;
15417<a class="summary-letter" href="#Function-Index_fn_letter-E"><b>E</b></a>
15418 &nbsp;
15419<a class="summary-letter" href="#Function-Index_fn_letter-F"><b>F</b></a>
15420 &nbsp;
15421<a class="summary-letter" href="#Function-Index_fn_letter-G"><b>G</b></a>
15422 &nbsp;
15423<a class="summary-letter" href="#Function-Index_fn_letter-H"><b>H</b></a>
15424 &nbsp;
15425<a class="summary-letter" href="#Function-Index_fn_letter-I"><b>I</b></a>
15426 &nbsp;
15427<a class="summary-letter" href="#Function-Index_fn_letter-K"><b>K</b></a>
15428 &nbsp;
15429<a class="summary-letter" href="#Function-Index_fn_letter-M"><b>M</b></a>
15430 &nbsp;
15431<a class="summary-letter" href="#Function-Index_fn_letter-N"><b>N</b></a>
15432 &nbsp;
15433<a class="summary-letter" href="#Function-Index_fn_letter-O"><b>O</b></a>
15434 &nbsp;
15435<a class="summary-letter" href="#Function-Index_fn_letter-P"><b>P</b></a>
15436 &nbsp;
15437<a class="summary-letter" href="#Function-Index_fn_letter-Q"><b>Q</b></a>
15438 &nbsp;
15439<a class="summary-letter" href="#Function-Index_fn_letter-R"><b>R</b></a>
15440 &nbsp;
15441<a class="summary-letter" href="#Function-Index_fn_letter-S"><b>S</b></a>
15442 &nbsp;
15443<a class="summary-letter" href="#Function-Index_fn_letter-T"><b>T</b></a>
15444 &nbsp;
15445<a class="summary-letter" href="#Function-Index_fn_letter-U"><b>U</b></a>
15446 &nbsp;
15447<a class="summary-letter" href="#Function-Index_fn_letter-Y"><b>Y</b></a>
15448 &nbsp;
15449</td></tr></table>
15450
15451<hr>
15452<a name="Concept-Index"></a>
15453<div class="header">
15454<p>
15455Previous: <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>
15456</div>
15457<a name="Concept-Index-1"></a>
15458<h3 class="appendixsec">D.5 Concept Index</h3>
15459<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Concept-Index_cp_letter-A"><b>A</b></a>
15460 &nbsp;
15461<a class="summary-letter" href="#Concept-Index_cp_letter-B"><b>B</b></a>
15462 &nbsp;
15463<a class="summary-letter" href="#Concept-Index_cp_letter-C"><b>C</b></a>
15464 &nbsp;
15465<a class="summary-letter" href="#Concept-Index_cp_letter-D"><b>D</b></a>
15466 &nbsp;
15467<a class="summary-letter" href="#Concept-Index_cp_letter-E"><b>E</b></a>
15468 &nbsp;
15469<a class="summary-letter" href="#Concept-Index_cp_letter-F"><b>F</b></a>
15470 &nbsp;
15471<a class="summary-letter" href="#Concept-Index_cp_letter-H"><b>H</b></a>
15472 &nbsp;
15473<a class="summary-letter" href="#Concept-Index_cp_letter-I"><b>I</b></a>
15474 &nbsp;
15475<a class="summary-letter" href="#Concept-Index_cp_letter-J"><b>J</b></a>
15476 &nbsp;
15477<a class="summary-letter" href="#Concept-Index_cp_letter-K"><b>K</b></a>
15478 &nbsp;
15479<a class="summary-letter" href="#Concept-Index_cp_letter-L"><b>L</b></a>
15480 &nbsp;
15481<a class="summary-letter" href="#Concept-Index_cp_letter-M"><b>M</b></a>
15482 &nbsp;
15483<a class="summary-letter" href="#Concept-Index_cp_letter-N"><b>N</b></a>
15484 &nbsp;
15485<a class="summary-letter" href="#Concept-Index_cp_letter-O"><b>O</b></a>
15486 &nbsp;
15487<a class="summary-letter" href="#Concept-Index_cp_letter-P"><b>P</b></a>
15488 &nbsp;
15489<a class="summary-letter" href="#Concept-Index_cp_letter-Q"><b>Q</b></a>
15490 &nbsp;
15491<a class="summary-letter" href="#Concept-Index_cp_letter-R"><b>R</b></a>
15492 &nbsp;
15493<a class="summary-letter" href="#Concept-Index_cp_letter-S"><b>S</b></a>
15494 &nbsp;
15495<a class="summary-letter" href="#Concept-Index_cp_letter-T"><b>T</b></a>
15496 &nbsp;
15497<a class="summary-letter" href="#Concept-Index_cp_letter-V"><b>V</b></a>
15498 &nbsp;
15499<a class="summary-letter" href="#Concept-Index_cp_letter-W"><b>W</b></a>
15500 &nbsp;
15501<a class="summary-letter" href="#Concept-Index_cp_letter-Y"><b>Y</b></a>
15502 &nbsp;
15503</td></tr></table>
15504<table class="index-cp" border="0">
15505<tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
15506<tr><td colspan="4"> <hr></td></tr>
15507<tr><th><a name="Concept-Index_cp_letter-A">A</a></th><td></td><td></td></tr>
15508<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>
15509<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>
15510<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>
15511<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>
15512<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>
15513<tr><td colspan="4"> <hr></td></tr>
15514<tr><th><a name="Concept-Index_cp_letter-B">B</a></th><td></td><td></td></tr>
15515<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>
15516<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>
15517<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>
15518<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>
15519<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>
15520<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>
15521<tr><td colspan="4"> <hr></td></tr>
15522<tr><th><a name="Concept-Index_cp_letter-C">C</a></th><td></td><td></td></tr>
15523<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>
15524<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>
15525<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>
15526<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>
15527<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>
15528<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>
15529<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>
15530<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>
15531<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>
15532<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>
15533<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>
15534<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>
15535<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>
15536<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>
15537<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>
15538<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>
15539<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>
15540<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>
15541<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>
15542<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>
15543<tr><td colspan="4"> <hr></td></tr>
15544<tr><th><a name="Concept-Index_cp_letter-D">D</a></th><td></td><td></td></tr>
15545<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>
15546<tr><td colspan="4"> <hr></td></tr>
15547<tr><th><a name="Concept-Index_cp_letter-E">E</a></th><td></td><td></td></tr>
15548<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>
15549<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>
15550<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>
15551<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>
15552<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>
15553<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>
15554<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>
15555<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>
15556<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>
15557<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>
15558<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>
15559<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>
15560<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>
15561<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>
15562<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>
15563<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>
15564<tr><td colspan="4"> <hr></td></tr>
15565<tr><th><a name="Concept-Index_cp_letter-F">F</a></th><td></td><td></td></tr>
15566<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>
15567<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>
15568<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>
15569<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>
15570<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>
15571<tr><td colspan="4"> <hr></td></tr>
15572<tr><th><a name="Concept-Index_cp_letter-H">H</a></th><td></td><td></td></tr>
15573<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>
15574<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>
15575<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>
15576<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>
15577<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>
15578<tr><td colspan="4"> <hr></td></tr>
15579<tr><th><a name="Concept-Index_cp_letter-I">I</a></th><td></td><td></td></tr>
15580<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>
15581<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>
15582<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>
15583<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>
15584<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>
15585<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>
15586<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>
15587<tr><td colspan="4"> <hr></td></tr>
15588<tr><th><a name="Concept-Index_cp_letter-J">J</a></th><td></td><td></td></tr>
15589<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>
15590<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>
15591<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>
15592<tr><td colspan="4"> <hr></td></tr>
15593<tr><th><a name="Concept-Index_cp_letter-K">K</a></th><td></td><td></td></tr>
15594<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>
15595<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>
15596<tr><td colspan="4"> <hr></td></tr>
15597<tr><th><a name="Concept-Index_cp_letter-L">L</a></th><td></td><td></td></tr>
15598<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>
15599<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>
15600<tr><td colspan="4"> <hr></td></tr>
15601<tr><th><a name="Concept-Index_cp_letter-M">M</a></th><td></td><td></td></tr>
15602<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>
15603<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>
15604<tr><td colspan="4"> <hr></td></tr>
15605<tr><th><a name="Concept-Index_cp_letter-N">N</a></th><td></td><td></td></tr>
15606<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>
15607<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>
15608<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>
15609<tr><td colspan="4"> <hr></td></tr>
15610<tr><th><a name="Concept-Index_cp_letter-O">O</a></th><td></td><td></td></tr>
15611<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>
15612<tr><td colspan="4"> <hr></td></tr>
15613<tr><th><a name="Concept-Index_cp_letter-P">P</a></th><td></td><td></td></tr>
15614<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>
15615<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>
15616<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>
15617<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>
15618<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>
15619<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>
15620<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>
15621<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>
15622<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>
15623<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>
15624<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>
15625<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>
15626<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>
15627<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>
15628<tr><td colspan="4"> <hr></td></tr>
15629<tr><th><a name="Concept-Index_cp_letter-Q">Q</a></th><td></td><td></td></tr>
15630<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>
15631<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>
15632<tr><td colspan="4"> <hr></td></tr>
15633<tr><th><a name="Concept-Index_cp_letter-R">R</a></th><td></td><td></td></tr>
15634<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>
15635<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>
15636<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>
15637<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>
15638<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>
15639<tr><td colspan="4"> <hr></td></tr>
15640<tr><th><a name="Concept-Index_cp_letter-S">S</a></th><td></td><td></td></tr>
15641<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>
15642<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>
15643<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>
15644<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>
15645<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>
15646<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>
15647<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>
15648<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>
15649<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>
15650<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>
15651<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>
15652<tr><td colspan="4"> <hr></td></tr>
15653<tr><th><a name="Concept-Index_cp_letter-T">T</a></th><td></td><td></td></tr>
15654<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>
15655<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>
15656<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>
15657<tr><td colspan="4"> <hr></td></tr>
15658<tr><th><a name="Concept-Index_cp_letter-V">V</a></th><td></td><td></td></tr>
15659<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>
15660<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>
15661<tr><td colspan="4"> <hr></td></tr>
15662<tr><th><a name="Concept-Index_cp_letter-W">W</a></th><td></td><td></td></tr>
15663<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>
15664<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>
15665<tr><td colspan="4"> <hr></td></tr>
15666<tr><th><a name="Concept-Index_cp_letter-Y">Y</a></th><td></td><td></td></tr>
15667<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>
15668<tr><td colspan="4"> <hr></td></tr>
15669</table>
15670<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Concept-Index_cp_letter-A"><b>A</b></a>
15671 &nbsp;
15672<a class="summary-letter" href="#Concept-Index_cp_letter-B"><b>B</b></a>
15673 &nbsp;
15674<a class="summary-letter" href="#Concept-Index_cp_letter-C"><b>C</b></a>
15675 &nbsp;
15676<a class="summary-letter" href="#Concept-Index_cp_letter-D"><b>D</b></a>
15677 &nbsp;
15678<a class="summary-letter" href="#Concept-Index_cp_letter-E"><b>E</b></a>
15679 &nbsp;
15680<a class="summary-letter" href="#Concept-Index_cp_letter-F"><b>F</b></a>
15681 &nbsp;
15682<a class="summary-letter" href="#Concept-Index_cp_letter-H"><b>H</b></a>
15683 &nbsp;
15684<a class="summary-letter" href="#Concept-Index_cp_letter-I"><b>I</b></a>
15685 &nbsp;
15686<a class="summary-letter" href="#Concept-Index_cp_letter-J"><b>J</b></a>
15687 &nbsp;
15688<a class="summary-letter" href="#Concept-Index_cp_letter-K"><b>K</b></a>
15689 &nbsp;
15690<a class="summary-letter" href="#Concept-Index_cp_letter-L"><b>L</b></a>
15691 &nbsp;
15692<a class="summary-letter" href="#Concept-Index_cp_letter-M"><b>M</b></a>
15693 &nbsp;
15694<a class="summary-letter" href="#Concept-Index_cp_letter-N"><b>N</b></a>
15695 &nbsp;
15696<a class="summary-letter" href="#Concept-Index_cp_letter-O"><b>O</b></a>
15697 &nbsp;
15698<a class="summary-letter" href="#Concept-Index_cp_letter-P"><b>P</b></a>
15699 &nbsp;
15700<a class="summary-letter" href="#Concept-Index_cp_letter-Q"><b>Q</b></a>
15701 &nbsp;
15702<a class="summary-letter" href="#Concept-Index_cp_letter-R"><b>R</b></a>
15703 &nbsp;
15704<a class="summary-letter" href="#Concept-Index_cp_letter-S"><b>S</b></a>
15705 &nbsp;
15706<a class="summary-letter" href="#Concept-Index_cp_letter-T"><b>T</b></a>
15707 &nbsp;
15708<a class="summary-letter" href="#Concept-Index_cp_letter-V"><b>V</b></a>
15709 &nbsp;
15710<a class="summary-letter" href="#Concept-Index_cp_letter-W"><b>W</b></a>
15711 &nbsp;
15712<a class="summary-letter" href="#Concept-Index_cp_letter-Y"><b>Y</b></a>
15713 &nbsp;
15714</td></tr></table>
15715
15716<hr>
15717
15718
15719
15720</body>
15721</html>