]>
Commit | Line | Data |
---|---|---|
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 | 4 | the Bash shell (version 5.0, 7 August 2018). |
a0c0a00f | 5 | |
2f5dfe5a | 6 | This is Edition 5.0, last updated 7 August 2018, |
a0c0a00f | 7 | of The GNU Bash Reference Manual, |
9a51695b | 8 | for Bash, Version 5.0. |
a0c0a00f | 9 | |
9a51695b | 10 | Copyright (C) 1988-2018 Free Software Foundation, Inc. |
a0c0a00f CR |
11 | |
12 | Permission is granted to copy, distribute and/or modify this document | |
13 | under the terms of the GNU Free Documentation License, Version 1.3 or | |
14 | any later version published by the Free Software Foundation; with no | |
15 | Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. | |
16 | A copy of the license is included in the section entitled | |
17 | "GNU Free Documentation License". --> | |
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 | <!-- | |
34 | a.summary-letter {text-decoration: none} | |
35 | blockquote.indentedblock {margin-right: 0em} | |
36 | blockquote.smallindentedblock {margin-right: 0em; font-size: smaller} | |
37 | blockquote.smallquotation {font-size: smaller} | |
38 | div.display {margin-left: 3.2em} | |
39 | div.example {margin-left: 3.2em} | |
40 | div.lisp {margin-left: 3.2em} | |
41 | div.smalldisplay {margin-left: 3.2em} | |
42 | div.smallexample {margin-left: 3.2em} | |
43 | div.smalllisp {margin-left: 3.2em} | |
44 | kbd {font-style: oblique} | |
45 | pre.display {font-family: inherit} | |
46 | pre.format {font-family: inherit} | |
47 | pre.menu-comment {font-family: serif} | |
48 | pre.menu-preformatted {font-family: serif} | |
49 | pre.smalldisplay {font-family: inherit; font-size: smaller} | |
50 | pre.smallexample {font-size: smaller} | |
51 | pre.smallformat {font-family: inherit; font-size: smaller} | |
52 | pre.smalllisp {font-size: smaller} | |
53 | span.nolinebreak {white-space: nowrap} | |
54 | span.roman {font-family: initial; font-weight: normal} | |
55 | span.sansserif {font-family: sans-serif; font-weight: normal} | |
56 | ul.no-bullet {list-style: none} | |
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> | |
281 | Next: <a href="#Introduction" accesskey="n" rel="next">Introduction</a>, Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href="dir.html#Top" accesskey="u" rel="up">(dir)</a> [<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 | 287 | the Bash shell (version 5.0, 7 August 2018). |
a0c0a00f CR |
288 | The 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 | 291 | of <cite>The GNU Bash Reference Manual</cite>, |
9a51695b | 292 | for <code>Bash</code>, Version 5.0. |
a0c0a00f CR |
293 | </p> |
294 | <p>Bash contains features that appear in other popular shells, and some | |
17345e5a | 295 | features that only appear in Bash. Some of the shells that Bash has |
a0c0a00f CR |
296 | borrowed concepts from are the Bourne Shell (<samp>sh</samp>), the Korn Shell |
297 | (<samp>ksh</samp>), and the C-shell (<samp>csh</samp> and its successor, | |
298 | <samp>tcsh</samp>). The following menu breaks the features up into | |
ac50fbac CR |
299 | categories, noting which features were inspired by other shells and |
300 | which are specific to Bash. | |
a0c0a00f CR |
301 | </p> |
302 | <p>This manual is meant as a brief introduction to features found in | |
17345e5a JA |
303 | Bash. The Bash manual page should be used as the definitive |
304 | reference on shell behavior. | |
a0c0a00f CR |
305 | </p> |
306 | <table class="menu" border="0" cellspacing="0"> | |
307 | <tr><td align="left" valign="top">• <a href="#Introduction" accesskey="1">Introduction</a>:</td><td> </td><td align="left" valign="top">An introduction to the shell. | |
308 | </td></tr> | |
309 | <tr><td align="left" valign="top">• <a href="#Definitions" accesskey="2">Definitions</a>:</td><td> </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">• <a href="#Basic-Shell-Features" accesskey="3">Basic Shell Features</a>:</td><td> </td><td align="left" valign="top">The shell "building blocks". | |
313 | </td></tr> | |
314 | <tr><td align="left" valign="top">• <a href="#Shell-Builtin-Commands" accesskey="4">Shell Builtin Commands</a>:</td><td> </td><td align="left" valign="top">Commands that are a part of the shell. | |
315 | </td></tr> | |
316 | <tr><td align="left" valign="top">• <a href="#Shell-Variables" accesskey="5">Shell Variables</a>:</td><td> </td><td align="left" valign="top">Variables used or set by Bash. | |
317 | </td></tr> | |
318 | <tr><td align="left" valign="top">• <a href="#Bash-Features" accesskey="6">Bash Features</a>:</td><td> </td><td align="left" valign="top">Features found only in Bash. | |
319 | </td></tr> | |
320 | <tr><td align="left" valign="top">• <a href="#Job-Control" accesskey="7">Job Control</a>:</td><td> </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">• <a href="#Command-Line-Editing" accesskey="8">Command Line Editing</a>:</td><td> </td><td align="left" valign="top">Chapter describing the command line | |
324 | editing features. | |
325 | </td></tr> | |
326 | <tr><td align="left" valign="top">• <a href="#Using-History-Interactively" accesskey="9">Using History Interactively</a>:</td><td> </td><td align="left" valign="top">Command History Expansion | |
327 | </td></tr> | |
328 | <tr><td align="left" valign="top">• <a href="#Installing-Bash">Installing Bash</a>:</td><td> </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">• <a href="#Reporting-Bugs">Reporting Bugs</a>:</td><td> </td><td align="left" valign="top">How to report bugs in Bash. | |
331 | </td></tr> | |
332 | <tr><td align="left" valign="top">• <a href="#Major-Differences-From-The-Bourne-Shell">Major Differences From The Bourne Shell</a>:</td><td> </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">• <a href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>:</td><td> </td><td align="left" valign="top">Copying and sharing this documentation. | |
337 | </td></tr> | |
338 | <tr><td align="left" valign="top">• <a href="#Indexes">Indexes</a>:</td><td> </td><td align="left" valign="top">Various indexes for this manual. | |
339 | </td></tr> | |
340 | </table> | |
341 | ||
342 | <hr> | |
343 | <a name="Introduction"></a> | |
344 | <div class="header"> | |
345 | <p> | |
346 | Next: <a href="#Definitions" accesskey="n" rel="next">Definitions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<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">• <a href="#What-is-Bash_003f" accesskey="1">What is Bash?</a>:</td><td> </td><td align="left" valign="top">A short description of Bash. | |
352 | </td></tr> | |
353 | <tr><td align="left" valign="top">• <a href="#What-is-a-shell_003f" accesskey="2">What is a shell?</a>:</td><td> </td><td align="left" valign="top">A brief introduction to shells. | |
354 | </td></tr> | |
355 | </table> | |
356 | ||
357 | <hr> | |
358 | <a name="What-is-Bash_003f"></a> | |
359 | <div class="header"> | |
360 | <p> | |
361 | Next: <a href="#What-is-a-shell_003f" accesskey="n" rel="next">What is a shell?</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> | |
362 | </div> | |
363 | <a name="What-is-Bash_003f-1"></a> | |
364 | <h3 class="section">1.1 What is Bash?</h3> | |
365 | ||
366 | <p>Bash is the shell, or command language interpreter, | |
367 | for the <small>GNU</small> operating system. | |
368 | The name is an acronym for the ‘<samp>Bourne-Again SHell</samp>’, | |
17345e5a | 369 | a pun on Stephen Bourne, the author of the direct ancestor of |
a0c0a00f | 370 | the current Unix shell <code>sh</code>, |
17345e5a JA |
371 | which appeared in the Seventh Edition Bell Labs Research version |
372 | of Unix. | |
a0c0a00f CR |
373 | </p> |
374 | <p>Bash is largely compatible with <code>sh</code> and incorporates useful | |
375 | features from the Korn shell <code>ksh</code> and the C shell <code>csh</code>. | |
376 | It is intended to be a conformant implementation of the <small>IEEE</small> | |
377 | <small>POSIX</small> Shell and Tools portion of the <small>IEEE</small> <small>POSIX</small> | |
378 | specification (<small>IEEE</small> Standard 1003.1). | |
379 | It offers functional improvements over <code>sh</code> for both interactive and | |
17345e5a | 380 | programming use. |
a0c0a00f CR |
381 | </p> |
382 | <p>While the <small>GNU</small> operating system provides other shells, including | |
383 | a version of <code>csh</code>, Bash is the default shell. | |
384 | Like other <small>GNU</small> software, Bash is quite portable. It currently runs | |
17345e5a | 385 | on nearly every version of Unix and a few other operating systems - |
a0c0a00f | 386 | independently-supported ports exist for <small>MS-DOS</small>, <small>OS/2</small>, |
17345e5a | 387 | and Windows platforms. |
a0c0a00f CR |
388 | </p> |
389 | <hr> | |
390 | <a name="What-is-a-shell_003f"></a> | |
391 | <div class="header"> | |
392 | <p> | |
393 | Previous: <a href="#What-is-Bash_003f" accesskey="p" rel="prev">What is Bash?</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> [<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 |
399 | commands. The term macro processor means functionality where text |
400 | and 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 | 403 | language. As a command interpreter, the shell provides the user |
a0c0a00f | 404 | interface to the rich set of <small>GNU</small> utilities. The programming |
17345e5a JA |
405 | language features allow these utilities to be combined. |
406 | Files containing commands can be created, and become | |
407 | commands themselves. These new commands have the same status as | |
a0c0a00f | 408 | system commands in directories such as <samp>/bin</samp>, allowing users |
17345e5a JA |
409 | or groups to establish custom environments to automate their common |
410 | tasks. | |
a0c0a00f CR |
411 | </p> |
412 | <p>Shells may be used interactively or non-interactively. In | |
17345e5a JA |
413 | interactive mode, they accept input typed from the keyboard. |
414 | When executing non-interactively, shells execute commands read | |
415 | from a file. | |
a0c0a00f CR |
416 | </p> |
417 | <p>A shell allows execution of <small>GNU</small> commands, both synchronously and | |
17345e5a JA |
418 | asynchronously. |
419 | The shell waits for synchronous commands to complete before accepting | |
420 | more input; asynchronous commands continue to execute in parallel | |
421 | with the shell while it reads and executes additional commands. | |
a0c0a00f | 422 | The <em>redirection</em> constructs permit |
17345e5a | 423 | fine-grained control of the input and output of those commands. |
a0c0a00f | 424 | Moreover, the shell allows control over the contents of commands’ |
17345e5a | 425 | environments. |
a0c0a00f CR |
426 | </p> |
427 | <p>Shells also provide a small set of built-in | |
428 | commands (<em>builtins</em>) implementing functionality impossible | |
17345e5a | 429 | or inconvenient to obtain via separate utilities. |
a0c0a00f CR |
430 | For example, <code>cd</code>, <code>break</code>, <code>continue</code>, and |
431 | <code>exec</code> cannot be implemented outside of the shell because | |
17345e5a | 432 | they directly manipulate the shell itself. |
a0c0a00f | 433 | The <code>history</code>, <code>getopts</code>, <code>kill</code>, or <code>pwd</code> |
17345e5a JA |
434 | builtins, among others, could be implemented in separate utilities, |
435 | but they are more convenient to use as builtin commands. | |
436 | All of the shell builtins are described in | |
437 | subsequent sections. | |
a0c0a00f CR |
438 | </p> |
439 | <p>While executing commands is essential, most of the power (and | |
17345e5a JA |
440 | complexity) of shells is due to their embedded programming |
441 | languages. Like any high-level language, the shell provides | |
442 | variables, flow control constructs, quoting, and functions. | |
a0c0a00f CR |
443 | </p> |
444 | <p>Shells offer features geared specifically for | |
17345e5a JA |
445 | interactive use rather than to augment the programming language. |
446 | These interactive features include job control, command line | |
447 | editing, command history and aliases. Each of these features is | |
448 | described in this manual. | |
a0c0a00f CR |
449 | </p> |
450 | <hr> | |
451 | <a name="Definitions"></a> | |
452 | <div class="header"> | |
453 | <p> | |
454 | Next: <a href="#Basic-Shell-Features" accesskey="n" rel="next">Basic Shell Features</a>, Previous: <a href="#Introduction" accesskey="p" rel="prev">Introduction</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<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 | 464 | is 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 | 475 | than 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 | 481 | or one of the following: |
a0c0a00f CR |
482 | ‘<samp>||</samp>’, ‘<samp>&&</samp>’, ‘<samp>&</samp>’, ‘<samp>;</samp>’, ‘<samp>;;</samp>’, ‘<samp>;&</samp>’, ‘<samp>;;&</samp>’, |
483 | ‘<samp>|</samp>’, ‘<samp>|&</samp>’, ‘<samp>(</samp>’, or ‘<samp>)</samp>’. | |
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 | 489 | to 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 |
495 | expansion, when executing a command, the resulting fields are used as |
496 | the 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 | 507 | from 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 | |
519 | a <code>space</code>, <code>tab</code>, <code>newline</code>, or one of the following characters: | |
520 | ‘<samp>|</samp>’, ‘<samp>&</samp>’, ‘<samp>;</samp>’, ‘<samp>(</samp>’, ‘<samp>)</samp>’, ‘<samp><</samp>’, or | |
521 | ‘<samp>></samp>’. | |
522 | </p> | |
523 | </dd> | |
524 | <dt><code>name</code></dt> | |
525 | <dd><a name="index-name"></a> | |
526 | <a name="index-identifier"></a> | |
527 | <p>A <code>word</code> consisting solely of letters, numbers, and underscores, | |
528 | and beginning with a letter or underscore. <code>Name</code>s are used as | |
17345e5a | 529 | shell variable and function names. |
a0c0a00f CR |
530 | Also referred to as an <code>identifier</code>. |
531 | </p> | |
532 | </dd> | |
533 | <dt><code>operator</code></dt> | |
534 | <dd><a name="index-operator_002c-shell"></a> | |
535 | <p>A <code>control operator</code> or a <code>redirection operator</code>. | |
536 | See <a href="#Redirections">Redirections</a>, for a list of redirection operators. | |
537 | Operators contain at least one unquoted <code>metacharacter</code>. | |
538 | </p> | |
539 | </dd> | |
540 | <dt><code>process group</code></dt> | |
541 | <dd><a name="index-process-group"></a> | |
542 | <p>A collection of related processes each having the same process | |
543 | group <small>ID</small>. | |
544 | </p> | |
545 | </dd> | |
546 | <dt><code>process group ID</code></dt> | |
547 | <dd><a name="index-process-group-ID"></a> | |
548 | <p>A unique identifier that represents a <code>process group</code> | |
17345e5a | 549 | during 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 | |
555 | words introduce shell flow control constructs, such as <code>for</code> and | |
556 | <code>while</code>. | |
557 | </p> | |
558 | </dd> | |
559 | <dt><code>return status</code></dt> | |
560 | <dd><a name="index-return-status"></a> | |
561 | <p>A synonym for <code>exit status</code>. | |
562 | </p> | |
563 | </dd> | |
564 | <dt><code>signal</code></dt> | |
565 | <dd><a name="index-signal"></a> | |
566 | <p>A mechanism by which a process may be notified by the kernel | |
17345e5a | 567 | of 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. | |
579 | It is either a <code>word</code> or an <code>operator</code>. | |
580 | </p> | |
581 | </dd> | |
582 | <dt><code>word</code></dt> | |
583 | <dd><a name="index-word"></a> | |
584 | <p>A sequence of characters treated as a unit by the shell. | |
585 | Words may not include unquoted <code>metacharacters</code>. | |
586 | </p></dd> | |
587 | </dl> | |
588 | ||
589 | <hr> | |
590 | <a name="Basic-Shell-Features"></a> | |
591 | <div class="header"> | |
592 | <p> | |
593 | Next: <a href="#Shell-Builtin-Commands" accesskey="n" rel="next">Shell Builtin Commands</a>, Previous: <a href="#Definitions" accesskey="p" rel="prev">Definitions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<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 ‘<samp>Bourne-Again SHell</samp>’. | |
17345e5a JA |
600 | The Bourne shell is |
601 | the traditional Unix shell originally written by Stephen Bourne. | |
602 | All of the Bourne shell builtin commands are available in Bash, | |
a0c0a00f CR |
603 | The rules for evaluation and quoting are taken from the <small>POSIX</small> |
604 | specification for the ‘standard’ Unix shell. | |
605 | </p> | |
606 | <p>This chapter briefly summarizes the shell’s ‘building blocks’: | |
607 | commands, control structures, shell functions, shell <i>parameters</i>, | |
17345e5a | 608 | shell expansions, |
a0c0a00f | 609 | <i>redirections</i>, which are a way to direct input and output from |
17345e5a | 610 | and 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">• <a href="#Shell-Syntax" accesskey="1">Shell Syntax</a>:</td><td> </td><td align="left" valign="top">What your input means to the shell. | |
614 | </td></tr> | |
615 | <tr><td align="left" valign="top">• <a href="#Shell-Commands" accesskey="2">Shell Commands</a>:</td><td> </td><td align="left" valign="top">The types of commands you can use. | |
616 | </td></tr> | |
617 | <tr><td align="left" valign="top">• <a href="#Shell-Functions" accesskey="3">Shell Functions</a>:</td><td> </td><td align="left" valign="top">Grouping commands by name. | |
618 | </td></tr> | |
619 | <tr><td align="left" valign="top">• <a href="#Shell-Parameters" accesskey="4">Shell Parameters</a>:</td><td> </td><td align="left" valign="top">How the shell stores values. | |
620 | </td></tr> | |
621 | <tr><td align="left" valign="top">• <a href="#Shell-Expansions" accesskey="5">Shell Expansions</a>:</td><td> </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">• <a href="#Redirections" accesskey="6">Redirections</a>:</td><td> </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">• <a href="#Executing-Commands" accesskey="7">Executing Commands</a>:</td><td> </td><td align="left" valign="top">What happens when you run a command. | |
627 | </td></tr> | |
628 | <tr><td align="left" valign="top">• <a href="#Shell-Scripts" accesskey="8">Shell Scripts</a>:</td><td> </td><td align="left" valign="top">Executing files of shell commands. | |
629 | </td></tr> | |
630 | </table> | |
631 | ||
632 | <hr> | |
633 | <a name="Shell-Syntax"></a> | |
634 | <div class="header"> | |
635 | <p> | |
636 | Next: <a href="#Shell-Commands" accesskey="n" rel="next">Shell Commands</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> [<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">• <a href="#Shell-Operation" accesskey="1">Shell Operation</a>:</td><td> </td><td align="left" valign="top">The basic operation of the shell. | |
642 | </td></tr> | |
643 | <tr><td align="left" valign="top">• <a href="#Quoting" accesskey="2">Quoting</a>:</td><td> </td><td align="left" valign="top">How to remove the special meaning from characters. | |
644 | </td></tr> | |
645 | <tr><td align="left" valign="top">• <a href="#Comments" accesskey="3">Comments</a>:</td><td> </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 | 650 | sequence of operations. If the input indicates the beginning of a |
a0c0a00f | 651 | comment, the shell ignores the comment symbol (‘<samp>#</samp>’), and the rest |
17345e5a | 652 | of that line. |
a0c0a00f CR |
653 | </p> |
654 | <p>Otherwise, roughly speaking, the shell reads its input and | |
17345e5a JA |
655 | divides the input into words and operators, employing the quoting rules |
656 | to 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 |
659 | removes the special meaning of certain words or characters, expands |
660 | others, redirects input and output as needed, executes the specified | |
a0c0a00f | 661 | command, waits for the command’s exit status, and makes that exit status |
17345e5a | 662 | available for further inspection or processing. |
a0c0a00f CR |
663 | </p> |
664 | <hr> | |
665 | <a name="Shell-Operation"></a> | |
666 | <div class="header"> | |
667 | <p> | |
668 | Next: <a href="#Quoting" accesskey="n" rel="next">Quoting</a>, Up: <a href="#Shell-Syntax" accesskey="u" rel="up">Shell Syntax</a> [<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’s operation when it | |
17345e5a JA |
674 | reads and executes a command. Basically, the shell does the |
675 | following: | |
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 | |
679 | supplied as an argument to the <samp>-c</samp> invocation option | |
680 | (see <a href="#Invoking-Bash">Invoking Bash</a>), or from the user’s terminal. | |
681 | ||
682 | </li><li> Breaks the input into words and operators, obeying the quoting rules | |
683 | described in <a href="#Quoting">Quoting</a>. These tokens are separated by | |
684 | <code>metacharacters</code>. Alias expansion is performed by this step | |
685 | (see <a href="#Aliases">Aliases</a>). | |
686 | ||
687 | </li><li> Parses the tokens into simple and compound commands | |
688 | (see <a href="#Shell-Commands">Shell Commands</a>). | |
689 | ||
690 | </li><li> Performs the various shell expansions (see <a href="#Shell-Expansions">Shell Expansions</a>), breaking | |
691 | the expanded tokens into lists of filenames (see <a href="#Filename-Expansion">Filename Expansion</a>) | |
17345e5a | 692 | and commands and arguments. |
17345e5a | 693 | |
a0c0a00f | 694 | </li><li> Performs any necessary redirections (see <a href="#Redirections">Redirections</a>) and removes |
17345e5a | 695 | the 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 | |
700 | status (see <a href="#Exit-Status">Exit Status</a>). | |
701 | ||
702 | </li></ol> | |
703 | ||
704 | <hr> | |
705 | <a name="Quoting"></a> | |
706 | <div class="header"> | |
707 | <p> | |
708 | Next: <a href="#Comments" accesskey="n" rel="next">Comments</a>, Previous: <a href="#Shell-Operation" accesskey="p" rel="prev">Shell Operation</a>, Up: <a href="#Shell-Syntax" accesskey="u" rel="up">Shell Syntax</a> [<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">• <a href="#Escape-Character" accesskey="1">Escape Character</a>:</td><td> </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">• <a href="#Single-Quotes" accesskey="2">Single Quotes</a>:</td><td> </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">• <a href="#Double-Quotes" accesskey="3">Double Quotes</a>:</td><td> </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">• <a href="#ANSI_002dC-Quoting" accesskey="4">ANSI-C Quoting</a>:</td><td> </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">• <a href="#Locale-Translation" accesskey="5">Locale Translation</a>:</td><td> </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 |
730 | characters or words to the shell. Quoting can be used to |
731 | disable special treatment for special characters, to prevent | |
732 | reserved words from being recognized as such, and to prevent | |
733 | parameter expansion. | |
a0c0a00f CR |
734 | </p> |
735 | <p>Each of the shell metacharacters (see <a href="#Definitions">Definitions</a>) | |
17345e5a JA |
736 | has special meaning to the shell and must be quoted if it is to |
737 | represent itself. | |
738 | When the command history expansion facilities are being used | |
a0c0a00f CR |
739 | (see <a href="#History-Interaction">History Interaction</a>), the |
740 | <var>history expansion</var> character, usually ‘<samp>!</samp>’, must be quoted | |
741 | to prevent history expansion. See <a href="#Bash-History-Facilities">Bash History Facilities</a>, for | |
17345e5a | 742 | more 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> | |
751 | Next: <a href="#Single-Quotes" accesskey="n" rel="next">Single Quotes</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> [<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 ‘<samp>\</samp>’ is the Bash escape character. | |
17345e5a | 756 | It preserves the literal value of the next character that follows, |
a0c0a00f CR |
757 | with the exception of <code>newline</code>. If a <code>\newline</code> pair |
758 | appears, and the backslash itself is not quoted, the <code>\newline</code> | |
17345e5a JA |
759 | is treated as a line continuation (that is, it is removed from |
760 | the input stream and effectively ignored). | |
a0c0a00f CR |
761 | </p> |
762 | <hr> | |
763 | <a name="Single-Quotes"></a> | |
764 | <div class="header"> | |
765 | <p> | |
766 | Next: <a href="#Double-Quotes" accesskey="n" rel="next">Double Quotes</a>, Previous: <a href="#Escape-Character" accesskey="p" rel="prev">Escape Character</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> [<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 (‘<samp>'</samp>’) preserves the literal value | |
17345e5a JA |
772 | of each character within the quotes. A single quote may not occur |
773 | between 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> | |
779 | Next: <a href="#ANSI_002dC-Quoting" accesskey="n" rel="next">ANSI-C Quoting</a>, Previous: <a href="#Single-Quotes" accesskey="p" rel="prev">Single Quotes</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> [<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 (‘<samp>"</samp>’) preserves the literal value | |
17345e5a | 785 | of all characters within the quotes, with the exception of |
a0c0a00f CR |
786 | ‘<samp>$</samp>’, ‘<samp>`</samp>’, ‘<samp>\</samp>’, |
787 | and, when history expansion is enabled, ‘<samp>!</samp>’. | |
788 | When the shell is in | |
789 | <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>), | |
790 | the ‘<samp>!</samp>’ has no special meaning | |
791 | within double quotes, even when history expansion is enabled. | |
792 | The characters ‘<samp>$</samp>’ and ‘<samp>`</samp>’ | |
793 | retain their special meaning within double quotes (see <a href="#Shell-Expansions">Shell Expansions</a>). | |
17345e5a JA |
794 | The backslash retains its special meaning only when followed by one of |
795 | the following characters: | |
a0c0a00f | 796 | ‘<samp>$</samp>’, ‘<samp>`</samp>’, ‘<samp>"</samp>’, ‘<samp>\</samp>’, or <code>newline</code>. |
17345e5a JA |
797 | Within double quotes, backslashes that are followed by one of these |
798 | characters are removed. Backslashes preceding characters without a | |
799 | special meaning are left unmodified. | |
800 | A double quote may be quoted within double quotes by preceding it with | |
801 | a backslash. | |
a0c0a00f | 802 | If enabled, history expansion will be performed unless an ‘<samp>!</samp>’ |
17345e5a | 803 | appearing in double quotes is escaped using a backslash. |
a0c0a00f CR |
804 | The backslash preceding the ‘<samp>!</samp>’ is not removed. |
805 | </p> | |
806 | <p>The special parameters ‘<samp>*</samp>’ and ‘<samp>@</samp>’ have special meaning | |
807 | when in double quotes (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>). | |
808 | </p> | |
809 | <hr> | |
810 | <a name="ANSI_002dC-Quoting"></a> | |
811 | <div class="header"> | |
812 | <p> | |
813 | Next: <a href="#Locale-Translation" accesskey="n" rel="next">Locale Translation</a>, Previous: <a href="#Double-Quotes" accesskey="p" rel="prev">Double Quotes</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> | |
814 | </div> | |
815 | <a name="ANSI_002dC-Quoting-1"></a> | |
816 | <h4 class="subsubsection">3.1.2.4 ANSI-C Quoting</h4> | |
817 | <a name="index-quoting_002c-ANSI"></a> | |
818 | ||
819 | <p>Words of the form <code>$'<var>string</var>'</code> are treated specially. The | |
820 | word expands to <var>string</var>, with backslash-escaped characters replaced | |
17345e5a JA |
821 | as specified by the ANSI C standard. Backslash escape sequences, if |
822 | present, 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>\"</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 | 884 | been present. |
a0c0a00f CR |
885 | </p> |
886 | <hr> | |
887 | <a name="Locale-Translation"></a> | |
888 | <div class="header"> | |
889 | <p> | |
890 | Previous: <a href="#ANSI_002dC-Quoting" accesskey="p" rel="prev">ANSI-C Quoting</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> [<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 (‘<samp>$</samp>’) will cause | |
17345e5a | 900 | the string to be translated according to the current locale. |
a0c0a00f | 901 | If the current locale is <code>C</code> or <code>POSIX</code>, the dollar sign |
17345e5a JA |
902 | is ignored. |
903 | If the string is translated and replaced, the replacement is | |
904 | double-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 | 910 | shell variable. Others create the name of the message catalog from the |
a0c0a00f CR |
911 | value of the <code>TEXTDOMAIN</code> shell variable, possibly adding a |
912 | suffix of ‘<samp>.mo</samp>’. If you use the <code>TEXTDOMAIN</code> variable, you | |
913 | may need to set the <code>TEXTDOMAINDIR</code> variable to the location of | |
17345e5a JA |
914 | the message catalog files. Still others use both variables in this |
915 | fashion: | |
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> | |
922 | Previous: <a href="#Quoting" accesskey="p" rel="prev">Quoting</a>, Up: <a href="#Shell-Syntax" accesskey="u" rel="up">Shell Syntax</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> | |
923 | </div> | |
924 | <a name="Comments-1"></a> | |
925 | <h4 class="subsection">3.1.3 Comments</h4> | |
926 | <a name="index-comments_002c-shell"></a> | |
927 | ||
928 | <p>In a non-interactive shell, or an interactive shell in which the | |
929 | <code>interactive_comments</code> option to the <code>shopt</code> | |
930 | builtin is enabled (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), | |
931 | a word beginning with ‘<samp>#</samp>’ | |
17345e5a | 932 | causes that word and all remaining characters on that line to |
a0c0a00f CR |
933 | be ignored. An interactive shell without the <code>interactive_comments</code> |
934 | option enabled does not allow comments. The <code>interactive_comments</code> | |
17345e5a | 935 | option is on by default in interactive shells. |
a0c0a00f | 936 | See <a href="#Interactive-Shells">Interactive Shells</a>, for a description of what makes |
17345e5a | 937 | a shell interactive. |
a0c0a00f CR |
938 | </p> |
939 | <hr> | |
940 | <a name="Shell-Commands"></a> | |
941 | <div class="header"> | |
942 | <p> | |
943 | Next: <a href="#Shell-Functions" accesskey="n" rel="next">Shell Functions</a>, Previous: <a href="#Shell-Syntax" accesskey="p" rel="prev">Shell Syntax</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> [<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 | 950 | itself 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 |
953 | in a variety of ways: in a pipeline in which the output of one command |
954 | becomes the input of a second, in a loop or conditional construct, or in | |
955 | some other grouping. | |
a0c0a00f CR |
956 | </p> |
957 | <table class="menu" border="0" cellspacing="0"> | |
958 | <tr><td align="left" valign="top">• <a href="#Simple-Commands" accesskey="1">Simple Commands</a>:</td><td> </td><td align="left" valign="top">The most common type of command. | |
959 | </td></tr> | |
960 | <tr><td align="left" valign="top">• <a href="#Pipelines" accesskey="2">Pipelines</a>:</td><td> </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">• <a href="#Lists" accesskey="3">Lists</a>:</td><td> </td><td align="left" valign="top">How to execute commands sequentially. | |
964 | </td></tr> | |
965 | <tr><td align="left" valign="top">• <a href="#Compound-Commands" accesskey="4">Compound Commands</a>:</td><td> </td><td align="left" valign="top">Shell commands for control flow. | |
966 | </td></tr> | |
967 | <tr><td align="left" valign="top">• <a href="#Coprocesses" accesskey="5">Coprocesses</a>:</td><td> </td><td align="left" valign="top">Two-way communication between commands. | |
968 | </td></tr> | |
969 | <tr><td align="left" valign="top">• <a href="#GNU-Parallel" accesskey="6">GNU Parallel</a>:</td><td> </td><td align="left" valign="top">Running commands in parallel. | |
970 | </td></tr> | |
971 | </table> | |
972 | ||
973 | <hr> | |
974 | <a name="Simple-Commands"></a> | |
975 | <div class="header"> | |
976 | <p> | |
977 | Next: <a href="#Pipelines" accesskey="n" rel="next">Pipelines</a>, Up: <a href="#Shell-Commands" accesskey="u" rel="up">Shell Commands</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> | |
978 | </div> | |
979 | <a name="Simple-Commands-1"></a> | |
980 | <h4 class="subsection">3.2.1 Simple Commands</h4> | |
981 | <a name="index-commands_002c-simple"></a> | |
982 | ||
983 | <p>A simple command is the kind of command encountered most often. | |
984 | It’s just a sequence of words separated by <code>blank</code>s, terminated | |
985 | by one of the shell’s control operators (see <a href="#Definitions">Definitions</a>). The | |
17345e5a | 986 | first word generally specifies a command to be executed, with the |
a0c0a00f CR |
987 | rest of the words being that command’s arguments. |
988 | </p> | |
989 | <p>The return status (see <a href="#Exit-Status">Exit Status</a>) of a simple command is | |
17345e5a | 990 | its exit status as provided |
a0c0a00f CR |
991 | by the <small>POSIX</small> 1003.1 <code>waitpid</code> function, or 128+<var>n</var> if |
992 | the command was terminated by signal <var>n</var>. | |
993 | </p> | |
994 | <hr> | |
995 | <a name="Pipelines"></a> | |
996 | <div class="header"> | |
997 | <p> | |
998 | Next: <a href="#Lists" accesskey="n" rel="next">Lists</a>, Previous: <a href="#Simple-Commands" accesskey="p" rel="prev">Simple Commands</a>, Up: <a href="#Shell-Commands" accesskey="u" rel="up">Shell Commands</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> | |
999 | </div> | |
1000 | <a name="Pipelines-1"></a> | |
1001 | <h4 class="subsection">3.2.2 Pipelines</h4> | |
1002 | <a name="index-pipeline"></a> | |
1003 | <a name="index-commands_002c-pipelines"></a> | |
1004 | ||
1005 | <p>A <code>pipeline</code> is a sequence of one or more commands separated by | |
1006 | one of the control operators ‘<samp>|</samp>’ or ‘<samp>|&</samp>’. | |
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 |& <var>command2</var> ] … | |
1014 | </pre></div> | |
1015 | ||
1016 | <p>The output of each command in the pipeline is connected via a pipe | |
17345e5a | 1017 | to the input of the next command. |
a0c0a00f | 1018 | That is, each command reads the previous command’s output. This |
17345e5a JA |
1019 | connection is performed before any redirections specified by the |
1020 | command. | |
a0c0a00f CR |
1021 | </p> |
1022 | <p>If ‘<samp>|&</samp>’ is used, <var>command1</var>’s standard error, in addition to | |
ac50fbac | 1023 | its standard output, is connected to |
a0c0a00f CR |
1024 | <var>command2</var>’s standard input through the pipe; |
1025 | it is shorthand for <code>2>&1 |</code>. | |
ac50fbac | 1026 | This implicit redirection of the standard error to the standard output is |
17345e5a | 1027 | performed after any redirections specified by the command. |
a0c0a00f CR |
1028 | </p> |
1029 | <p>The reserved word <code>time</code> causes timing statistics | |
17345e5a JA |
1030 | to be printed for the pipeline once it finishes. |
1031 | The statistics currently consist of elapsed (wall-clock) time and | |
a0c0a00f CR |
1032 | user and system time consumed by the command’s execution. |
1033 | The <samp>-p</samp> option changes the output format to that specified | |
1034 | by <small>POSIX</small>. | |
1035 | When the shell is in <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>), | |
1036 | it does not recognize <code>time</code> as a reserved word if the next | |
1037 | token begins with a ‘<samp>-</samp>’. | |
1038 | The <code>TIMEFORMAT</code> variable may be set to a format string that | |
17345e5a | 1039 | specifies how the timing information should be displayed. |
a0c0a00f CR |
1040 | See <a href="#Bash-Variables">Bash Variables</a>, for a description of the available formats. |
1041 | The use of <code>time</code> as a reserved word permits the timing of | |
17345e5a | 1042 | shell 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 |
1046 | may be followed by a newline. In this case, the shell displays the |
1047 | total user and system time consumed by the shell and its children. | |
a0c0a00f | 1048 | The <code>TIMEFORMAT</code> variable may be used to specify the format of |
495aee44 | 1049 | the time information. |
a0c0a00f CR |
1050 | </p> |
1051 | <p>If the pipeline is not executed asynchronously (see <a href="#Lists">Lists</a>), the | |
17345e5a | 1052 | shell 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 |
1055 | separate process (see <a href="#Command-Execution-Environment">Command Execution Environment</a>). | |
1056 | If the <code>lastpipe</code> option is enabled using the <code>shopt</code> builtin | |
1057 | (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), | |
1058 | the last element of a pipeline may be run by the shell process. | |
1059 | </p> | |
1060 | <p>The exit | |
17345e5a | 1061 | status of a pipeline is the exit status of the last command in the |
a0c0a00f CR |
1062 | pipeline, unless the <code>pipefail</code> option is enabled |
1063 | (see <a href="#The-Set-Builtin">The Set Builtin</a>). | |
1064 | If <code>pipefail</code> is enabled, the pipeline’s return status is the | |
17345e5a JA |
1065 | value of the last (rightmost) command to exit with a non-zero status, |
1066 | or zero if all commands exit successfully. | |
a0c0a00f | 1067 | If the reserved word ‘<samp>!</samp>’ precedes the pipeline, the |
17345e5a JA |
1068 | exit status is the logical negation of the exit status as described |
1069 | above. | |
1070 | The shell waits for all commands in the pipeline to terminate before | |
1071 | returning a value. | |
a0c0a00f CR |
1072 | </p> |
1073 | <hr> | |
1074 | <a name="Lists"></a> | |
1075 | <div class="header"> | |
1076 | <p> | |
1077 | Next: <a href="#Compound-Commands" accesskey="n" rel="next">Compound Commands</a>, Previous: <a href="#Pipelines" accesskey="p" rel="prev">Pipelines</a>, Up: <a href="#Shell-Commands" accesskey="u" rel="up">Shell Commands</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> | |
1078 | </div> | |
1079 | <a name="Lists-of-Commands"></a> | |
1080 | <h4 class="subsection">3.2.3 Lists of Commands</h4> | |
1081 | <a name="index-commands_002c-lists"></a> | |
1082 | ||
1083 | <p>A <code>list</code> is a sequence of one or more pipelines separated by one | |
1084 | of the operators ‘<samp>;</samp>’, ‘<samp>&</samp>’, ‘<samp>&&</samp>’, or ‘<samp>||</samp>’, | |
1085 | and optionally terminated by one of ‘<samp>;</samp>’, ‘<samp>&</samp>’, or a | |
1086 | <code>newline</code>. | |
1087 | </p> | |
1088 | <p>Of these list operators, ‘<samp>&&</samp>’ and ‘<samp>||</samp>’ | |
1089 | have equal precedence, followed by ‘<samp>;</samp>’ and ‘<samp>&</samp>’, | |
17345e5a | 1090 | which have equal precedence. |
a0c0a00f CR |
1091 | </p> |
1092 | <p>A sequence of one or more newlines may appear in a <code>list</code> | |
17345e5a | 1093 | to delimit commands, equivalent to a semicolon. |
a0c0a00f CR |
1094 | </p> |
1095 | <p>If a command is terminated by the control operator ‘<samp>&</samp>’, | |
17345e5a | 1096 | the shell executes the command asynchronously in a subshell. |
a0c0a00f | 1097 | This is known as executing the command in the <var>background</var>. |
17345e5a JA |
1098 | The shell does not wait for the command to finish, and the return |
1099 | status is 0 (true). | |
a0c0a00f | 1100 | When job control is not active (see <a href="#Job-Control">Job Control</a>), |
17345e5a | 1101 | the standard input for asynchronous commands, in the absence of any |
a0c0a00f CR |
1102 | explicit redirections, is redirected from <code>/dev/null</code>. |
1103 | </p> | |
1104 | <p>Commands separated by a ‘<samp>;</samp>’ are executed sequentially; the shell | |
17345e5a JA |
1105 | waits for each command to terminate in turn. The return status is the |
1106 | exit 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 | |
1109 | separated by the control operators ‘<samp>&&</samp>’ and ‘<samp>||</samp>’, | |
1110 | respectively. <small>AND</small> and <small>OR</small> lists are executed with left | |
17345e5a | 1111 | associativity. |
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> && <var>command2</var> | |
1116 | </pre></div> | |
17345e5a | 1117 | |
a0c0a00f | 1118 | <p><var>command2</var> is executed if, and only if, <var>command1</var> |
9a51695b | 1119 | returns 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 | 1127 | returns 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 | 1131 | executed in the list. |
a0c0a00f CR |
1132 | </p> |
1133 | <hr> | |
1134 | <a name="Compound-Commands"></a> | |
1135 | <div class="header"> | |
1136 | <p> | |
1137 | Next: <a href="#Coprocesses" accesskey="n" rel="next">Coprocesses</a>, Previous: <a href="#Lists" accesskey="p" rel="prev">Lists</a>, Up: <a href="#Shell-Commands" accesskey="u" rel="up">Shell Commands</a> [<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">• <a href="#Looping-Constructs" accesskey="1">Looping Constructs</a>:</td><td> </td><td align="left" valign="top">Shell commands for iterative action. | |
1145 | </td></tr> | |
1146 | <tr><td align="left" valign="top">• <a href="#Conditional-Constructs" accesskey="2">Conditional Constructs</a>:</td><td> </td><td align="left" valign="top">Shell commands for conditional execution. | |
1147 | </td></tr> | |
1148 | <tr><td align="left" valign="top">• <a href="#Command-Grouping" accesskey="3">Command Grouping</a>:</td><td> </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 |
1153 | Each construct begins with a reserved word or control operator and is |
1154 | terminated by a corresponding reserved word or operator. | |
a0c0a00f | 1155 | Any redirections (see <a href="#Redirections">Redirections</a>) associated with a compound command |
17345e5a | 1156 | apply 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’s description may be | |
ac50fbac CR |
1159 | separated from the rest of the command by one or more newlines, and may be |
1160 | followed by a newline in place of a semicolon. | |
a0c0a00f CR |
1161 | </p> |
1162 | <p>Bash provides looping constructs, conditional commands, and mechanisms | |
17345e5a | 1163 | to 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> | |
1169 | Next: <a href="#Conditional-Constructs" accesskey="n" rel="next">Conditional Constructs</a>, Up: <a href="#Compound-Commands" accesskey="u" rel="up">Compound Commands</a> [<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 ‘<samp>;</samp>’ appears in the description of a | |
1178 | command’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 | 1193 | The return status is the exit status of the last command executed |
a0c0a00f CR |
1194 | in <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 | 1207 | The return status is the exit status of the last command executed |
a0c0a00f CR |
1208 | in <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> …] ] ; ] 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> |
1220 | once for each member | |
a0c0a00f CR |
1221 | in the resultant list, with <var>name</var> bound to the current member. |
1222 | If ‘<samp>in <var>words</var></samp>’ is not present, the <code>for</code> command | |
1223 | executes the <var>commands</var> once for each positional parameter that is | |
1224 | set, as if ‘<samp>in "$@"</samp>’ 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 | 1228 | If there are no items in the expansion of <var>words</var>, no commands are |
17345e5a | 1229 | executed, 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 | |
1238 | to the rules described below (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>). | |
1239 | The arithmetic expression <var>expr2</var> is then evaluated repeatedly | |
17345e5a | 1240 | until it evaluates to zero. |
a0c0a00f CR |
1241 | Each time <var>expr2</var> evaluates to a non-zero value, <var>commands</var> are |
1242 | executed and the arithmetic expression <var>expr3</var> is evaluated. | |
17345e5a | 1243 | If any expression is omitted, it behaves as if it evaluates to 1. |
a0c0a00f | 1244 | The return value is the exit status of the last command in <var>commands</var> |
17345e5a | 1245 | that 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 | 1250 | may be used to control loop execution. |
a0c0a00f CR |
1251 | </p> |
1252 | <hr> | |
1253 | <a name="Conditional-Constructs"></a> | |
1254 | <div class="header"> | |
1255 | <p> | |
1256 | Next: <a href="#Command-Grouping" accesskey="n" rel="next">Command Grouping</a>, Previous: <a href="#Looping-Constructs" accesskey="p" rel="prev">Looping Constructs</a>, Up: <a href="#Compound-Commands" accesskey="u" rel="up">Compound Commands</a> [<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 | 1277 | fi |
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, |
1281 | the <var>consequent-commands</var> list is executed. | |
1282 | If <var>test-commands</var> returns a non-zero status, each <code>elif</code> list | |
17345e5a | 1283 | is executed in turn, and if its exit status is zero, |
a0c0a00f | 1284 | the corresponding <var>more-consequents</var> is executed and the |
17345e5a | 1285 | command completes. |
a0c0a00f CR |
1286 | If ‘<samp>else <var>alternate-consequents</var></samp>’ is present, and |
1287 | the final command in the final <code>if</code> or <code>elif</code> clause | |
1288 | has a non-zero exit status, then <var>alternate-consequents</var> is executed. | |
17345e5a JA |
1289 | The return status is the exit status of the last command executed, or |
1290 | zero 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>]…) <var>command-list</var> ;;]… | |
1302 | esac | |
a0c0a00f CR |
1303 | </pre></div> |
1304 | ||
1305 | <p><code>case</code> will selectively execute the <var>command-list</var> corresponding to | |
1306 | the first <var>pattern</var> that matches <var>word</var>. | |
9a51695b CR |
1307 | The match is performed according |
1308 | to the rules described below in <a href="#Pattern-Matching">Pattern Matching</a>. | |
a0c0a00f CR |
1309 | If 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 |
1311 | is enabled, the match is performed without regard to the case |
1312 | of alphabetic characters. | |
a0c0a00f | 1313 | The ‘<samp>|</samp>’ is used to separate multiple patterns, and the ‘<samp>)</samp>’ |
17345e5a JA |
1314 | operator terminates a pattern list. |
1315 | A list of patterns and an associated command-list is known | |
a0c0a00f CR |
1316 | as a <var>clause</var>. |
1317 | </p> | |
1318 | <p>Each clause must be terminated with ‘<samp>;;</samp>’, ‘<samp>;&</samp>’, or ‘<samp>;;&</samp>’. | |
1319 | The <var>word</var> undergoes tilde expansion, parameter expansion, command | |
9a51695b CR |
1320 | substitution, arithmetic expansion, and quote removal |
1321 | (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>) | |
1322 | before matching is | |
a0c0a00f | 1323 | attempted. Each <var>pattern</var> undergoes tilde expansion, parameter |
17345e5a | 1324 | expansion, command substitution, and arithmetic expansion. |
a0c0a00f CR |
1325 | </p> |
1326 | <p>There may be an arbitrary number of <code>case</code> clauses, each terminated | |
1327 | by a ‘<samp>;;</samp>’, ‘<samp>;&</samp>’, or ‘<samp>;;&</samp>’. | |
17345e5a JA |
1328 | The first pattern that matches determines the |
1329 | command-list that is executed. | |
a0c0a00f | 1330 | It’s a common idiom to use ‘<samp>*</samp>’ as the final pattern to define the |
ac50fbac | 1331 | default 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 | 1334 | describe one interesting feature of an animal: |
a0c0a00f CR |
1335 | </p> |
1336 | <div class="example"> | |
1337 | <pre class="example">echo -n "Enter the name of an animal: " | |
17345e5a | 1338 | read ANIMAL |
a0c0a00f | 1339 | echo -n "The $ANIMAL has " |
17345e5a | 1340 | case $ANIMAL in |
a0c0a00f CR |
1341 | horse | dog | cat) echo -n "four";; |
1342 | man | kangaroo ) echo -n "two";; | |
1343 | *) echo -n "an unknown number of";; | |
17345e5a | 1344 | esac |
a0c0a00f CR |
1345 | echo " legs." |
1346 | </pre></div> | |
17345e5a | 1347 | |
17345e5a | 1348 | |
a0c0a00f | 1349 | <p>If the ‘<samp>;;</samp>’ operator is used, no subsequent matches are attempted after |
17345e5a | 1350 | the first pattern match. |
a0c0a00f CR |
1351 | Using ‘<samp>;&</samp>’ in place of ‘<samp>;;</samp>’ causes execution to continue with |
1352 | the <var>command-list</var> associated with the next clause, if any. | |
1353 | Using ‘<samp>;;&</samp>’ in place of ‘<samp>;;</samp>’ causes the shell to test the patterns | |
1354 | in the next clause, if any, and execute any associated <var>command-list</var> | |
17345e5a | 1355 | on a successful match. |
a0c0a00f CR |
1356 | </p> |
1357 | <p>The return status is zero if no <var>pattern</var> is matched. Otherwise, the | |
1358 | return 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. | |
1365 | It 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> …]; 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 |
1372 | of items. The set of expanded words is printed on the standard |
1373 | error output stream, each preceded by a number. If the | |
a0c0a00f CR |
1374 | ‘<samp>in <var>words</var></samp>’ is omitted, the positional parameters are printed, |
1375 | as if ‘<samp>in "$@"</samp>’ had been specified. | |
1376 | The <code>PS3</code> prompt is then displayed and a line is read from the | |
17345e5a JA |
1377 | standard input. |
1378 | If the line consists of a number corresponding to one of the displayed | |
a0c0a00f | 1379 | words, then the value of <var>name</var> is set to that word. |
17345e5a | 1380 | If the line is empty, the words and prompt are displayed again. |
a0c0a00f CR |
1381 | If <code>EOF</code> is read, the <code>select</code> command completes. |
1382 | Any other value read causes <var>name</var> to be set to null. | |
1383 | The 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 | |
1387 | point 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 |
1390 | current directory, and displays the name and index of the file |
1391 | selected. | |
a0c0a00f CR |
1392 | </p> |
1393 | <div class="example"> | |
1394 | <pre class="example">select fname in *; | |
17345e5a JA |
1395 | do |
1396 | echo you picked $fname \($REPLY\) | |
1397 | break; | |
1398 | done | |
a0c0a00f | 1399 | </pre></div> |
17345e5a | 1400 | |
a0c0a00f CR |
1401 | </dd> |
1402 | <dt><code>((…))</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 |
1408 | described below (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>). | |
17345e5a JA |
1409 | If the value of the expression is non-zero, the return status is 0; |
1410 | otherwise the return status is 1. This is exactly equivalent to | |
a0c0a00f CR |
1411 | </p><div class="example"> |
1412 | <pre class="example">let "<var>expression</var>" | |
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>[[…]]</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 | |
1425 | the conditional expression <var>expression</var>. | |
17345e5a | 1426 | Expressions are composed of the primaries described below in |
a0c0a00f | 1427 | <a href="#Bash-Conditional-Expressions">Bash Conditional Expressions</a>. |
17345e5a | 1428 | Word splitting and filename expansion are not performed on the words |
a0c0a00f | 1429 | between the <code>[[</code> and <code>]]</code>; tilde expansion, parameter and |
17345e5a JA |
1430 | variable expansion, arithmetic expansion, command substitution, process |
1431 | substitution, and quote removal are performed. | |
a0c0a00f | 1432 | Conditional operators such as ‘<samp>-f</samp>’ must be unquoted to be recognized |
17345e5a | 1433 | as primaries. |
a0c0a00f CR |
1434 | </p> |
1435 | <p>When used with <code>[[</code>, the ‘<samp><</samp>’ and ‘<samp>></samp>’ operators sort | |
0001803f | 1436 | lexicographically using the current locale. |
a0c0a00f CR |
1437 | </p> |
1438 | <p>When the ‘<samp>==</samp>’ and ‘<samp>!=</samp>’ operators are used, the string to the | |
17345e5a | 1439 | right of the operator is considered a pattern and matched according |
a0c0a00f CR |
1440 | to the rules described below in <a href="#Pattern-Matching">Pattern Matching</a>, |
1441 | as if the <code>extglob</code> shell option were enabled. | |
1442 | The ‘<samp>=</samp>’ operator is identical to ‘<samp>==</samp>’. | |
1443 | If 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 |
1445 | is enabled, the match is performed without regard to the case |
1446 | of alphabetic characters. | |
a0c0a00f | 1447 | The return value is 0 if the string matches (‘<samp>==</samp>’) or does not |
2f5dfe5a | 1448 | match (‘<samp>!=</samp>’) the pattern, and 1 otherwise. |
ac50fbac CR |
1449 | Any part of the pattern may be quoted to force the quoted portion |
1450 | to be matched as a string. | |
a0c0a00f CR |
1451 | </p> |
1452 | <p>An additional binary operator, ‘<samp>=~</samp>’, is available, with the same | |
1453 | precedence as ‘<samp>==</samp>’ and ‘<samp>!=</samp>’. | |
17345e5a | 1454 | When it is used, the string to the right of the operator is considered |
2f5dfe5a CR |
1455 | a <small>POSIX</small> extended regular expression and matched accordingly |
1456 | (as in <i>regex</i>3)). | |
17345e5a JA |
1457 | The return value is 0 if the string matches |
1458 | the pattern, and 1 otherwise. | |
1459 | If the regular expression is syntactically incorrect, the conditional | |
a0c0a00f CR |
1460 | expression’s return value is 2. |
1461 | If 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 |
1463 | is enabled, the match is performed without regard to the case |
1464 | of alphabetic characters. | |
ac50fbac CR |
1465 | Any part of the pattern may be quoted to force the quoted portion |
1466 | to be matched as a string. | |
1467 | Bracket expressions in regular expressions must be treated carefully, | |
1468 | since normal quoting characters lose their meanings between brackets. | |
1469 | If the pattern is stored in a shell variable, quoting the variable | |
1470 | expansion forces the entire pattern to be matched as a string. | |
17345e5a | 1471 | Substrings matched by parenthesized subexpressions within the regular |
a0c0a00f CR |
1472 | expression are saved in the array variable <code>BASH_REMATCH</code>. |
1473 | The element of <code>BASH_REMATCH</code> with index 0 is the portion of the string | |
17345e5a | 1474 | matching the entire regular expression. |
a0c0a00f CR |
1475 | The element of <code>BASH_REMATCH</code> with index <var>n</var> is the portion of the |
1476 | string 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 |
1480 | if there is a sequence of characters in the value consisting of |
1481 | any number, including zero, of | |
a0c0a00f CR |
1482 | space characters, zero or one instances of ‘<samp>a</samp>’, then a ‘<samp>b</samp>’: |
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 ‘<samp>aab</samp>’ and ‘<samp> aaaaaab</samp>’ will match, as | |
1488 | will a line containing a ‘<samp>b</samp>’ anywhere in its value. | |
1489 | </p> | |
1490 | <p>Storing the regular expression in a shell variable is often a useful | |
ac50fbac CR |
1491 | way to avoid problems with quoting characters that are special to the |
1492 | shell. | |
1493 | It is sometimes difficult to specify a regular expression literally | |
1494 | without using quotes, or to keep track of the quoting used by regular | |
a0c0a00f | 1495 | expressions while paying attention to the shell’s quote removal. |
ac50fbac CR |
1496 | Using a shell variable to store the pattern decreases these problems. |
1497 | For 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’s special to the regular expression |
ac50fbac | 1504 | grammar, it has to be quoted to remove its special meaning. |
a0c0a00f | 1505 | This means that in the pattern ‘<samp>xxx.txt</samp>’, the ‘<samp>.</samp>’ matches any |
ac50fbac | 1506 | character in the string (its usual regular expression meaning), but in the |
a0c0a00f | 1507 | pattern ‘<samp>"xxx.txt"</samp>’ it can only match a literal ‘<samp>.</samp>’. |
ac50fbac CR |
1508 | Shell programmers should take special care with backslashes, since backslashes |
1509 | are used both by the shell and regular expressions to remove the special | |
1510 | meaning from the following character. | |
a0c0a00f CR |
1511 | The 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 | [[ . =~ "$pattern" ]] |
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 |
1523 | in the second two the backslash will be part of the pattern to be matched. |
1524 | In the first two examples, the backslash removes the special meaning from | |
a0c0a00f CR |
1525 | ‘<samp>.</samp>’, so the literal ‘<samp>.</samp>’ matches. |
1526 | If the string in the first examples were anything other than ‘<samp>.</samp>’, say | |
1527 | ‘<samp>a</samp>’, the pattern would not match, because the quoted ‘<samp>.</samp>’ in the | |
ac50fbac | 1528 | pattern 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 | 1531 | in 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 | 1536 | This 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> && <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>&&</code> and <code>||</code> operators do not evaluate <var>expression2</var> if the | |
1553 | value of <var>expression1</var> is sufficient to determine the return | |
17345e5a | 1554 | value 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> | |
1562 | Previous: <a href="#Conditional-Constructs" accesskey="p" rel="prev">Conditional Constructs</a>, Up: <a href="#Compound-Commands" accesskey="u" rel="up">Compound Commands</a> [<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 |
1569 | as a unit. When commands are grouped, redirections may be applied |
1570 | to the entire command list. For example, the output of all the | |
1571 | commands 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 | |
1580 | environment to be created (see <a href="#Command-Execution-Environment">Command Execution Environment</a>), and each | |
1581 | of 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 | 1583 | effect 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 | 1594 | be executed in the current shell context. No subshell is created. |
a0c0a00f CR |
1595 | The 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 | 1600 | between these two constructs due to historical reasons. The braces |
a0c0a00f CR |
1601 | are <code>reserved words</code>, so they must be separated from the <var>list</var> |
1602 | by <code>blank</code>s or other shell metacharacters. | |
1603 | The parentheses are <code>operators</code>, and are | |
17345e5a | 1604 | recognized as separate tokens by the shell even if they are not separated |
a0c0a00f CR |
1605 | from 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> | |
1614 | Next: <a href="#GNU-Parallel" accesskey="n" rel="next">GNU Parallel</a>, Previous: <a href="#Compound-Commands" accesskey="p" rel="prev">Compound Commands</a>, Up: <a href="#Shell-Commands" accesskey="u" rel="up">Shell Commands</a> [<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 |
1621 | reserved word. |
1622 | A coprocess is executed asynchronously in a subshell, as if the command | |
a0c0a00f | 1623 | had been terminated with the ‘<samp>&</samp>’ control operator, with a two-way pipe |
17345e5a | 1624 | established 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>. | |
1632 | If <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 | |
1634 | command (see <a href="#Simple-Commands">Simple Commands</a>); otherwise, it is interpreted as | |
17345e5a | 1635 | the 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>) | |
1639 | named <code>NAME</code> in the context of the executing shell. | |
1640 | The standard output of <var>command</var> | |
17345e5a | 1641 | is connected via a pipe to a file descriptor in the executing shell, |
a0c0a00f CR |
1642 | and that file descriptor is assigned to <code>NAME</code>[0]. |
1643 | The standard input of <var>command</var> | |
17345e5a | 1644 | is connected via a pipe to a file descriptor in the executing shell, |
a0c0a00f | 1645 | and that file descriptor is assigned to <code>NAME</code>[1]. |
17345e5a | 1646 | This pipe is established before any redirections specified by the |
a0c0a00f | 1647 | command (see <a href="#Redirections">Redirections</a>). |
17345e5a JA |
1648 | The file descriptors can be utilized as arguments to shell commands |
1649 | and redirections using standard word expansions. | |
9a51695b CR |
1650 | Other than those created to execute command and process substitutions, |
1651 | the 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 | |
1654 | available as the value of the variable <code>NAME</code>_PID. | |
1655 | The <code>wait</code> | |
17345e5a | 1656 | builtin 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, | |
1659 | the <code>coproc</code> command always returns success. | |
1660 | The 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> | |
1666 | Previous: <a href="#Coprocesses" accesskey="p" rel="prev">Coprocesses</a>, Up: <a href="#Shell-Commands" accesskey="u" rel="up">Shell Commands</a> [<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 | 1672 | GNU 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 | 1675 | in parallel. You may run the same command with different arguments, whether |
ac50fbac CR |
1676 | they are filenames, usernames, hostnames, or lines read from files. GNU |
1677 | Parallel provides shorthand references to many of the most common operations | |
1678 | (input lines, various portions of the input line, different ways to specify | |
a0c0a00f | 1679 | the input source, and so on). Parallel can replace <code>xargs</code> or feed |
ac50fbac | 1680 | commands 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 | 1683 | examples 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 | 1686 | current 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, | |
1691 | use find’s <samp>-print0</samp> option and parallel’s <samp>-0</samp> option. | |
1692 | </p> | |
1693 | <p>You can use Parallel to move files from the current directory when the | |
1694 | number 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. | |
1700 | While using <code>ls</code> will work in most instances, it is not sufficient to | |
ac50fbac CR |
1701 | deal with all filenames. |
1702 | If 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 | 1711 | directory. |
a0c0a00f CR |
1712 | You 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 | 1718 | from 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 "$x" "config-$x" | |
1722 | do-something2 < "$x" | |
1723 | done < 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 "do-something1 {} config-{} ; do-something2 < {}" | |
1729 | process-output | |
a0c0a00f CR |
1730 | </pre></div> |
1731 | ||
1732 | <p>Parallel provides a built-in mechanism to remove filename extensions, which | |
495aee44 | 1733 | lends itself to batch file transformations or renaming: |
a0c0a00f CR |
1734 | </p><div class="example"> |
1735 | <pre class="example">ls *.gz | parallel -j+0 "zcat {} | bzip2 >{.}.bz2 && rm {}" | |
1736 | </pre></div> | |
1737 | <p>This will recompress all files in the current directory with names ending | |
ac50fbac | 1738 | in .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 |
1740 | robust in the face of filenames containing unexpected characters.) |
1741 | Parallel can take arguments from the command line; the above can also be | |
1742 | written as | |
a0c0a00f CR |
1743 | </p> |
1744 | <div class="example"> | |
1745 | <pre class="example">parallel "zcat {} | bzip2 >{.}.bz2 && rm {}" ::: *.gz | |
1746 | </pre></div> | |
495aee44 | 1747 | |
a0c0a00f | 1748 | <p>If a command generates output, you may want to preserve the input order in |
495aee44 | 1749 | the 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. | |
1758 | Adding 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, | |
1769 | similar to ‘<samp>cat file | bash</samp>’. | |
ac50fbac | 1770 | It is not uncommon to take a list of filenames, create a series of shell |
9a51695b | 1771 | commands to operate on them, and feed that list of commands to a shell. |
a0c0a00f | 1772 | Parallel can speed this up. Assuming that <samp>file</samp> contains a list of |
ac50fbac | 1773 | shell commands, one per line, |
a0c0a00f CR |
1774 | </p> |
1775 | <div class="example"> | |
1776 | <pre class="example">parallel -j 10 < file | |
1777 | </pre></div> | |
ac50fbac | 1778 | |
a0c0a00f | 1779 | <p>will evaluate the commands using the shell (since no explicit command is |
ac50fbac | 1780 | supplied 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> | |
1786 | Next: <a href="#Shell-Parameters" accesskey="n" rel="next">Shell Parameters</a>, Previous: <a href="#Shell-Commands" accesskey="p" rel="prev">Shell Commands</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> [<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 | 1794 | using a single name for the group. They are executed just like |
a0c0a00f | 1795 | a "regular" command. |
17345e5a JA |
1796 | When the name of a shell function is used as a simple command name, |
1797 | the list of commands associated with that function name is executed. | |
1798 | Shell functions are executed in the current | |
1799 | shell 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 | |
1814 | word <code>function</code> is optional. | |
1815 | If the <code>function</code> reserved | |
17345e5a | 1816 | word is supplied, the parentheses are optional. |
a0c0a00f CR |
1817 | The <var>body</var> of the function is the compound command |
1818 | <var>compound-command</var> (see <a href="#Compound-Commands">Compound Commands</a>). | |
1819 | That command is usually a <var>list</var> enclosed between { and }, but | |
1820 | may be any compound command listed above, | |
1821 | with one exception: If the <code>function</code> reserved word is used, but the | |
1822 | parentheses are not supplied, the braces are required. | |
1823 | <var>compound-command</var> is executed whenever <var>name</var> is specified as the | |
17345e5a | 1824 | name of a command. |
a0c0a00f CR |
1825 | When 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>). | |
1828 | Any redirections (see <a href="#Redirections">Redirections</a>) associated with the shell function | |
17345e5a | 1829 | are 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 |
1835 | occurs or a readonly function with the same name already exists. |
1836 | When executed, the exit status of a function is the exit status of the | |
1837 | last 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 | 1840 | that surround the body of the function must be separated from the body by |
a0c0a00f | 1841 | <code>blank</code>s or newlines. |
17345e5a JA |
1842 | This is because the braces are reserved words and are only recognized |
1843 | as such when they are separated from the command list | |
1844 | by whitespace or another shell metacharacter. | |
a0c0a00f CR |
1845 | Also, when using the braces, the <var>list</var> must be terminated by a semicolon, |
1846 | a ‘<samp>&</samp>’, or a newline. | |
1847 | </p> | |
1848 | <p>When a function is executed, the arguments to the | |
17345e5a | 1849 | function become the positional parameters |
a0c0a00f CR |
1850 | during its execution (see <a href="#Positional-Parameters">Positional Parameters</a>). |
1851 | The special parameter ‘<samp>#</samp>’ that expands to the number of | |
17345e5a | 1852 | positional parameters is updated to reflect the change. |
a0c0a00f CR |
1853 | Special parameter <code>0</code> is unchanged. |
1854 | The first element of the <code>FUNCNAME</code> variable is set to the | |
17345e5a | 1855 | name of the function while the function is executing. |
a0c0a00f CR |
1856 | </p> |
1857 | <p>All other aspects of the shell execution | |
17345e5a | 1858 | environment are identical between a function and its caller |
0001803f | 1859 | with these exceptions: |
a0c0a00f | 1860 | the <code>DEBUG</code> and <code>RETURN</code> traps |
17345e5a | 1861 | are not inherited unless the function has been given the |
a0c0a00f CR |
1862 | <code>trace</code> attribute using the <code>declare</code> builtin or |
1863 | the <code>-o functrace</code> option has been enabled with | |
1864 | the <code>set</code> builtin, | |
1865 | (in which case all functions inherit the <code>DEBUG</code> and <code>RETURN</code> traps), | |
1866 | and the <code>ERR</code> trap is not inherited unless the <code>-o errtrace</code> | |
0001803f | 1867 | shell option has been enabled. |
a0c0a00f CR |
1868 | See <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 |
1872 | than 0, defines a maximum function nesting level. Function |
1873 | invocations that exceed the limit cause the entire command to | |
1874 | abort. | |
a0c0a00f CR |
1875 | </p> |
1876 | <p>If the builtin command <code>return</code> | |
17345e5a JA |
1877 | is executed in a function, the function completes and |
1878 | execution resumes with the next command after the function | |
1879 | call. | |
a0c0a00f | 1880 | Any command associated with the <code>RETURN</code> trap is executed |
17345e5a JA |
1881 | before execution resumes. |
1882 | When a function completes, the values of the | |
a0c0a00f CR |
1883 | positional parameters and the special parameter ‘<samp>#</samp>’ |
1884 | are restored to the values they had prior to the function’s | |
1885 | execution. If a numeric argument is given to <code>return</code>, | |
1886 | that is the function’s return status; otherwise the function’s | |
17345e5a | 1887 | return status is the exit status of the last command executed |
a0c0a00f CR |
1888 | before 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 |
1892 | the function and the commands it invokes. This is particularly |
1893 | important when a shell function calls other functions. | |
1894 | </p> | |
1895 | <p>Local variables "shadow" variables with the same name declared at | |
1896 | previous scopes. For instance, a local variable declared in a function | |
1897 | hides a global variable of the same name: references and assignments | |
1898 | refer to the local variable, leaving the global variable unmodified. | |
1899 | When 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’s visibility | |
1902 | within functions. | |
1903 | With dynamic scoping, visible variables and their values | |
1904 | are a result of the sequence of function calls that caused execution | |
1905 | to reach the current function. | |
1906 | The value of a variable that a function sees depends | |
1907 | on its value within its caller, if any, whether that caller is | |
1908 | the "global" scope or another shell function. | |
1909 | This is also the value that a local variable | |
1910 | declaration "shadows", and the value that is restored when the function | |
1911 | returns. | |
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>, | |
1915 | references to <var>var</var> made from within <var>func2</var> will resolve to the | |
1916 | local variable <var>var</var> from <var>func1</var>, shadowing any global variable | |
1917 | named <var>var</var>. | |
1918 | </p> | |
1919 | <p>The following script demonstrates this behavior. | |
1920 | When 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 | ||
1933 | func2() | |
1934 | { | |
1935 | echo "In func2, var = $var" | |
1936 | } | |
1937 | ||
1938 | var=global | |
1939 | func1 | |
1940 | </pre></div> | |
1941 | ||
1942 | <p>The <code>unset</code> builtin also acts using the same dynamic scope: if a | |
1943 | variable is local to the current scope, <code>unset</code> will unset it; | |
1944 | otherwise the unset will refer to the variable found in any calling scope | |
1945 | as described above. | |
1946 | If a variable at the current local scope is unset, it will remain so | |
1947 | until it is reset in that scope or until the function returns. | |
1948 | Once the function returns, any instance of the variable at a previous | |
1949 | scope will become visible. | |
1950 | If the unset acts on a variable at a previous scope, any instance of a | |
1951 | variable 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>) | |
1955 | builtin command (see <a href="#Bash-Builtins">Bash Builtins</a>). | |
1956 | The <samp>-F</samp> option to <code>declare</code> or <code>typeset</code> | |
17345e5a | 1957 | will list the function names only |
a0c0a00f | 1958 | (and optionally the source file and line number, if the <code>extdebug</code> |
17345e5a JA |
1959 | shell option is enabled). |
1960 | Functions may be exported so that subshells | |
1961 | automatically 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. | |
1966 | The <code>FUNCNEST</code> variable may be used to limit the depth of the | |
495aee44 CR |
1967 | function call stack and restrict the number of function invocations. |
1968 | By 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> | |
1974 | Next: <a href="#Shell-Expansions" accesskey="n" rel="next">Shell Expansions</a>, Previous: <a href="#Shell-Functions" accesskey="p" rel="prev">Shell Functions</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> [<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">• <a href="#Positional-Parameters" accesskey="1">Positional Parameters</a>:</td><td> </td><td align="left" valign="top">The shell’s command-line arguments. | |
1984 | </td></tr> | |
1985 | <tr><td align="left" valign="top">• <a href="#Special-Parameters" accesskey="2">Special Parameters</a>:</td><td> </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. | |
1990 | It can be a <code>name</code>, a number, or one of the special characters | |
17345e5a | 1991 | listed below. |
a0c0a00f CR |
1992 | A <var>variable</var> is a parameter denoted by a <code>name</code>. |
1993 | A variable has a <var>value</var> and zero or more <var>attributes</var>. | |
1994 | Attributes 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 | 1998 | a valid value. Once a variable is set, it may be unset only by using |
a0c0a00f CR |
1999 | the <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 | 2006 | is not given, the variable is assigned the null string. All |
a0c0a00f | 2007 | <var>value</var>s undergo tilde expansion, parameter and variable expansion, |
17345e5a | 2008 | command substitution, arithmetic expansion, and quote |
a0c0a00f CR |
2009 | removal (detailed below). If the variable has its <code>integer</code> |
2010 | attribute set, then <var>value</var> | |
2011 | is evaluated as an arithmetic expression even if the <code>$((…))</code> | |
2012 | expansion is not used (see <a href="#Arithmetic-Expansion">Arithmetic Expansion</a>). | |
17345e5a | 2013 | Word splitting is not performed, with the exception |
a0c0a00f | 2014 | of <code>"$@"</code> as explained below. |
17345e5a JA |
2015 | Filename expansion is not performed. |
2016 | Assignment 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>, | |
2019 | and <code>local</code> builtin commands (<var>declaration</var> commands). | |
2020 | When in <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>), these builtins may appear | |
2021 | in a command after one or more instances of the <code>command</code> builtin | |
ac50fbac | 2022 | and retain these assignment statement properties. |
a0c0a00f CR |
2023 | </p> |
2024 | <p>In the context where an assignment statement is assigning a value | |
2025 | to a shell variable or array index (see <a href="#Arrays">Arrays</a>), the ‘<samp>+=</samp>’ | |
17345e5a | 2026 | operator can be used to |
a0c0a00f CR |
2027 | append to or add to the variable’s previous value. |
2028 | This includes arguments to builtin commands such as <code>declare</code> that | |
2029 | accept assignment statements (<var>declaration</var> commands). | |
2030 | When ‘<samp>+=</samp>’ is applied to a variable for which the <var>integer</var> attribute | |
2031 | has been set, <var>value</var> is evaluated as an arithmetic expression and | |
2032 | added to the variable’s current value, which is also evaluated. | |
2033 | When ‘<samp>+=</samp>’ is applied to an array variable using compound assignment | |
2034 | (see <a href="#Arrays">Arrays</a>), the | |
2035 | variable’s value is not unset (as it is when using ‘<samp>=</samp>’), and new | |
2036 | values are appended to the array beginning at one greater than the array’s | |
17345e5a JA |
2037 | maximum index (for indexed arrays), or added as additional key-value pairs |
2038 | in an associative array. | |
a0c0a00f CR |
2039 | When applied to a string-valued variable, <var>value</var> is expanded and |
2040 | appended to the variable’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>) | |
2045 | to create a <var>nameref</var>, or a reference to another variable. | |
ac50fbac | 2046 | This allows variables to be manipulated indirectly. |
a0c0a00f CR |
2047 | Whenever the nameref variable is referenced, assigned to, unset, or has |
2048 | its attributes modified (other than using or changing the nameref | |
2049 | attribute itself), the | |
2050 | operation is actually performed on the variable specified by the nameref | |
2051 | variable’s value. | |
ac50fbac CR |
2052 | A nameref is commonly used within shell functions to refer to a variable |
2053 | whose name is passed as an argument to the function. | |
2054 | For instance, if a variable name is passed to a shell function as its first | |
2055 | argument, 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 | 2060 | the variable name passed as the first argument. |
a0c0a00f CR |
2061 | References and assignments to <var>ref</var>, and changes to its attributes, |
2062 | are treated as references, assignments, and attribute modifications | |
2063 | to 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 |
2066 | the list of words can be a list of shell variables, and a name reference |
2067 | will be established for each word in the list, in turn, when the loop is | |
2068 | executed. | |
a0c0a00f | 2069 | Array variables cannot be given the nameref attribute. |
ac50fbac CR |
2070 | However, nameref variables can reference array variables and subscripted |
2071 | array variables. | |
a0c0a00f CR |
2072 | Namerefs 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>). | |
2074 | Otherwise, if <code>unset</code> is executed with the name of a nameref variable | |
ac50fbac | 2075 | as 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> | |
2081 | Next: <a href="#Special-Parameters" accesskey="n" rel="next">Special Parameters</a>, Up: <a href="#Shell-Parameters" accesskey="u" rel="up">Shell Parameters</a> [<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 | |
2088 | digits, other than the single digit <code>0</code>. Positional parameters are | |
2089 | assigned from the shell’s arguments when it is invoked, | |
2090 | and may be reassigned using the <code>set</code> builtin command. | |
2091 | Positional parameter <code>N</code> may be referenced as <code>${N}</code>, or | |
2092 | as <code>$N</code> when <code>N</code> consists of a single digit. | |
17345e5a | 2093 | Positional parameters may not be assigned to with assignment statements. |
a0c0a00f CR |
2094 | The <code>set</code> and <code>shift</code> builtins are used to set and |
2095 | unset them (see <a href="#Shell-Builtin-Commands">Shell Builtin Commands</a>). | |
17345e5a JA |
2096 | The positional parameters are |
2097 | temporarily 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 | 2101 | digit 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> | |
2107 | Previous: <a href="#Positional-Parameters" accesskey="p" rel="prev">Positional Parameters</a>, Up: <a href="#Shell-Parameters" accesskey="u" rel="up">Shell Parameters</a> [<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 | 2114 | only 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 |
2122 | When the expansion is not within double quotes, each positional parameter |
2123 | expands to a separate word. | |
2124 | In contexts where it is performed, those words | |
2125 | are subject to further word splitting and pathname expansion. | |
2126 | When the expansion occurs within double quotes, it expands to a single word | |
a0c0a00f CR |
2127 | with the value of each parameter separated by the first character of the |
2128 | <code>IFS</code> special variable. That is, <code>"$*"</code> is equivalent | |
2129 | to <code>"$1<var>c</var>$2<var>c</var>…"</code>, where <var>c</var> | |
2130 | is the first character of the value of the <code>IFS</code> | |
17345e5a | 2131 | variable. |
a0c0a00f CR |
2132 | If <code>IFS</code> is unset, the parameters are separated by spaces. |
2133 | If <code>IFS</code> is null, the parameters are joined without intervening | |
17345e5a | 2134 | separators. |
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. |
2142 | In contexts where word splitting is performed, this expands each | |
2143 | positional parameter to a separate word; if not within double | |
2144 | quotes, these words are subject to word splitting. | |
2145 | In contexts where word splitting is not performed, | |
2146 | this expands to a single word | |
2147 | with each positional parameter separated by a space. | |
2148 | When the | |
2149 | expansion occurs within double quotes, and word splitting is performed, | |
2150 | each parameter expands to a | |
a0c0a00f CR |
2151 | separate word. That is, <code>"$@"</code> is equivalent to |
2152 | <code>"$1" "$2" …</code>. | |
17345e5a JA |
2153 | If the double-quoted expansion occurs within a word, the expansion of |
2154 | the first parameter is joined with the beginning part of the original | |
2155 | word, and the expansion of the last parameter is joined with the last | |
2156 | part of the original word. | |
a0c0a00f CR |
2157 | When there are no positional parameters, <code>"$@"</code> and |
2158 | <code>$@</code> | |
17345e5a | 2159 | expand 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 | 2174 | pipeline. |
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 | |
2182 | invocation, by the <code>set</code> | |
17345e5a | 2183 | builtin 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 | |
2192 | expands 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 | 2200 | background, whether executed as an asynchronous command or using |
a0c0a00f CR |
2201 | the <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 | 2209 | shell 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. |
2211 | If Bash is started with the <samp>-c</samp> option (see <a href="#Invoking-Bash">Invoking Bash</a>), | |
2212 | then <code>$0</code> is set to the first argument after the string to be | |
17345e5a JA |
2213 | executed, if one is present. Otherwise, it is set |
2214 | to 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 |
2222 | At shell startup, set to the absolute pathname used to invoke the |
2223 | shell or shell script being executed as passed in the environment | |
2224 | or argument list. | |
2225 | Subsequently, expands to the last argument to the previous command, | |
2226 | after expansion. | |
2227 | Also set to the full pathname used to invoke each command executed | |
2228 | and placed in the environment exported to that command. | |
2229 | When 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> | |
2237 | Next: <a href="#Redirections" accesskey="n" rel="next">Redirections</a>, Previous: <a href="#Shell-Parameters" accesskey="p" rel="prev">Shell Parameters</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> [<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">• <a href="#Brace-Expansion" accesskey="1">Brace Expansion</a>:</td><td> </td><td align="left" valign="top">Expansion of expressions within braces. | |
2258 | </td></tr> | |
2259 | <tr><td align="left" valign="top">• <a href="#Tilde-Expansion" accesskey="2">Tilde Expansion</a>:</td><td> </td><td align="left" valign="top">Expansion of the ~ character. | |
2260 | </td></tr> | |
2261 | <tr><td align="left" valign="top">• <a href="#Shell-Parameter-Expansion" accesskey="3">Shell Parameter Expansion</a>:</td><td> </td><td align="left" valign="top">How Bash expands variables to their values. | |
2262 | </td></tr> | |
2263 | <tr><td align="left" valign="top">• <a href="#Command-Substitution" accesskey="4">Command Substitution</a>:</td><td> </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">• <a href="#Arithmetic-Expansion" accesskey="5">Arithmetic Expansion</a>:</td><td> </td><td align="left" valign="top">How to use arithmetic in shell expansions. | |
2266 | </td></tr> | |
2267 | <tr><td align="left" valign="top">• <a href="#Process-Substitution" accesskey="6">Process Substitution</a>:</td><td> </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">• <a href="#Word-Splitting" accesskey="7">Word Splitting</a>:</td><td> </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">• <a href="#Filename-Expansion" accesskey="8">Filename Expansion</a>:</td><td> </td><td align="left" valign="top">A shorthand for specifying filenames matching patterns. | |
2274 | </td></tr> | |
2275 | <tr><td align="left" valign="top">• <a href="#Quote-Removal" accesskey="9">Quote Removal</a>:</td><td> </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 |
2281 | brace expansion; |
2282 | tilde expansion, parameter and variable expansion, arithmetic expansion, | |
2283 | and command substitution (done in a left-to-right fashion); | |
2284 | word splitting; | |
2285 | and filename expansion. | |
a0c0a00f CR |
2286 | </p> |
2287 | <p>On systems that can support it, there is an additional expansion | |
2288 | available: <var>process substitution</var>. | |
ac50fbac CR |
2289 | This is performed at the |
2290 | same time as tilde, parameter, variable, and arithmetic expansion and | |
17345e5a | 2291 | command substitution. |
a0c0a00f CR |
2292 | </p> |
2293 | <p>After these expansions are performed, quote characters present in the | |
2294 | original 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 | 2298 | can increase the number of words of the expansion; other expansions |
17345e5a JA |
2299 | expand a single word to a single word. |
2300 | The only exceptions to this are the expansions of | |
9a51695b CR |
2301 | <code>"$@"</code> and <code>$*</code> (see <a href="#Special-Parameters">Special Parameters</a>), and |
2302 | <code>"${<var>name</var>[@]}"</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 | 2306 | is performed. |
a0c0a00f CR |
2307 | </p> |
2308 | <hr> | |
2309 | <a name="Brace-Expansion"></a> | |
2310 | <div class="header"> | |
2311 | <p> | |
2312 | Next: <a href="#Tilde-Expansion" accesskey="n" rel="next">Tilde Expansion</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> [<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 | 2320 | This mechanism is similar to |
a0c0a00f | 2321 | <var>filename expansion</var> (see <a href="#Filename-Expansion">Filename Expansion</a>), |
ac50fbac | 2322 | but the filenames generated need not exist. |
a0c0a00f | 2323 | Patterns to be brace expanded take the form of an optional <var>preamble</var>, |
ac50fbac | 2324 | followed by either a series of comma-separated strings or a sequence expression |
17345e5a | 2325 | between a pair of braces, |
a0c0a00f | 2326 | followed by an optional <var>postscript</var>. |
17345e5a JA |
2327 | The preamble is prefixed to each string contained within the braces, and |
2328 | the postscript is then appended to each resulting string, expanding left | |
2329 | to right. | |
a0c0a00f CR |
2330 | </p> |
2331 | <p>Brace expansions may be nested. | |
17345e5a JA |
2332 | The results of each expanded string are not sorted; left to right order |
2333 | is preserved. | |
2334 | For example, | |
a0c0a00f CR |
2335 | </p><div class="example"> |
2336 | <pre class="example">bash$ echo a{d,c,b}e | |
17345e5a | 2337 | ade 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>, |
2341 | where <var>x</var> and <var>y</var> are either integers or single characters, | |
2342 | and <var>incr</var>, an optional increment, is an integer. | |
17345e5a | 2343 | When integers are supplied, the expression expands to each number between |
a0c0a00f CR |
2344 | <var>x</var> and <var>y</var>, inclusive. |
2345 | Supplied integers may be prefixed with ‘<samp>0</samp>’ to force each term to have the | |
ac50fbac | 2346 | same width. |
a0c0a00f | 2347 | When either <var>x</var> or <var>y</var> begins with a zero, the shell |
17345e5a JA |
2348 | attempts to force all generated terms to contain the same number of digits, |
2349 | zero-padding where necessary. | |
2350 | When characters are supplied, the expression expands to each character | |
a0c0a00f | 2351 | lexicographically between <var>x</var> and <var>y</var>, inclusive, |
ac50fbac | 2352 | using the default C locale. |
a0c0a00f | 2353 | Note that both <var>x</var> and <var>y</var> must be of the same type. |
17345e5a JA |
2354 | When the increment is supplied, it is used as the difference between |
2355 | each 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 |
2358 | and any characters special to other expansions are preserved |
2359 | in the result. It is strictly textual. Bash | |
2360 | does not apply any syntactic interpretation to the context of the | |
2361 | expansion or the text between the braces. | |
a0c0a00f CR |
2362 | </p> |
2363 | <p>A correctly-formed brace expansion must contain unquoted opening | |
17345e5a JA |
2364 | and closing braces, and at least one unquoted comma or a valid |
2365 | sequence expression. | |
2366 | Any incorrectly formed brace expansion is left unchanged. | |
a0c0a00f CR |
2367 | </p> |
2368 | <p>A { or ‘<samp>,</samp>’ may be quoted with a backslash to prevent its | |
17345e5a | 2369 | being considered part of a brace expression. |
a0c0a00f | 2370 | To avoid conflicts with parameter expansion, the string ‘<samp>${</samp>’ |
9a51695b CR |
2371 | is not considered eligible for brace expansion, |
2372 | and inhibits brace expansion until the closing ‘<samp>}</samp>’.. | |
a0c0a00f CR |
2373 | </p> |
2374 | <p>This construct is typically used as shorthand when the common | |
17345e5a JA |
2375 | prefix of the strings to be generated is longer than in the |
2376 | above 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> | |
2389 | Next: <a href="#Shell-Parameter-Expansion" accesskey="n" rel="next">Shell Parameter Expansion</a>, Previous: <a href="#Brace-Expansion" accesskey="p" rel="prev">Brace Expansion</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> [<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 (‘<samp>~</samp>’), all of the | |
17345e5a | 2397 | characters up to the first unquoted slash (or all characters, |
a0c0a00f | 2398 | if there is no unquoted slash) are considered a <var>tilde-prefix</var>. |
17345e5a JA |
2399 | If none of the characters in the tilde-prefix are quoted, the |
2400 | characters in the tilde-prefix following the tilde are treated as a | |
a0c0a00f | 2401 | possible <var>login name</var>. |
17345e5a | 2402 | If this login name is the null string, the tilde is replaced with the |
a0c0a00f CR |
2403 | value of the <code>HOME</code> shell variable. |
2404 | If <code>HOME</code> is unset, the home directory of the user executing the | |
17345e5a JA |
2405 | shell is substituted instead. |
2406 | Otherwise, the tilde-prefix is replaced with the home directory | |
2407 | associated with the specified login name. | |
a0c0a00f CR |
2408 | </p> |
2409 | <p>If the tilde-prefix is ‘<samp>~+</samp>’, the value of | |
2410 | the shell variable <code>PWD</code> replaces the tilde-prefix. | |
2411 | If the tilde-prefix is ‘<samp>~-</samp>’, 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 | |
2415 | number <var>N</var>, optionally prefixed by a ‘<samp>+</samp>’ or a ‘<samp>-</samp>’, | |
17345e5a JA |
2416 | the tilde-prefix is replaced with the |
2417 | corresponding element from the directory stack, as it would be displayed | |
a0c0a00f CR |
2418 | by the <code>dirs</code> builtin invoked with the characters following tilde |
2419 | in the tilde-prefix as an argument (see <a href="#The-Directory-Stack">The Directory Stack</a>). | |
17345e5a | 2420 | If the tilde-prefix, sans the tilde, consists of a number without a |
a0c0a00f CR |
2421 | leading ‘<samp>+</samp>’ or ‘<samp>-</samp>’, ‘<samp>+</samp>’ is assumed. |
2422 | </p> | |
2423 | <p>If the login name is invalid, or the tilde expansion fails, the word is | |
17345e5a | 2424 | left unchanged. |
a0c0a00f CR |
2425 | </p> |
2426 | <p>Each variable assignment is checked for unquoted tilde-prefixes immediately | |
2427 | following a ‘<samp>:</samp>’ or the first ‘<samp>=</samp>’. | |
17345e5a | 2428 | In these cases, tilde expansion is also performed. |
ac50fbac | 2429 | Consequently, one may use filenames with tildes in assignments to |
a0c0a00f | 2430 | <code>PATH</code>, <code>MAILPATH</code>, and <code>CDPATH</code>, |
17345e5a | 2431 | and 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 ‘<samp>dirs +<var>N</var></samp>’ | |
2458 | </p> | |
2459 | </dd> | |
2460 | <dt><code>~+<var>N</var></code></dt> | |
2461 | <dd><p>The string that would be displayed by ‘<samp>dirs +<var>N</var></samp>’ | |
2462 | </p> | |
2463 | </dd> | |
2464 | <dt><code>~-<var>N</var></code></dt> | |
2465 | <dd><p>The string that would be displayed by ‘<samp>dirs -<var>N</var></samp>’ | |
2466 | </p></dd> | |
2467 | </dl> | |
2468 | ||
2f5dfe5a CR |
2469 | <p>Bash also performs tilde expansion on words satisfying the conditions of |
2470 | variable assignments (see <a href="#Shell-Parameters">Shell Parameters</a>) | |
2471 | when they appear as arguments to simple commands. | |
2472 | Bash does not do this, except for the <var>declaration</var> commands listed | |
2473 | above, 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> | |
2479 | Next: <a href="#Command-Substitution" accesskey="n" rel="next">Command Substitution</a>, Previous: <a href="#Tilde-Expansion" accesskey="p" rel="prev">Tilde Expansion</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> [<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 ‘<samp>$</samp>’ character introduces parameter expansion, | |
17345e5a JA |
2487 | command substitution, or arithmetic expansion. The parameter name |
2488 | or symbol to be expanded may be enclosed in braces, which | |
2489 | are optional but serve to protect the variable to be expanded from | |
2490 | characters immediately following it which could be | |
2491 | interpreted as part of the name. | |
a0c0a00f CR |
2492 | </p> |
2493 | <p>When braces are used, the matching ending brace is the first ‘<samp>}</samp>’ | |
17345e5a JA |
2494 | not escaped by a backslash or within a quoted string, and not within an |
2495 | embedded arithmetic expansion, command substitution, or parameter | |
2496 | expansion. | |
a0c0a00f CR |
2497 | </p> |
2498 | <p>The basic form of parameter expansion is ${<var>parameter</var>}. | |
2499 | The value of <var>parameter</var> is substituted. | |
2500 | The <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>). | |
2502 | The braces are required when <var>parameter</var> | |
17345e5a | 2503 | is a positional parameter with more than one digit, |
a0c0a00f | 2504 | or when <var>parameter</var> is followed by a character that is not to be |
17345e5a | 2505 | interpreted as part of its name. |
a0c0a00f CR |
2506 | </p> |
2507 | <p>If the first character of <var>parameter</var> is an exclamation point (!), | |
2508 | and <var>parameter</var> is not a <var>nameref</var>, | |
2f5dfe5a CR |
2509 | it introduces a level of indirection. |
2510 | Bash uses the value formed by expanding the rest of | |
2511 | <var>parameter</var> as the new <var>parameter</var>; this is then | |
2512 | expanded and that value is used in the rest of the expansion, rather | |
2513 | than the expansion of the original <var>parameter</var>. | |
a0c0a00f | 2514 | This is known as <code>indirect expansion</code>. |
9a51695b CR |
2515 | The value is subject to tilde expansion, |
2516 | parameter expansion, command substitution, and arithmetic expansion. | |
a0c0a00f CR |
2517 | If <var>parameter</var> is a nameref, this expands to the name of the |
2518 | variable referenced by <var>parameter</var> instead of performing the | |
2519 | complete indirect expansion. | |
2520 | The exceptions to this are the expansions of ${!<var>prefix</var>*} | |
2521 | and ${!<var>name</var>[@]} | |
17345e5a JA |
2522 | described below. |
2523 | The exclamation point must immediately follow the left brace in order to | |
2524 | introduce indirection. | |
a0c0a00f CR |
2525 | </p> |
2526 | <p>In each of the cases below, <var>word</var> is subject to tilde expansion, | |
17345e5a | 2527 | parameter expansion, command substitution, and arithmetic expansion. |
a0c0a00f CR |
2528 | </p> |
2529 | <p>When not performing substring expansion, using the form described | |
2530 | below (e.g., ‘<samp>:-</samp>’), Bash tests for a parameter that is unset or null. | |
17345e5a JA |
2531 | Omitting the colon results in a test only for a parameter that is unset. |
2532 | Put another way, if the colon is included, | |
a0c0a00f | 2533 | the operator tests for both <var>parameter</var>’s existence and that its value |
17345e5a | 2534 | is 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> | |
2545 | is unset or null, the expansion of <var>word</var> | |
2546 | is assigned to <var>parameter</var>. | |
2547 | The value of <var>parameter</var> is then substituted. | |
17345e5a JA |
2548 | Positional parameters and special parameters may not be assigned to |
2549 | in 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> | |
2554 | is null or unset, the expansion of <var>word</var> (or a message | |
2555 | to that effect if <var>word</var> | |
17345e5a | 2556 | is not present) is written to the standard error and the shell, if it |
a0c0a00f | 2557 | is not interactive, exits. Otherwise, the value of <var>parameter</var> is |
17345e5a | 2558 | substituted. |
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 | 2563 | is 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. | |
2570 | It expands to up to <var>length</var> characters of the value of <var>parameter</var> | |
2571 | starting at the character specified by <var>offset</var>. | |
2572 | If <var>parameter</var> is ‘<samp>@</samp>’, an indexed array subscripted by | |
2573 | ‘<samp>@</samp>’ or ‘<samp>*</samp>’, or an associative array name, the results differ as | |
ac50fbac | 2574 | described below. |
a0c0a00f CR |
2575 | If <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 | 2577 | and 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 | 2582 | is used as an offset in characters |
a0c0a00f CR |
2583 | from the end of the value of <var>parameter</var>. |
2584 | If <var>length</var> evaluates to a number less than zero, | |
ac50fbac | 2585 | it is interpreted as an offset in characters |
a0c0a00f | 2586 | from the end of the value of <var>parameter</var> rather than |
ac50fbac | 2587 | a number of characters, and the expansion is the characters between |
a0c0a00f | 2588 | <var>offset</var> and that result. |
ac50fbac | 2589 | Note that a negative offset must be separated from the colon by at least |
a0c0a00f CR |
2590 | one space to avoid being confused with the ‘<samp>:-</samp>’ expansion. |
2591 | </p> | |
2592 | <p>Here are some examples illustrating substring expansion on parameters and | |
ac50fbac | 2593 | subscripted arrays: |
a0c0a00f CR |
2594 | </p> |
2595 | <pre class="verbatim">$ string=01234567890abcdefgh | |
ac50fbac CR |
2596 | $ echo ${string:7} |
2597 | 7890abcdefgh | |
2598 | $ echo ${string:7:0} | |
ac50fbac CR |
2599 | |
2600 | $ echo ${string:7:2} | |
2601 | 78 | |
2602 | $ echo ${string:7:-2} | |
2603 | 7890abcdef | |
2604 | $ echo ${string: -7} | |
2605 | bcdefgh | |
2606 | $ echo ${string: -7:0} | |
ac50fbac CR |
2607 | |
2608 | $ echo ${string: -7:2} | |
2609 | bc | |
2610 | $ echo ${string: -7:-2} | |
2611 | bcdef | |
2612 | $ set -- 01234567890abcdefgh | |
2613 | $ echo ${1:7} | |
2614 | 7890abcdefgh | |
2615 | $ echo ${1:7:0} | |
ac50fbac CR |
2616 | |
2617 | $ echo ${1:7:2} | |
2618 | 78 | |
2619 | $ echo ${1:7:-2} | |
2620 | 7890abcdef | |
2621 | $ echo ${1: -7} | |
2622 | bcdefgh | |
2623 | $ echo ${1: -7:0} | |
ac50fbac CR |
2624 | |
2625 | $ echo ${1: -7:2} | |
2626 | bc | |
2627 | $ echo ${1: -7:-2} | |
2628 | bcdef | |
2629 | $ array[0]=01234567890abcdefgh | |
2630 | $ echo ${array[0]:7} | |
2631 | 7890abcdefgh | |
2632 | $ echo ${array[0]:7:0} | |
ac50fbac CR |
2633 | |
2634 | $ echo ${array[0]:7:2} | |
2635 | 78 | |
2636 | $ echo ${array[0]:7:-2} | |
2637 | 7890abcdef | |
2638 | $ echo ${array[0]: -7} | |
2639 | bcdefgh | |
2640 | $ echo ${array[0]: -7:0} | |
ac50fbac CR |
2641 | |
2642 | $ echo ${array[0]: -7:2} | |
2643 | bc | |
2644 | $ echo ${array[0]: -7:-2} | |
2645 | bcdef | |
a0c0a00f CR |
2646 | </pre> |
2647 | <p>If <var>parameter</var> is ‘<samp>@</samp>’, the result is <var>length</var> positional | |
2648 | parameters beginning at <var>offset</var>. | |
2649 | A negative <var>offset</var> is taken relative to one greater than the greatest | |
ac50fbac CR |
2650 | positional parameter, so an offset of -1 evaluates to the last positional |
2651 | parameter. | |
a0c0a00f CR |
2652 | It 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 | 2655 | parameters: |
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 | 2659 | 7 8 9 0 a b c d e f g h |
a0c0a00f | 2660 | $ echo ${@:7:0} |
ac50fbac | 2661 | |
a0c0a00f | 2662 | $ echo ${@:7:2} |
ac50fbac | 2663 | 7 8 |
a0c0a00f CR |
2664 | $ echo ${@:7:-2} |
2665 | bash: -2: substring expression < 0 | |
2666 | $ echo ${@: -7:2} | |
ac50fbac | 2667 | b 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 | |
2676 | by ‘<samp>@</samp>’ or ‘<samp>*</samp>’, the result is the <var>length</var> | |
2677 | members of the array beginning with <code>${<var>parameter</var>[<var>offset</var>]}</code>. | |
2678 | A negative <var>offset</var> is taken relative to one greater than the maximum | |
17345e5a | 2679 | index of the specified array. |
a0c0a00f CR |
2680 | It 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 | 2683 | arrays: |
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} |
2687 | 7 8 9 0 a b c d e f g h | |
2688 | $ echo ${array[@]:7:2} | |
2689 | 7 8 | |
2690 | $ echo ${array[@]: -7:2} | |
2691 | b c | |
2692 | $ echo ${array[@]: -7:-2} | |
a0c0a00f | 2693 | bash: -2: substring expression < 0 |
ac50fbac CR |
2694 | $ echo ${array[@]:0} |
2695 | 0 1 2 3 4 5 6 7 8 9 0 a b c d e f g h | |
2696 | $ echo ${array[@]:0:2} | |
2697 | 0 1 | |
2698 | $ echo ${array[@]: -7:0} | |
ac50fbac | 2699 | |
a0c0a00f CR |
2700 | </pre> |
2701 | <p>Substring expansion applied to an associative array produces undefined | |
17345e5a | 2702 | results. |
a0c0a00f CR |
2703 | </p> |
2704 | <p>Substring indexing is zero-based unless the positional parameters | |
17345e5a | 2705 | are used, in which case the indexing starts at 1 by default. |
a0c0a00f | 2706 | If <var>offset</var> is 0, and the positional parameters are used, <code>$@</code> is |
17345e5a | 2707 | prefixed 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>, | |
2713 | separated by the first character of the <code>IFS</code> special variable. | |
2714 | When ‘<samp>@</samp>’ is used and the expansion appears within double quotes, each | |
17345e5a | 2715 | variable 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>. | |
2722 | If <var>name</var> is not an array, expands to 0 if <var>name</var> is set and null | |
17345e5a | 2723 | otherwise. |
a0c0a00f | 2724 | When ‘<samp>@</samp>’ is used and the expansion appears within double quotes, each |
17345e5a | 2725 | key 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 | 2730 | substituted. |
a0c0a00f | 2731 | If <var>parameter</var> is ‘<samp>*</samp>’ or ‘<samp>@</samp>’, the value substituted |
17345e5a | 2732 | is the number of positional parameters. |
a0c0a00f | 2733 | If <var>parameter</var> is an array name subscripted by ‘<samp>*</samp>’ or ‘<samp>@</samp>’, |
17345e5a | 2734 | the value substituted is the number of elements in the array. |
a0c0a00f | 2735 | If <var>parameter</var> |
ac50fbac CR |
2736 | is an indexed array name subscripted by a negative number, that number is |
2737 | interpreted 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 | 2739 | array, 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 |
2745 | is expanded to produce a pattern and matched according to the rules |
2746 | described below (see <a href="#Pattern-Matching">Pattern Matching</a>). If the pattern matches | |
a0c0a00f CR |
2747 | the beginning of the expanded value of <var>parameter</var>, |
2748 | then the result of the expansion is the expanded value of <var>parameter</var> | |
2749 | with the shortest matching pattern (the ‘<samp>#</samp>’ case) or the | |
2750 | longest matching pattern (the ‘<samp>##</samp>’ case) deleted. | |
2751 | If <var>parameter</var> is ‘<samp>@</samp>’ or ‘<samp>*</samp>’, | |
17345e5a JA |
2752 | the pattern removal operation is applied to each positional |
2753 | parameter in turn, and the expansion is the resultant list. | |
a0c0a00f CR |
2754 | If <var>parameter</var> is an array variable subscripted with |
2755 | ‘<samp>@</samp>’ or ‘<samp>*</samp>’, | |
17345e5a JA |
2756 | the pattern removal operation is applied to each member of the |
2757 | array 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> |
2763 | is expanded to produce a pattern and matched according to the rules | |
2764 | described below (see <a href="#Pattern-Matching">Pattern Matching</a>). If the pattern matches | |
17345e5a | 2765 | If 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 ‘<samp>%</samp>’ case) | |
2768 | or the longest matching pattern (the ‘<samp>%%</samp>’ case) deleted. | |
2769 | If <var>parameter</var> is ‘<samp>@</samp>’ or ‘<samp>*</samp>’, | |
17345e5a JA |
2770 | the pattern removal operation is applied to each positional |
2771 | parameter in turn, and the expansion is the resultant list. | |
a0c0a00f CR |
2772 | If <var>parameter</var> |
2773 | is an array variable subscripted with ‘<samp>@</samp>’ or ‘<samp>*</samp>’, | |
17345e5a JA |
2774 | the pattern removal operation is applied to each member of the |
2775 | array 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 | 2781 | filename expansion. |
a0c0a00f CR |
2782 | <var>Parameter</var> is expanded and the longest match of <var>pattern</var> |
2783 | against its value is replaced with <var>string</var>. | |
9a51695b CR |
2784 | The match is performed according to the rules described below |
2785 | (see <a href="#Pattern-Matching">Pattern Matching</a>). | |
a0c0a00f CR |
2786 | If <var>pattern</var> begins with ‘<samp>/</samp>’, all matches of <var>pattern</var> are |
2787 | replaced with <var>string</var>. Normally only the first match is replaced. | |
2788 | If <var>pattern</var> begins with ‘<samp>#</samp>’, it must match at the beginning | |
2789 | of the expanded value of <var>parameter</var>. | |
2790 | If <var>pattern</var> begins with ‘<samp>%</samp>’, it must match at the end | |
2791 | of the expanded value of <var>parameter</var>. | |
2792 | If <var>string</var> is null, matches of <var>pattern</var> are deleted | |
2793 | and the <code>/</code> following <var>pattern</var> may be omitted. | |
2794 | If the <code>nocasematch</code> shell option | |
2795 | (see the description of <code>shopt</code> in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>) | |
2796 | is enabled, the match is performed without regard to the case | |
2797 | of alphabetic characters. | |
2798 | If <var>parameter</var> is ‘<samp>@</samp>’ or ‘<samp>*</samp>’, | |
17345e5a JA |
2799 | the substitution operation is applied to each positional |
2800 | parameter in turn, and the expansion is the resultant list. | |
a0c0a00f CR |
2801 | If <var>parameter</var> |
2802 | is an array variable subscripted with ‘<samp>@</samp>’ or ‘<samp>*</samp>’, | |
17345e5a JA |
2803 | the substitution operation is applied to each member of the |
2804 | array 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>. | |
2812 | The <var>pattern</var> is expanded to produce a pattern just as in | |
0001803f | 2813 | filename expansion. |
a0c0a00f CR |
2814 | Each 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 | 2816 | The pattern should not attempt to match more than one character. |
a0c0a00f CR |
2817 | The ‘<samp>^</samp>’ operator converts lowercase letters matching <var>pattern</var> |
2818 | to uppercase; the ‘<samp>,</samp>’ operator converts matching uppercase letters | |
17345e5a | 2819 | to lowercase. |
a0c0a00f CR |
2820 | The ‘<samp>^^</samp>’ and ‘<samp>,,</samp>’ expansions convert each matched character in the |
2821 | expanded value; the ‘<samp>^</samp>’ and ‘<samp>,</samp>’ expansions match and convert only | |
17345e5a | 2822 | the first character in the expanded value. |
a0c0a00f | 2823 | If <var>pattern</var> is omitted, it is treated like a ‘<samp>?</samp>’, which matches |
17345e5a | 2824 | every character. |
a0c0a00f | 2825 | If <var>parameter</var> is ‘<samp>@</samp>’ or ‘<samp>*</samp>’, |
17345e5a JA |
2826 | the case modification operation is applied to each positional |
2827 | parameter in turn, and the expansion is the resultant list. | |
a0c0a00f CR |
2828 | If <var>parameter</var> |
2829 | is an array variable subscripted with ‘<samp>@</samp>’ or ‘<samp>*</samp>’, | |
17345e5a JA |
2830 | the case modification operation is applied to each member of the |
2831 | array 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> | |
2836 | or 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 | |
2842 | format 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 | 2846 | escape sequences expanded as with the <code>$'…'</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 | |
2854 | an assignment statement or <code>declare</code> command that, if | |
2855 | evaluated, 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>’s attributes. | |
2860 | </p></dd> | |
2861 | </dl> | |
2862 | ||
2863 | <p>If <var>parameter</var> is ‘<samp>@</samp>’ or ‘<samp>*</samp>’, | |
2864 | the operation is applied to each positional | |
2865 | parameter in turn, and the expansion is the resultant list. | |
2866 | If <var>parameter</var> | |
2867 | is an array variable subscripted with ‘<samp>@</samp>’ or ‘<samp>*</samp>’, | |
2868 | the operation is applied to each member of the | |
2869 | array 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 | |
2872 | expansion as described below. | |
2873 | </p></dd> | |
2874 | </dl> | |
2875 | ||
2876 | <hr> | |
2877 | <a name="Command-Substitution"></a> | |
2878 | <div class="header"> | |
2879 | <p> | |
2880 | Next: <a href="#Arithmetic-Expansion" accesskey="n" rel="next">Arithmetic Expansion</a>, Previous: <a href="#Shell-Parameter-Expansion" accesskey="p" rel="prev">Shell Parameter Expansion</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> [<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 |
2887 | the command itself. |
2888 | Command 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 | |
2898 | and replacing the command substitution with the standard output of the | |
17345e5a JA |
2899 | command, with any trailing newlines deleted. |
2900 | Embedded newlines are not deleted, but they may be removed during | |
2901 | word splitting. | |
a0c0a00f CR |
2902 | The command substitution <code>$(cat <var>file</var>)</code> can be |
2903 | replaced by the equivalent but faster <code>$(< <var>file</var>)</code>. | |
2904 | </p> | |
2905 | <p>When the old-style backquote form of substitution is used, | |
17345e5a | 2906 | backslash retains its literal meaning except when followed by |
a0c0a00f | 2907 | ‘<samp>$</samp>’, ‘<samp>`</samp>’, or ‘<samp>\</samp>’. |
17345e5a JA |
2908 | The first backquote not preceded by a backslash terminates the |
2909 | command substitution. | |
a0c0a00f | 2910 | When using the <code>$(<var>command</var>)</code> form, all characters between |
17345e5a | 2911 | the 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 | 2914 | form, escape the inner backquotes with backslashes. |
a0c0a00f CR |
2915 | </p> |
2916 | <p>If the substitution appears within double quotes, word splitting and | |
17345e5a | 2917 | filename 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> | |
2923 | Next: <a href="#Process-Substitution" accesskey="n" rel="next">Process Substitution</a>, Previous: <a href="#Command-Substitution" accesskey="p" rel="prev">Command Substitution</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> [<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 | 2931 | and 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 | 2938 | a double quote inside the parentheses is not treated specially. |
ac50fbac CR |
2939 | All tokens in the expression undergo parameter and variable expansion, |
2940 | command substitution, and quote removal. | |
2941 | The result is treated as the arithmetic expression to be evaluated. | |
17345e5a | 2942 | Arithmetic 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 |
2946 | If the expression is invalid, Bash prints a message indicating |
2947 | failure 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> | |
2953 | Next: <a href="#Word-Splitting" accesskey="n" rel="next">Word Splitting</a>, Previous: <a href="#Arithmetic-Expansion" accesskey="p" rel="prev">Arithmetic Expansion</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> [<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’s input or output to be | |
2960 | referred to using a filename. | |
17345e5a | 2961 | It takes the form of |
a0c0a00f CR |
2962 | </p><div class="example"> |
2963 | <pre class="example"><(<var>list</var>) | |
2964 | </pre></div> | |
2965 | <p>or | |
2966 | </p><div class="example"> | |
2967 | <pre class="example">>(<var>list</var>) | |
2968 | </pre></div> | |
2969 | <p>The process <var>list</var> is run asynchronously, and its input or output | |
2970 | appears as a filename. | |
2971 | This filename is | |
17345e5a | 2972 | passed as an argument to the current command as the result of the |
a0c0a00f CR |
2973 | expansion. |
2974 | If the <code>>(<var>list</var>)</code> form is used, writing to | |
2975 | the file will provide input for <var>list</var>. If the | |
2976 | <code><(<var>list</var>)</code> form is used, the file passed as an | |
2977 | argument should be read to obtain the output of <var>list</var>. | |
2978 | Note that no space may appear between the <code><</code> or <code>></code> | |
17345e5a JA |
2979 | and the left parenthesis, otherwise the construct would be interpreted |
2980 | as a redirection. | |
a0c0a00f CR |
2981 | Process substitution is supported on systems that support named |
2982 | pipes (<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 |
2985 | parameter and variable expansion, command substitution, and arithmetic |
2986 | expansion. | |
a0c0a00f CR |
2987 | </p> |
2988 | <hr> | |
2989 | <a name="Word-Splitting"></a> | |
2990 | <div class="header"> | |
2991 | <p> | |
2992 | Next: <a href="#Filename-Expansion" accesskey="n" rel="next">Filename Expansion</a>, Previous: <a href="#Process-Substitution" accesskey="p" rel="prev">Process Substitution</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> [<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 |
2999 | and arithmetic expansion that did not occur within double quotes for |
3000 | word splitting. | |
a0c0a00f CR |
3001 | </p> |
3002 | <p>The shell treats each character of <code>$IFS</code> as a delimiter, and splits | |
ac50fbac CR |
3003 | the results of the other expansions into words using these characters |
3004 | as field terminators. | |
a0c0a00f | 3005 | If <code>IFS</code> is unset, or its value is exactly <code><space><tab><newline></code>, |
17345e5a | 3006 | the default, then sequences of |
a0c0a00f | 3007 | <code> <space></code>, <code><tab></code>, and <code><newline></code> |
17345e5a | 3008 | at the beginning and end of the results of the previous |
a0c0a00f | 3009 | expansions are ignored, and any sequence of <code>IFS</code> |
17345e5a | 3010 | characters not at the beginning or end serves to delimit words. |
a0c0a00f CR |
3011 | If <code>IFS</code> has a value other than the default, then sequences of |
3012 | the whitespace characters <code>space</code>, <code>tab</code>, and <code>newline</code> | |
17345e5a JA |
3013 | are ignored at the beginning and end of the |
3014 | word, as long as the whitespace character is in the | |
a0c0a00f CR |
3015 | value of <code>IFS</code> (an <code>IFS</code> whitespace character). |
3016 | Any character in <code>IFS</code> that is not <code>IFS</code> | |
3017 | whitespace, along with any adjacent <code>IFS</code> | |
3018 | whitespace characters, delimits a field. A sequence of <code>IFS</code> | |
17345e5a | 3019 | whitespace characters is also treated as a delimiter. |
a0c0a00f CR |
3020 | If the value of <code>IFS</code> is null, no word splitting occurs. |
3021 | </p> | |
3022 | <p>Explicit null arguments (<code>""</code> or <code>''</code>) are retained | |
3023 | and passed to commands as empty strings. | |
17345e5a JA |
3024 | Unquoted implicit null arguments, resulting from the expansion of |
3025 | parameters that have no values, are removed. | |
3026 | If a parameter with no value is expanded within double quotes, a | |
a0c0a00f CR |
3027 | null argument results and is retained |
3028 | and passed to a command as an empty string. | |
3029 | When a quoted null argument appears as part of a word whose expansion is | |
3030 | non-null, the null argument is removed. | |
3031 | That is, the word | |
3032 | <code>-d''</code> becomes <code>-d</code> after word splitting and | |
3033 | null argument removal. | |
3034 | </p> | |
3035 | <p>Note that if no expansion occurs, no splitting | |
17345e5a | 3036 | is performed. |
a0c0a00f CR |
3037 | </p> |
3038 | <hr> | |
3039 | <a name="Filename-Expansion"></a> | |
3040 | <div class="header"> | |
3041 | <p> | |
3042 | Next: <a href="#Quote-Removal" accesskey="n" rel="next">Quote Removal</a>, Previous: <a href="#Word-Splitting" accesskey="p" rel="prev">Word Splitting</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> [<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">• <a href="#Pattern-Matching" accesskey="1">Pattern Matching</a>:</td><td> </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 | ‘<samp>*</samp>’, ‘<samp>?</samp>’, and ‘<samp>[</samp>’. | |
17345e5a | 3058 | If one of these characters appears, then the word is |
a0c0a00f | 3059 | regarded as a <var>pattern</var>, |
17345e5a | 3060 | and replaced with an alphabetically sorted list of |
a0c0a00f | 3061 | filenames matching the pattern (see <a href="#Pattern-Matching">Pattern Matching</a>). |
ac50fbac | 3062 | If no matching filenames are found, |
a0c0a00f | 3063 | and the shell option <code>nullglob</code> is disabled, the word is left |
17345e5a | 3064 | unchanged. |
a0c0a00f | 3065 | If the <code>nullglob</code> option is set, and no matches are found, the word |
17345e5a | 3066 | is removed. |
a0c0a00f | 3067 | If the <code>failglob</code> shell option is set, and no matches are found, |
17345e5a | 3068 | an error message is printed and the command is not executed. |
a0c0a00f | 3069 | If the shell option <code>nocaseglob</code> is enabled, the match is performed |
17345e5a | 3070 | without regard to the case of alphabetic characters. |
a0c0a00f CR |
3071 | </p> |
3072 | <p>When a pattern is used for filename expansion, the character ‘<samp>.</samp>’ | |
17345e5a | 3073 | at the start of a filename or immediately following a slash |
a0c0a00f | 3074 | must be matched explicitly, unless the shell option <code>dotglob</code> is set. |
9a51695b CR |
3075 | The filenames ‘<samp>.</samp>’ and ‘<samp>..</samp>’ must always be matched explicitly, |
3076 | even if <code>dotglob</code> is set. | |
a0c0a00f CR |
3077 | In other cases, the ‘<samp>.</samp>’ character is not treated specially. |
3078 | </p> | |
9a51695b CR |
3079 | <p>When matching a filename, the slash character must always be |
3080 | matched explicitly by a slash in the pattern, but in other matching | |
3081 | contexts it can be matched by a special pattern character as described | |
3082 | below (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>, |
3085 | for 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 | 3089 | shell variable may be used to restrict the set of file names matching a |
a0c0a00f | 3090 | pattern. If <code>GLOBIGNORE</code> |
9a51695b | 3091 | is 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. |
3093 | If the <code>nocaseglob</code> option is set, the matching against the patterns in | |
3094 | <code>GLOBIGNORE</code> is performed without regard to case. | |
3095 | The filenames | |
3096 | <samp>.</samp> and <samp>..</samp> | |
3097 | are always ignored when <code>GLOBIGNORE</code> | |
17345e5a | 3098 | is set and not null. |
a0c0a00f CR |
3099 | However, setting <code>GLOBIGNORE</code> to a non-null value has the effect of |
3100 | enabling the <code>dotglob</code> | |
17345e5a | 3101 | shell option, so all other filenames beginning with a |
a0c0a00f | 3102 | ‘<samp>.</samp>’ will match. |
17345e5a | 3103 | To get the old behavior of ignoring filenames beginning with a |
a0c0a00f CR |
3104 | ‘<samp>.</samp>’, make ‘<samp>.*</samp>’ one of the patterns in <code>GLOBIGNORE</code>. |
3105 | The <code>dotglob</code> option is disabled when <code>GLOBIGNORE</code> | |
17345e5a | 3106 | is unset. |
a0c0a00f CR |
3107 | </p> |
3108 | <hr> | |
3109 | <a name="Pattern-Matching"></a> | |
3110 | <div class="header"> | |
3111 | <p> | |
3112 | Up: <a href="#Filename-Expansion" accesskey="u" rel="up">Filename Expansion</a> [<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 | 3120 | characters described below, matches itself. |
a0c0a00f | 3121 | The <small>NUL</small> character may not occur in a pattern. |
17345e5a JA |
3122 | A backslash escapes the following character; the |
3123 | escaping backslash is discarded when matching. | |
3124 | The special pattern characters must be quoted if they are to be matched | |
3125 | literally. | |
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. | |
3131 | When the <code>globstar</code> shell option is enabled, and ‘<samp>*</samp>’ is used in | |
3132 | a filename expansion context, two adjacent ‘<samp>*</samp>’s used as a single | |
17345e5a JA |
3133 | pattern will match all files and zero or more directories and |
3134 | subdirectories. | |
a0c0a00f | 3135 | If followed by a ‘<samp>/</samp>’, two adjacent ‘<samp>*</samp>’s will match only |
17345e5a | 3136 | directories 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>[…]</code></dt> | |
3142 | <dd><p>Matches any one of the enclosed characters. A pair of characters | |
3143 | separated by a hyphen denotes a <var>range expression</var>; | |
ac50fbac | 3144 | any character that falls between those two characters, inclusive, |
a0c0a00f | 3145 | using the current locale’s collating sequence and character set, |
17345e5a | 3146 | is matched. If the first character following the |
a0c0a00f CR |
3147 | ‘<samp>[</samp>’ is a ‘<samp>!</samp>’ or a ‘<samp>^</samp>’ |
3148 | then any character not enclosed is matched. A ‘<samp>-</samp>’ | |
17345e5a | 3149 | may be matched by including it as the first or last character |
a0c0a00f | 3150 | in the set. A ‘<samp>]</samp>’ may be matched by including it as the first |
17345e5a JA |
3151 | character in the set. |
3152 | The sorting order of characters in range expressions is determined by | |
ac50fbac | 3153 | the 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, ‘<samp>[a-dx-z]</samp>’ is equivalent to | |
3157 | ‘<samp>[abcdxyz]</samp>’. Many locales sort characters in dictionary order, and in | |
3158 | these locales ‘<samp>[a-dx-z]</samp>’ is typically not equivalent to ‘<samp>[abcdxyz]</samp>’; | |
3159 | it might be equivalent to ‘<samp>[aBbCcDdxXyYz]</samp>’, for example. To obtain | |
17345e5a | 3160 | the traditional interpretation of ranges in bracket expressions, you can |
a0c0a00f CR |
3161 | force the use of the C locale by setting the <code>LC_COLLATE</code> or |
3162 | <code>LC_ALL</code> environment variable to the value ‘<samp>C</samp>’, or enable the | |
3163 | <code>globasciiranges</code> shell option. | |
3164 | </p> | |
3165 | <p>Within ‘<samp>[</samp>’ and ‘<samp>]</samp>’, <var>character classes</var> can be specified | |
17345e5a | 3166 | using the syntax |
a0c0a00f CR |
3167 | <code>[:</code><var>class</var><code>:]</code>, where <var>class</var> is one of the |
3168 | following 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 | 3171 | print punct space upper word xdigit |
a0c0a00f CR |
3172 | </pre></div> |
3173 | <p>A character class matches any character belonging to that class. | |
3174 | The <code>word</code> character class matches letters, digits, and the character | |
3175 | ‘<samp>_</samp>’. | |
3176 | </p> | |
3177 | <p>Within ‘<samp>[</samp>’ and ‘<samp>]</samp>’, an <var>equivalence class</var> can be | |
3178 | specified using the syntax <code>[=</code><var>c</var><code>=]</code>, which | |
17345e5a | 3179 | matches all characters with the same collation weight (as defined |
a0c0a00f CR |
3180 | by the current locale) as the character <var>c</var>. |
3181 | </p> | |
3182 | <p>Within ‘<samp>[</samp>’ and ‘<samp>]</samp>’, the syntax <code>[.</code><var>symbol</var><code>.]</code> | |
3183 | matches 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 | 3188 | builtin, several extended pattern matching operators are recognized. |
a0c0a00f CR |
3189 | In the following description, a <var>pattern-list</var> is a list of one |
3190 | or more patterns separated by a ‘<samp>|</samp>’. | |
17345e5a JA |
3191 | Composite patterns may be formed using one or more of the following |
3192 | sub-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, |
3217 | especially when the patterns contain alternations and the strings | |
3218 | contain multiple matches. | |
3219 | Using separate matches against shorter strings, or using arrays of | |
3220 | strings 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> | |
3226 | Previous: <a href="#Filename-Expansion" accesskey="p" rel="prev">Filename Expansion</a>, Up: <a href="#Shell-Expansions" accesskey="u" rel="up">Shell Expansions</a> [<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 | |
3232 | characters ‘<samp>\</samp>’, ‘<samp>'</samp>’, and ‘<samp>"</samp>’ that did not | |
17345e5a | 3233 | result 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> | |
3239 | Next: <a href="#Executing-Commands" accesskey="n" rel="next">Executing Commands</a>, Previous: <a href="#Shell-Expansions" accesskey="p" rel="prev">Shell Expansions</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> [<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 | |
3246 | may be <var>redirected</var> | |
17345e5a | 3247 | using a special notation interpreted by the shell. |
a0c0a00f | 3248 | Redirection allows commands’ file handles to be |
ac50fbac CR |
3249 | duplicated, opened, closed, |
3250 | made to refer to different files, | |
3251 | and can change the files the command reads from and writes to. | |
3252 | Redirection may also be used to modify file handles in the | |
17345e5a JA |
3253 | current shell execution environment. The following redirection |
3254 | operators may precede or appear anywhere within a | |
3255 | simple command or may follow a command. | |
3256 | Redirections are processed in the order they appear, from | |
3257 | left to right. | |
a0c0a00f CR |
3258 | </p> |
3259 | <p>Each redirection that may be preceded by a file descriptor number | |
3260 | may instead be preceded by a word of the form {<var>varname</var>}. | |
0001803f | 3261 | In this case, for each redirection operator except |
a0c0a00f CR |
3262 | >&- and <&-, the shell will allocate a file descriptor greater |
3263 | than 10 and assign it to {<var>varname</var>}. If >&- or <&- is preceded | |
3264 | by {<var>varname</var>}, the value of <var>varname</var> defines the file | |
0001803f | 3265 | descriptor to close. |
9a51695b CR |
3266 | If {<var>varname</var>} is supplied, the redirection persists beyond |
3267 | the scope of the command, allowing the shell programmer to manage | |
3268 | the file descriptor himself. | |
a0c0a00f CR |
3269 | </p> |
3270 | <p>In the following descriptions, if the file descriptor number is | |
17345e5a | 3271 | omitted, and the first character of the redirection operator is |
a0c0a00f | 3272 | ‘<samp><</samp>’, the redirection refers to the standard input (file |
17345e5a | 3273 | descriptor 0). If the first character of the redirection operator |
a0c0a00f | 3274 | is ‘<samp>></samp>’, the redirection refers to the standard output (file |
17345e5a | 3275 | descriptor 1). |
a0c0a00f CR |
3276 | </p> |
3277 | <p>The word following the redirection operator in the following | |
17345e5a JA |
3278 | descriptions, unless otherwise noted, is subjected to brace expansion, |
3279 | tilde expansion, parameter expansion, command substitution, arithmetic | |
3280 | expansion, quote removal, filename expansion, and word splitting. | |
3281 | If 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 | 3284 | the command |
a0c0a00f CR |
3285 | </p><div class="example"> |
3286 | <pre class="example">ls > <var>dirlist</var> 2>&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>&1 > <var>dirlist</var> | |
3292 | </pre></div> | |
3293 | <p>directs only the standard output to file <var>dirlist</var>, | |
0001803f | 3294 | because the standard error was made a copy of the standard output |
a0c0a00f CR |
3295 | before the standard output was redirected to <var>dirlist</var>. |
3296 | </p> | |
3297 | <p>Bash handles several filenames specially when they are used in | |
3298 | redirections, as described in the following table. | |
3299 | If the operating system on which Bash is running provides these | |
3300 | special files, bash will use them; otherwise it will emulate them | |
3301 | internally 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 |
3322 | is an integer port number or service name, Bash attempts to open |
3323 | the 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 |
3328 | is an integer port number or service name, Bash attempts to open |
3329 | the 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 |
3336 | care, as they may conflict with file descriptors the shell uses |
3337 | internally. | |
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 | |
3342 | the expansion of <var>word</var> | |
3343 | to be opened for reading on file descriptor <code>n</code>, | |
3344 | or the standard input (file descriptor 0) if <code>n</code> | |
17345e5a | 3345 | is 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>]<<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 | |
3355 | the expansion of <var>word</var> | |
3356 | to be opened for writing on file descriptor <var>n</var>, | |
3357 | or the standard output (file descriptor 1) if <var>n</var> | |
17345e5a JA |
3358 | is not specified. If the file does not exist it is created; |
3359 | if 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>]>[|]<var>word</var> | |
3364 | </pre></div> | |
3365 | ||
3366 | <p>If the redirection operator is ‘<samp>></samp>’, and the <code>noclobber</code> | |
3367 | option to the <code>set</code> builtin has been enabled, the redirection | |
17345e5a | 3368 | will fail if the file whose name results from the expansion of |
a0c0a00f CR |
3369 | <var>word</var> exists and is a regular file. |
3370 | If the redirection operator is ‘<samp>>|</samp>’, or the redirection operator is | |
3371 | ‘<samp>></samp>’ and the <code>noclobber</code> option is not enabled, the redirection | |
3372 | is 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 | 3377 | causes the file whose name results from |
a0c0a00f CR |
3378 | the expansion of <var>word</var> |
3379 | to be opened for appending on file descriptor <var>n</var>, | |
3380 | or the standard output (file descriptor 1) if <var>n</var> | |
17345e5a | 3381 | is 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>]>><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 |
3391 | standard output (file descriptor 1) and |
3392 | the standard error output (file descriptor 2) | |
3393 | to be redirected to the file whose name is the | |
a0c0a00f CR |
3394 | expansion of <var>word</var>. |
3395 | </p> | |
3396 | <p>There are two formats for redirecting standard output and | |
17345e5a | 3397 | standard error: |
a0c0a00f CR |
3398 | </p><div class="example"> |
3399 | <pre class="example">&><var>word</var> | |
3400 | </pre></div> | |
3401 | <p>and | |
3402 | </p><div class="example"> | |
3403 | <pre class="example">>&<var>word</var> | |
3404 | </pre></div> | |
3405 | <p>Of the two forms, the first is preferred. | |
17345e5a | 3406 | This is semantically equivalent to |
a0c0a00f CR |
3407 | </p><div class="example"> |
3408 | <pre class="example">><var>word</var> 2>&1 | |
3409 | </pre></div> | |
3410 | <p>When using the second form, <var>word</var> may not expand to a number or | |
3411 | ‘<samp>-</samp>’. 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 |
3417 | standard output (file descriptor 1) and |
3418 | the standard error output (file descriptor 2) | |
3419 | to be appended to the file whose name is the | |
a0c0a00f CR |
3420 | expansion 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">&>><var>word</var> | |
3425 | </pre></div> | |
3426 | <p>This is semantically equivalent to | |
3427 | </p><div class="example"> | |
3428 | <pre class="example">>><var>word</var> 2>&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 | |
3435 | current source until a line containing only <var>word</var> | |
17345e5a JA |
3436 | (with no trailing blanks) is seen. All of |
3437 | the lines read up to that point are then used as the standard | |
a0c0a00f CR |
3438 | input (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>]<<[-]<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 | 3448 | arithmetic 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 | 3451 | and the lines in the here-document are not expanded. |
a0c0a00f | 3452 | If <var>word</var> is unquoted, |
ac50fbac CR |
3453 | all lines of the here-document are subjected to |
3454 | parameter expansion, command substitution, and arithmetic expansion, | |
a0c0a00f | 3455 | the character sequence <code>\newline</code> is ignored, and ‘<samp>\</samp>’ |
17345e5a | 3456 | must be used to quote the characters |
a0c0a00f CR |
3457 | ‘<samp>\</samp>’, ‘<samp>$</samp>’, and ‘<samp>`</samp>’. |
3458 | </p> | |
3459 | <p>If the redirection operator is ‘<samp><<-</samp>’, | |
17345e5a | 3460 | then all leading tab characters are stripped from input lines and the |
a0c0a00f | 3461 | line containing <var>delimiter</var>. |
17345e5a JA |
3462 | This allows here-documents within shell scripts to be indented in a |
3463 | natural 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>]<<< <var>word</var> | |
3470 | </pre></div> | |
3471 | ||
3472 | <p>The <var>word</var> undergoes | |
9a51695b | 3473 | tilde expansion, parameter and variable expansion, |
ac50fbac CR |
3474 | command substitution, arithmetic expansion, and quote removal. |
3475 | Pathname expansion and word splitting are not performed. | |
a0c0a00f CR |
3476 | The result is supplied as a single string, |
3477 | with a newline appended, | |
3478 | to the command on its | |
3479 | standard 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>]<&<var>word</var> | |
3486 | </pre></div> | |
3487 | <p>is used to duplicate input file descriptors. | |
3488 | If <var>word</var> | |
3489 | expands to one or more digits, the file descriptor denoted by <var>n</var> | |
17345e5a | 3490 | is made to be a copy of that file descriptor. |
a0c0a00f | 3491 | If the digits in <var>word</var> do not specify a file descriptor open for |
17345e5a | 3492 | input, a redirection error occurs. |
a0c0a00f CR |
3493 | If <var>word</var> |
3494 | evaluates to ‘<samp>-</samp>’, file descriptor <var>n</var> is closed. | |
3495 | If <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>]>&<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. | |
3503 | If the digits in <var>word</var> do not specify a file descriptor open for | |
17345e5a | 3504 | output, a redirection error occurs. |
a0c0a00f CR |
3505 | If <var>word</var> |
3506 | evaluates to ‘<samp>-</samp>’, file descriptor <var>n</var> is closed. | |
3507 | As a special case, if <var>n</var> is omitted, and <var>word</var> does not | |
3508 | expand to one or more digits or ‘<samp>-</samp>’, the standard output and standard | |
17345e5a | 3509 | error 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>]<&<var>digit</var>- | |
3516 | </pre></div> | |
3517 | <p>moves the file descriptor <var>digit</var> to file descriptor <var>n</var>, | |
3518 | or 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>]>&<var>digit</var>- | |
3524 | </pre></div> | |
3525 | <p>moves the file descriptor <var>digit</var> to file descriptor <var>n</var>, | |
3526 | or 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>]<><var>word</var> | |
3533 | </pre></div> | |
3534 | <p>causes the file whose name is the expansion of <var>word</var> | |
17345e5a | 3535 | to 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 | 3537 | is 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> | |
3543 | Next: <a href="#Shell-Scripts" accesskey="n" rel="next">Shell Scripts</a>, Previous: <a href="#Redirections" accesskey="p" rel="prev">Redirections</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> [<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">• <a href="#Simple-Command-Expansion" accesskey="1">Simple Command Expansion</a>:</td><td> </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">• <a href="#Command-Search-and-Execution" accesskey="2">Command Search and Execution</a>:</td><td> </td><td align="left" valign="top">How Bash finds commands and runs them. | |
3553 | </td></tr> | |
3554 | <tr><td align="left" valign="top">• <a href="#Command-Execution-Environment" accesskey="3">Command Execution Environment</a>:</td><td> </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">• <a href="#Environment" accesskey="4">Environment</a>:</td><td> </td><td align="left" valign="top">The environment given to a command. | |
3559 | </td></tr> | |
3560 | <tr><td align="left" valign="top">• <a href="#Exit-Status" accesskey="5">Exit Status</a>:</td><td> </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">• <a href="#Signals" accesskey="6">Signals</a>:</td><td> </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> | |
3572 | Next: <a href="#Command-Search-and-Execution" accesskey="n" rel="next">Command Search and Execution</a>, Up: <a href="#Executing-Commands" accesskey="u" rel="up">Executing Commands</a> [<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 | 3579 | expansions, 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 |
3583 | preceding the command name) and redirections are saved for later |
3584 | processing. | |
17345e5a | 3585 | |
a0c0a00f CR |
3586 | </li><li> The words that are not variable assignments or redirections are |
3587 | expanded (see <a href="#Shell-Expansions">Shell Expansions</a>). | |
17345e5a JA |
3588 | If any words remain after expansion, the first word |
3589 | is taken to be the name of the command and the remaining words are | |
3590 | the 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 ‘<samp>=</samp>’ in each variable assignment undergoes tilde |
17345e5a JA |
3595 | expansion, parameter expansion, command substitution, arithmetic expansion, |
3596 | and 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 |
3600 | shell environment. Otherwise, the variables are added to the environment |
3601 | of the executed command and do not affect the current shell environment. | |
3602 | If any of the assignments attempts to assign a value to a readonly variable, | |
3603 | an 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 |
3606 | affect the current shell environment. A redirection error causes the |
3607 | command 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 |
3610 | described below. Otherwise, the command exits. If one of the expansions |
3611 | contained a command substitution, the exit status of the command is | |
3612 | the exit status of the last command substitution performed. If there | |
3613 | were 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> | |
3619 | Next: <a href="#Command-Execution-Environment" accesskey="n" rel="next">Command Execution Environment</a>, Previous: <a href="#Simple-Command-Expansion" accesskey="p" rel="prev">Simple Command Expansion</a>, Up: <a href="#Executing-Commands" accesskey="u" rel="up">Executing Commands</a> [<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 |
3627 | simple command and an optional list of arguments, the following |
3628 | actions are taken. | |
a0c0a00f CR |
3629 | </p> |
3630 | <ol> | |
3631 | <li> If the command name contains no slashes, the shell attempts to | |
17345e5a | 3632 | locate it. If there exists a shell function by that name, that |
a0c0a00f | 3633 | function 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 |
3636 | it in the list of shell builtins. If a match is found, that |
3637 | builtin is invoked. | |
17345e5a | 3638 | |
a0c0a00f | 3639 | </li><li> If the name is neither a shell function nor a builtin, |
17345e5a | 3640 | and contains no slashes, Bash searches each element of |
a0c0a00f | 3641 | <code>$PATH</code> for a directory containing an executable file |
17345e5a | 3642 | by that name. Bash uses a hash table to remember the full |
a0c0a00f CR |
3643 | pathnames 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>). | |
3645 | A full search of the directories in <code>$PATH</code> | |
17345e5a JA |
3646 | is performed only if the command is not found in the hash table. |
3647 | If the search is unsuccessful, the shell searches for a defined shell | |
a0c0a00f | 3648 | function named <code>command_not_found_handle</code>. |
9a51695b CR |
3649 | If that function exists, it is invoked in a separate execution environment |
3650 | with the original command and | |
a0c0a00f | 3651 | the original command’s arguments as its arguments, and the function’s |
9a51695b | 3652 | exit status becomes the exit status of that subshell. |
17345e5a JA |
3653 | If that function is not defined, the shell prints an error |
3654 | message 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 |
3657 | one or more slashes, the shell executes the named program in |
3658 | a separate execution environment. | |
3659 | Argument 0 is set to the name given, and the remaining arguments | |
3660 | to 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 | 3663 | format, 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 | 3668 | the 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> | |
3676 | Next: <a href="#Environment" accesskey="n" rel="next">Environment</a>, Previous: <a href="#Command-Search-and-Execution" accesskey="p" rel="prev">Command Search and Execution</a>, Up: <a href="#Executing-Commands" accesskey="u" rel="up">Executing Commands</a> [<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 | 3683 | following: |
a0c0a00f CR |
3684 | </p> |
3685 | <ul> | |
3686 | <li> open files inherited by the shell at invocation, as modified by | |
3687 | redirections 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 | |
3693 | the shell’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> | |
3698 | or inherited from the shell’s parent in the environment | |
3699 | ||
3700 | </li><li> shell functions defined during execution or inherited from the shell’s | |
17345e5a | 3701 | parent in the environment |
17345e5a | 3702 | |
a0c0a00f CR |
3703 | </li><li> options enabled at invocation (either by default or with command-line |
3704 | arguments) 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 |
3717 | is to be executed, it |
3718 | is invoked in a separate execution environment that consists of | |
3719 | the following. Unless otherwise noted, the values are inherited | |
3720 | from the shell. | |
a0c0a00f CR |
3721 | </p> |
3722 | <ul> | |
3723 | <li> the shell’s open files, plus any modifications and additions specified | |
17345e5a | 3724 | by 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 |
3731 | exported 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 |
3734 | shell’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 |
3739 | shell’s execution environment. | |
3740 | </p> | |
3741 | <p>Command substitution, commands grouped with parentheses, | |
17345e5a JA |
3742 | and asynchronous commands are invoked in a |
3743 | subshell environment that is a duplicate of the shell environment, | |
3744 | except that traps caught by the shell are reset to the values | |
3745 | that the shell inherited from its parent at invocation. Builtin | |
3746 | commands that are invoked as part of a pipeline are also executed | |
3747 | in a subshell environment. Changes made to the subshell environment | |
a0c0a00f CR |
3748 | cannot affect the shell’s execution environment. |
3749 | </p> | |
3750 | <p>Subshells spawned to execute command substitutions inherit the value of | |
3751 | the <samp>-e</samp> option from the parent shell. When not in <small>POSIX</small> mode, | |
3752 | Bash clears the <samp>-e</samp> option in such subshells. | |
3753 | </p> | |
3754 | <p>If a command is followed by a ‘<samp>&</samp>’ and job control is not active, the | |
3755 | default standard input for the command is the empty file <samp>/dev/null</samp>. | |
17345e5a JA |
3756 | Otherwise, the invoked command inherits the file descriptors of the calling |
3757 | shell as modified by redirections. | |
a0c0a00f CR |
3758 | </p> |
3759 | <hr> | |
3760 | <a name="Environment"></a> | |
3761 | <div class="header"> | |
3762 | <p> | |
3763 | Next: <a href="#Exit-Status" accesskey="n" rel="next">Exit Status</a>, Previous: <a href="#Command-Execution-Environment" accesskey="p" rel="prev">Command Execution Environment</a>, Up: <a href="#Executing-Commands" accesskey="u" rel="up">Executing Commands</a> [<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 | |
3770 | called the <var>environment</var>. | |
3771 | This 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 |
3774 | On invocation, the shell scans its own environment and |
3775 | creates a parameter for each name found, automatically marking | |
a0c0a00f | 3776 | it for <var>export</var> |
17345e5a | 3777 | to child processes. Executed commands inherit the environment. |
a0c0a00f | 3778 | The <code>export</code> and ‘<samp>declare -x</samp>’ |
17345e5a JA |
3779 | commands allow parameters and functions to be added to and |
3780 | deleted from the environment. If the value of a parameter | |
3781 | in the environment is modified, the new value becomes part | |
3782 | of the environment, replacing the old. The environment | |
a0c0a00f | 3783 | inherited by any executed command consists of the shell’s |
17345e5a | 3784 | initial environment, whose values may be modified in the shell, |
a0c0a00f CR |
3785 | less any pairs removed by the <code>unset</code> and ‘<samp>export -n</samp>’ |
3786 | commands, plus any additions via the <code>export</code> and | |
3787 | ‘<samp>declare -x</samp>’ commands. | |
3788 | </p> | |
3789 | <p>The environment for any simple command | |
17345e5a | 3790 | or function may be augmented temporarily by prefixing it with |
a0c0a00f | 3791 | parameter assignments, as described in <a href="#Shell-Parameters">Shell Parameters</a>. |
17345e5a JA |
3792 | These assignment statements affect only the environment seen |
3793 | by 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 |
3796 | parameter assignments are placed in the environment for a command, |
3797 | not just those that precede the command name. | |
a0c0a00f CR |
3798 | </p> |
3799 | <p>When Bash invokes an external command, the variable ‘<samp>$_</samp>’ | |
ac50fbac | 3800 | is set to the full pathname of the command and passed to that |
17345e5a | 3801 | command in its environment. |
a0c0a00f CR |
3802 | </p> |
3803 | <hr> | |
3804 | <a name="Exit-Status"></a> | |
3805 | <div class="header"> | |
3806 | <p> | |
3807 | Next: <a href="#Signals" accesskey="n" rel="next">Signals</a>, Previous: <a href="#Environment" accesskey="p" rel="prev">Environment</a>, Up: <a href="#Executing-Commands" accesskey="u" rel="up">Executing Commands</a> [<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 |
3815 | fall between 0 and 255, though, as explained below, the shell may |
3816 | use values above 125 specially. Exit statuses from shell builtins and | |
ac50fbac | 3817 | compound commands are also limited to this range. Under certain |
17345e5a JA |
3818 | circumstances, the shell will use special values to indicate specific |
3819 | failure modes. | |
a0c0a00f CR |
3820 | </p> |
3821 | <p>For the shell’s purposes, a command which exits with a | |
17345e5a JA |
3822 | zero exit status has succeeded. |
3823 | A non-zero exit status indicates failure. | |
3824 | This seemingly counter-intuitive scheme is used so there | |
3825 | is one well-defined way to indicate success and a variety of | |
3826 | ways to indicate various failure modes. | |
a0c0a00f CR |
3827 | When a command terminates on a fatal signal whose number is <var>N</var>, |
3828 | Bash 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 |
3831 | execute it returns a status of 127. If a command is found |
3832 | but 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 | 3835 | the 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 | |
3839 | constructs (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 |
3842 | and a non-zero status on failure, so they may be used by the |
3843 | conditional and list constructs. | |
a0c0a00f CR |
3844 | All builtins return an exit status of 2 to indicate incorrect usage, |
3845 | generally invalid options or missing arguments. | |
3846 | </p> | |
3847 | <hr> | |
3848 | <a name="Signals"></a> | |
3849 | <div class="header"> | |
3850 | <p> | |
3851 | Previous: <a href="#Exit-Status" accesskey="p" rel="prev">Exit Status</a>, Up: <a href="#Executing-Commands" accesskey="u" rel="up">Executing Commands</a> [<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 ‘<samp>kill 0</samp>’ does not kill an interactive shell), | |
3859 | and <code>SIGINT</code> | |
3860 | is caught and handled (so that the <code>wait</code> builtin is interruptible). | |
3861 | When Bash receives a <code>SIGINT</code>, it breaks out of any executing loops. | |
3862 | In all cases, Bash ignores <code>SIGQUIT</code>. | |
3863 | If job control is in effect (see <a href="#Job-Control">Job Control</a>), Bash | |
3864 | ignores <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 |
3867 | values inherited by the shell from its parent. |
3868 | When job control is not in effect, asynchronous commands | |
a0c0a00f | 3869 | ignore <code>SIGINT</code> and <code>SIGQUIT</code> in addition to these inherited |
17345e5a JA |
3870 | handlers. |
3871 | Commands run as a result of | |
3872 | command 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>. | |
3876 | Before exiting, an interactive shell resends the <code>SIGHUP</code> to | |
17345e5a | 3877 | all jobs, running or stopped. |
a0c0a00f CR |
3878 | Stopped jobs are sent <code>SIGCONT</code> to ensure that they receive |
3879 | the <code>SIGHUP</code>. | |
3880 | To prevent the shell from sending the <code>SIGHUP</code> signal to a | |
17345e5a | 3881 | particular job, it should be removed |
a0c0a00f CR |
3882 | from the jobs table with the <code>disown</code> |
3883 | builtin (see <a href="#Job-Control-Builtins">Job Control Builtins</a>) or marked | |
3884 | to 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 | 3888 | an interactive login shell exits. |
a0c0a00f CR |
3889 | </p> |
3890 | <p>If Bash is waiting for a command to complete and receives a signal | |
17345e5a | 3891 | for which a trap has been set, the trap will not be executed until |
a0c0a00f | 3892 | the command completes. |
17345e5a | 3893 | When Bash is waiting for an asynchronous |
a0c0a00f CR |
3894 | command via the <code>wait</code> builtin, the reception of a signal for |
3895 | which a trap has been set will cause the <code>wait</code> builtin to return | |
17345e5a JA |
3896 | immediately with an exit status greater than 128, immediately after |
3897 | which the trap is executed. | |
a0c0a00f CR |
3898 | </p> |
3899 | <hr> | |
3900 | <a name="Shell-Scripts"></a> | |
3901 | <div class="header"> | |
3902 | <p> | |
3903 | Previous: <a href="#Executing-Commands" accesskey="p" rel="prev">Executing Commands</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> [<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 | 3910 | a file is used as the first non-option argument when invoking Bash, |
a0c0a00f CR |
3911 | and neither the <samp>-c</samp> nor <samp>-s</samp> option is supplied |
3912 | (see <a href="#Invoking-Bash">Invoking Bash</a>), | |
17345e5a JA |
3913 | Bash reads and executes commands from the file, then exits. This |
3914 | mode of operation creates a non-interactive shell. The shell first | |
3915 | searches for the file in the current directory, and looks in the | |
a0c0a00f CR |
3916 | directories in <code>$PATH</code> if not found there. |
3917 | </p> | |
3918 | <p>When Bash runs | |
3919 | a shell script, it sets the special parameter <code>0</code> to the name | |
17345e5a JA |
3920 | of the file, rather than the name of the shell, and the positional |
3921 | parameters are set to the remaining arguments, if any are given. | |
3922 | If no additional arguments are supplied, the positional parameters | |
3923 | are unset. | |
a0c0a00f CR |
3924 | </p> |
3925 | <p>A shell script may be made executable by using the <code>chmod</code> command | |
17345e5a | 3926 | to turn on the execute bit. When Bash finds such a file while |
a0c0a00f | 3927 | searching the <code>$PATH</code> for a command, it spawns a subshell to |
17345e5a | 3928 | execute 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 |
3938 | This subshell reinitializes itself, so that the effect is as if a |
3939 | new shell had been invoked to interpret the script, with the | |
3940 | exception 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 | 3942 | are retained by the child. |
a0c0a00f CR |
3943 | </p> |
3944 | <p>Most versions of Unix make this a part of the operating system’s command | |
17345e5a | 3945 | execution mechanism. If the first line of a script begins with |
a0c0a00f | 3946 | the two characters ‘<samp>#!</samp>’, the remainder of the line specifies |
17345e5a | 3947 | an interpreter for the program. |
a0c0a00f | 3948 | Thus, you can specify Bash, <code>awk</code>, Perl, or some other |
17345e5a | 3949 | interpreter and write the rest of the script file in that language. |
a0c0a00f CR |
3950 | </p> |
3951 | <p>The arguments to the interpreter | |
17345e5a JA |
3952 | consist of a single optional argument following the interpreter |
3953 | name on the first line of the script file, followed by the name of | |
3954 | the script file, followed by the rest of the arguments. Bash | |
3955 | will perform this action on operating systems that do not handle it | |
3956 | themselves. Note that some older versions of Unix limit the interpreter | |
3957 | name 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 | |
3960 | Bash has been installed in <samp>/bin</samp>), since this ensures that | |
17345e5a JA |
3961 | Bash will be used to interpret the script, even if it is executed |
3962 | under another shell. | |
a0c0a00f CR |
3963 | </p> |
3964 | <hr> | |
3965 | <a name="Shell-Builtin-Commands"></a> | |
3966 | <div class="header"> | |
3967 | <p> | |
3968 | Next: <a href="#Shell-Variables" accesskey="n" rel="next">Shell Variables</a>, Previous: <a href="#Basic-Shell-Features" accesskey="p" rel="prev">Basic Shell Features</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<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">• <a href="#Bourne-Shell-Builtins" accesskey="1">Bourne Shell Builtins</a>:</td><td> </td><td align="left" valign="top">Builtin commands inherited from the Bourne | |
3975 | Shell. | |
3976 | </td></tr> | |
3977 | <tr><td align="left" valign="top">• <a href="#Bash-Builtins" accesskey="2">Bash Builtins</a>:</td><td> </td><td align="left" valign="top">Table of builtins specific to Bash. | |
3978 | </td></tr> | |
3979 | <tr><td align="left" valign="top">• <a href="#Modifying-Shell-Behavior" accesskey="3">Modifying Shell Behavior</a>:</td><td> </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">• <a href="#Special-Builtins" accesskey="4">Special Builtins</a>:</td><td> </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 | 3988 | When the name of a builtin command is used as the first word of |
a0c0a00f | 3989 | a simple command (see <a href="#Simple-Commands">Simple Commands</a>), the shell executes |
17345e5a JA |
3990 | the command directly, without invoking another program. |
3991 | Builtin commands are necessary to implement functionality impossible | |
3992 | or inconvenient to obtain with separate utilities. | |
a0c0a00f CR |
3993 | </p> |
3994 | <p>This section briefly describes the builtins which Bash inherits from | |
17345e5a JA |
3995 | the Bourne Shell, as well as the builtin commands which are unique |
3996 | to or have been extended in Bash. | |
a0c0a00f CR |
3997 | </p> |
3998 | <p>Several builtin commands are described in other chapters: builtin | |
17345e5a | 3999 | commands which provide the Bash interface to the job control |
a0c0a00f CR |
4000 | facilities (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 | |
4003 | facilities (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 | |
4008 | options preceded by ‘<samp>-</samp>’ accepts ‘<samp>--</samp>’ | |
17345e5a | 4009 | to signify the end of the options. |
9a51695b | 4010 | The <code>:</code>, <code>true</code>, <code>false</code>, and <code>test</code>/<code>[</code> |
a0c0a00f CR |
4011 | builtins do not accept options and do not treat ‘<samp>--</samp>’ specially. |
4012 | The <code>exit</code>, <code>logout</code>, <code>return</code>, | |
4013 | <code>break</code>, <code>continue</code>, <code>let</code>, | |
4014 | and <code>shift</code> builtins accept and process arguments beginning | |
4015 | with ‘<samp>-</samp>’ without requiring ‘<samp>--</samp>’. | |
0001803f | 4016 | Other builtins that accept arguments but are not specified as accepting |
a0c0a00f CR |
4017 | options interpret arguments beginning with ‘<samp>-</samp>’ as invalid options and |
4018 | require ‘<samp>--</samp>’ to prevent this interpretation. | |
4019 | </p> | |
4020 | <hr> | |
4021 | <a name="Bourne-Shell-Builtins"></a> | |
4022 | <div class="header"> | |
4023 | <p> | |
4024 | Next: <a href="#Bash-Builtins" accesskey="n" rel="next">Bash Builtins</a>, Up: <a href="#Shell-Builtin-Commands" accesskey="u" rel="up">Shell Builtin Commands</a> [<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. | |
4030 | These 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 | 4040 | The 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 | |
4050 | current shell context. If <var>filename</var> does not contain a slash, | |
4051 | the <code>PATH</code> variable is used to find <var>filename</var>. | |
4052 | When Bash is not in <small>POSIX</small> mode, the current directory is searched | |
4053 | if <var>filename</var> is not found in <code>$PATH</code>. | |
4054 | If any <var>arguments</var> are supplied, they become the positional | |
4055 | parameters when <var>filename</var> is executed. Otherwise the positional | |
17345e5a | 4056 | parameters are unchanged. |
a0c0a00f CR |
4057 | If 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 | |
4059 | restored around the call to <code>source</code>, and <code>source</code> unsets the | |
4060 | <code>DEBUG</code> trap while it executes. | |
4061 | If <samp>-T</samp> is not set, and the sourced file changes | |
4062 | the <code>DEBUG</code> trap, the new value is retained when <code>source</code> completes. | |
17345e5a | 4063 | The return status is the exit status of the last command executed, or |
a0c0a00f | 4064 | zero if no commands are executed. If <var>filename</var> is not found, or |
17345e5a | 4065 | cannot be read, the return status is non-zero. |
a0c0a00f CR |
4066 | This 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. | |
4076 | If <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. | |
4078 | The 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>. | |
4088 | If <var>directory</var> is not supplied, the value of the <code>HOME</code> | |
ac50fbac | 4089 | shell variable is used. |
a0c0a00f | 4090 | Any additional arguments following <var>directory</var> are ignored. |
ac50fbac | 4091 | If the shell variable |
a0c0a00f CR |
4092 | <code>CDPATH</code> exists, it is used as a search path: |
4093 | each directory name in <code>CDPATH</code> is searched for | |
4094 | <var>directory</var>, with alternative directory names in <code>CDPATH</code> | |
4095 | separated by a colon (‘<samp>:</samp>’). | |
4096 | If <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 | |
4099 | are resolved while <code>cd</code> is traversing <var>directory</var> and before | |
4100 | processing an instance of ‘<samp>..</samp>’ in <var>directory</var>. | |
4101 | </p> | |
4102 | <p>By default, or when the <samp>-L</samp> option is supplied, symbolic links | |
4103 | in <var>directory</var> are resolved after <code>cd</code> processes an instance | |
4104 | of ‘<samp>..</samp>’ in <var>directory</var>. | |
4105 | </p> | |
4106 | <p>If ‘<samp>..</samp>’ appears in <var>directory</var>, it is processed by removing the | |
ac50fbac | 4107 | immediately preceding pathname component, back to a slash or the beginning |
a0c0a00f CR |
4108 | of <var>directory</var>. |
4109 | </p> | |
4110 | <p>If the <samp>-e</samp> option is supplied with <samp>-P</samp> | |
495aee44 | 4111 | and the current working directory cannot be successfully determined |
a0c0a00f | 4112 | after a successful directory change, <code>cd</code> will return an unsuccessful |
495aee44 | 4113 | status. |
a0c0a00f CR |
4114 | </p> |
4115 | <p>On systems that support it, the <samp>-@</samp> option presents the extended | |
ac50fbac | 4116 | attributes associated with a file as a directory. |
a0c0a00f CR |
4117 | </p> |
4118 | <p>If <var>directory</var> is ‘<samp>-</samp>’, it is converted to <code>$OLDPWD</code> | |
ac50fbac | 4119 | before 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 | ‘<samp>-</samp>’ is the first argument, and the directory change is | |
17345e5a JA |
4123 | successful, the absolute pathname of the new working directory is |
4124 | written to the standard output. | |
a0c0a00f CR |
4125 | </p> |
4126 | <p>The return status is zero if the directory is successfully changed, | |
17345e5a | 4127 | non-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. | |
4138 | If <var>n</var> is supplied, the execution of the <var>n</var>th enclosing loop | |
17345e5a | 4139 | is resumed. |
a0c0a00f CR |
4140 | <var>n</var> must be greater than or equal to 1. |
4141 | The 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 | 4151 | then read and executed, and its exit status returned as the exit status |
a0c0a00f | 4152 | of <code>eval</code>. |
17345e5a JA |
4153 | If there are no arguments or only empty arguments, the return status is |
4154 | zero. | |
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 | 4164 | is supplied, it replaces the shell without creating a new process. |
a0c0a00f CR |
4165 | If the <samp>-l</samp> option is supplied, the shell places a dash at the |
4166 | beginning of the zeroth argument passed to <var>command</var>. | |
4167 | This is what the <code>login</code> program does. | |
4168 | The <samp>-c</samp> option causes <var>command</var> to be executed with an empty | |
17345e5a | 4169 | environment. |
a0c0a00f CR |
4170 | If <samp>-a</samp> is supplied, the shell passes <var>name</var> as the zeroth |
4171 | argument to <var>command</var>. | |
4172 | If <var>command</var> | |
ac50fbac | 4173 | cannot be executed for some reason, a non-interactive shell exits, |
a0c0a00f | 4174 | unless the <code>execfail</code> shell option |
ac50fbac CR |
4175 | is enabled. In that case, it returns failure. |
4176 | An interactive shell returns failure if the file cannot be executed. | |
9a51695b | 4177 | A subshell exits unconditionally if <code>exec</code> fails. |
a0c0a00f | 4178 | If no <var>command</var> is specified, redirections may be used to affect |
17345e5a JA |
4179 | the current shell environment. If there are no redirection errors, the |
4180 | return 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’s parent. | |
4190 | If <var>n</var> is omitted, the exit status is that of the last command executed. | |
4191 | Any 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 | |
4201 | in the environment. If the <samp>-f</samp> option is supplied, the <var>name</var>s | |
17345e5a | 4202 | refer to shell functions; otherwise the names refer to shell variables. |
a0c0a00f CR |
4203 | The <samp>-n</samp> option means to no longer mark each <var>name</var> for export. |
4204 | If no <var>names</var> are supplied, or if the <samp>-p</samp> option is given, a | |
ac50fbac | 4205 | list of names of all exported variables is displayed. |
a0c0a00f CR |
4206 | The <samp>-p</samp> option displays output in a form that may be reused as input. |
4207 | If a variable name is followed by =<var>value</var>, the value of | |
4208 | the variable is set to <var>value</var>. | |
4209 | </p> | |
4210 | <p>The return status is zero unless an invalid option is supplied, one of | |
4211 | the names is not a valid shell variable name, or <samp>-f</samp> is supplied | |
17345e5a | 4212 | with 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 | 4223 | character is followed by a colon, the option is expected to have an |
ac50fbac | 4224 | argument, which should be separated from it by whitespace. |
a0c0a00f | 4225 | The colon (‘<samp>:</samp>’) and question mark (‘<samp>?</samp>’) may not be |
17345e5a | 4226 | used as option characters. |
a0c0a00f CR |
4227 | Each time it is invoked, <code>getopts</code> |
4228 | places the next option in the shell variable <var>name</var>, initializing | |
4229 | <var>name</var> if it does not exist, | |
17345e5a | 4230 | and the index of the next argument to be processed into the |
a0c0a00f CR |
4231 | variable <code>OPTIND</code>. |
4232 | <code>OPTIND</code> is initialized to 1 each time the shell or a shell script | |
17345e5a JA |
4233 | is invoked. |
4234 | When an option requires an argument, | |
a0c0a00f CR |
4235 | <code>getopts</code> places that argument into the variable <code>OPTARG</code>. |
4236 | The shell does not reset <code>OPTIND</code> automatically; it must be manually | |
4237 | reset between multiple calls to <code>getopts</code> within the same shell | |
17345e5a | 4238 | invocation 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 | 4241 | return value greater than zero. |
a0c0a00f CR |
4242 | <code>OPTIND</code> is set to the index of the first non-option argument, |
4243 | and <var>name</var> is set to ‘<samp>?</samp>’. | |
4244 | </p> | |
4245 | <p><code>getopts</code> | |
17345e5a | 4246 | normally parses the positional parameters, but if more arguments are |
a0c0a00f CR |
4247 | given 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 | 4251 | error reporting is used. In normal operation, diagnostic messages |
17345e5a JA |
4252 | are printed when invalid options or missing option arguments are |
4253 | encountered. | |
a0c0a00f | 4254 | If the variable <code>OPTERR</code> |
17345e5a | 4255 | is set to 0, no error messages will be displayed, even if the first |
a0c0a00f CR |
4256 | character of <code>optstring</code> is not a colon. |
4257 | </p> | |
4258 | <p>If an invalid option is seen, | |
4259 | <code>getopts</code> places ‘<samp>?</samp>’ into <var>name</var> and, if not silent, | |
4260 | prints an error message and unsets <code>OPTARG</code>. | |
4261 | If <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> | |
4265 | is not silent, a question mark (‘<samp>?</samp>’) is placed in <var>name</var>, | |
4266 | <code>OPTARG</code> is unset, and a diagnostic message is printed. | |
4267 | If <code>getopts</code> is silent, then a colon (‘<samp>:</samp>’) 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 | |
4278 | commands specified as <var>name</var> arguments, | |
17345e5a JA |
4279 | so they need not be searched for on subsequent invocations. |
4280 | The commands are found by searching through the directories listed in | |
a0c0a00f | 4281 | <code>$PATH</code>. |
495aee44 | 4282 | Any previously-remembered pathname is discarded. |
a0c0a00f CR |
4283 | The <samp>-p</samp> option inhibits the path search, and <var>filename</var> is |
4284 | used as the location of <var>name</var>. | |
4285 | The <samp>-r</samp> option causes the shell to forget all remembered locations. | |
4286 | The <samp>-d</samp> option causes the shell to forget the remembered location | |
4287 | of each <var>name</var>. | |
4288 | If 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 | 4290 | supplied with <samp>-t</samp>, the <var>name</var> is printed before the hashed |
17345e5a | 4291 | full pathname. |
a0c0a00f | 4292 | The <samp>-l</samp> option causes output to be displayed in a format |
17345e5a | 4293 | that may be reused as input. |
a0c0a00f | 4294 | If no arguments are given, or if only <samp>-l</samp> is supplied, |
17345e5a | 4295 | information about remembered commands is printed. |
a0c0a00f | 4296 | The return status is zero unless a <var>name</var> is not found or an invalid |
17345e5a | 4297 | option 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. | |
4307 | If the <samp>-P</samp> option is supplied, the pathname printed will not | |
17345e5a | 4308 | contain symbolic links. |
a0c0a00f | 4309 | If the <samp>-L</samp> option is supplied, the pathname printed may contain |
17345e5a JA |
4310 | symbolic links. |
4311 | The return status is zero unless an error is encountered while | |
4312 | determining the name of the current directory or an invalid option | |
4313 | is 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>]] … | |
4320 | </pre></div> | |
4321 | ||
4322 | <p>Mark each <var>name</var> as readonly. | |
17345e5a | 4323 | The values of these names may not be changed by subsequent assignment. |
a0c0a00f | 4324 | If the <samp>-f</samp> option is supplied, each <var>name</var> refers to a shell |
17345e5a | 4325 | function. |
a0c0a00f CR |
4326 | The <samp>-a</samp> option means each <var>name</var> refers to an indexed |
4327 | array variable; the <samp>-A</samp> option means each <var>name</var> refers | |
17345e5a | 4328 | to an associative array variable. |
a0c0a00f CR |
4329 | If both options are supplied, <samp>-A</samp> takes precedence. |
4330 | If no <var>name</var> arguments are given, or if the <samp>-p</samp> | |
17345e5a | 4331 | option is supplied, a list of all readonly names is printed. |
ac50fbac CR |
4332 | The other options may be used to restrict the output to a subset of |
4333 | the set of readonly names. | |
a0c0a00f | 4334 | The <samp>-p</samp> option causes output to be displayed in a format that |
17345e5a | 4335 | may be reused as input. |
a0c0a00f CR |
4336 | If a variable name is followed by =<var>value</var>, the value of |
4337 | the variable is set to <var>value</var>. | |
17345e5a | 4338 | The return status is zero unless an invalid option is supplied, one of |
a0c0a00f CR |
4339 | the <var>name</var> arguments is not a valid shell variable or function name, |
4340 | or 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 | 4350 | to its caller. |
a0c0a00f | 4351 | If <var>n</var> is not supplied, the return value is the exit status of the |
17345e5a | 4352 | last command executed in the function. |
a0c0a00f CR |
4353 | If <code>return</code> is executed by a trap handler, the last command used to |
4354 | determine the status is the last command executed before the trap handler. | |
9a51695b | 4355 | If <code>return</code> is executed during a <code>DEBUG</code> trap, the last command |
a0c0a00f CR |
4356 | used to determine the status is the last command executed by the trap |
4357 | handler before <code>return</code> was invoked. | |
4358 | <code>return</code> may also be used to terminate execution of a script | |
4359 | being executed with the <code>.</code> (<code>source</code>) builtin, | |
4360 | returning either <var>n</var> or | |
17345e5a JA |
4361 | the exit status of the last command executed within the script as the exit |
4362 | status of the script. | |
a0c0a00f | 4363 | If <var>n</var> is supplied, the return value is its least significant |
ac50fbac | 4364 | 8 bits. |
a0c0a00f | 4365 | Any command associated with the <code>RETURN</code> trap is executed |
17345e5a | 4366 | before execution resumes after the function or script. |
a0c0a00f | 4367 | The return status is non-zero if <code>return</code> is supplied a non-numeric |
ac50fbac | 4368 | argument or is used outside a function |
a0c0a00f CR |
4369 | and 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>. | |
4379 | The positional parameters from <var>n</var>+1 … <code>$#</code> are | |
4380 | renamed to <code>$1</code> … <code>$#</code>-<var>n</var>. | |
4381 | Parameters represented by the numbers <code>$#</code> to <code>$#</code>-<var>n</var>+1 | |
17345e5a | 4382 | are unset. |
a0c0a00f CR |
4383 | <var>n</var> must be a non-negative number less than or equal to <code>$#</code>. |
4384 | If <var>n</var> is zero or greater than <code>$#</code>, the positional parameters | |
17345e5a | 4385 | are not changed. |
a0c0a00f CR |
4386 | If <var>n</var> is not supplied, it is assumed to be 1. |
4387 | The return status is zero unless <var>n</var> is greater than <code>$#</code> or | |
17345e5a | 4388 | less 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 |
4401 | Each operator and operand must be a separate argument. |
4402 | Expressions 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 | |
4405 | an 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 | |
4408 | be a <code>]</code>. | |
4409 | </p> | |
4410 | <p>Expressions may be combined using the following operators, listed in | |
17345e5a JA |
4411 | decreasing order of precedence. |
4412 | The evaluation depends on the number of arguments; see below. | |
495aee44 | 4413 | Operator 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 | 4422 | This 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 | 4435 | expressions 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 ‘<samp>!</samp>’, the expression is true if and | |
17345e5a JA |
4448 | only if the second argument is null. |
4449 | If 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 |
4451 | is true if the unary test is true. |
4452 | If the first argument is not a valid unary operator, the expression is | |
4453 | false. | |
a0c0a00f CR |
4454 | </p> |
4455 | </dd> | |
4456 | <dt>3 arguments</dt> | |
4457 | <dd><p>The following conditions are applied in the order listed. | |
495aee44 | 4458 | If the second argument is one of the binary conditional |
a0c0a00f | 4459 | operators (see <a href="#Bash-Conditional-Expressions">Bash Conditional Expressions</a>), the |
17345e5a JA |
4460 | result of the expression is the result of the binary test using the |
4461 | first and third arguments as operands. | |
a0c0a00f | 4462 | The ‘<samp>-a</samp>’ and ‘<samp>-o</samp>’ operators are considered binary operators |
17345e5a | 4463 | when there are three arguments. |
a0c0a00f | 4464 | If the first argument is ‘<samp>!</samp>’, the value is the negation of |
17345e5a | 4465 | the two-argument test using the second and third arguments. |
a0c0a00f CR |
4466 | If the first argument is exactly ‘<samp>(</samp>’ and the third argument is |
4467 | exactly ‘<samp>)</samp>’, the result is the one-argument test of the second | |
17345e5a JA |
4468 | argument. |
4469 | Otherwise, the expression is false. | |
a0c0a00f CR |
4470 | </p> |
4471 | </dd> | |
4472 | <dt>4 arguments</dt> | |
4473 | <dd><p>If the first argument is ‘<samp>!</samp>’, the result is the negation of | |
17345e5a | 4474 | the three-argument expression composed of the remaining arguments. |
a0c0a00f | 4475 | Otherwise, the expression is parsed and evaluated according to |
17345e5a | 4476 | precedence 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 | 4481 | using the rules listed above. |
a0c0a00f CR |
4482 | </p></dd> |
4483 | </dl> | |
17345e5a | 4484 | |
a0c0a00f | 4485 | <p>When used with <code>test</code> or ‘<samp>[</samp>’, the ‘<samp><</samp>’ and ‘<samp>></samp>’ |
495aee44 | 4486 | operators 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 | 4496 | The 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> …] | |
4503 | </pre></div> | |
4504 | ||
4505 | <p>The commands in <var>arg</var> are to be read and executed when the | |
4506 | shell receives signal <var>sigspec</var>. If <var>arg</var> is absent (and | |
4507 | there is a single <var>sigspec</var>) or | |
4508 | equal to ‘<samp>-</samp>’, each specified signal’s disposition is reset | |
17345e5a | 4509 | to the value it had when the shell was started. |
a0c0a00f CR |
4510 | If <var>arg</var> is the null string, then the signal specified by |
4511 | each <var>sigspec</var> is ignored by the shell and commands it invokes. | |
4512 | If <var>arg</var> is not present and <samp>-p</samp> has been supplied, | |
4513 | the shell displays the trap commands associated with each <var>sigspec</var>. | |
17345e5a | 4514 | If no arguments are supplied, or |
a0c0a00f | 4515 | only <samp>-p</samp> is given, <code>trap</code> prints the list of commands |
17345e5a JA |
4516 | associated with each signal number in a form that may be reused as |
4517 | shell input. | |
a0c0a00f | 4518 | The <samp>-l</samp> option causes the shell to print a list of signal names |
17345e5a | 4519 | and their corresponding numbers. |
a0c0a00f CR |
4520 | Each <var>sigspec</var> is either a signal name or a signal number. |
4521 | Signal names are case insensitive and the <code>SIG</code> prefix is optional. | |
4522 | </p> | |
4523 | <p>If a <var>sigspec</var> | |
4524 | is <code>0</code> or <code>EXIT</code>, <var>arg</var> is executed when the shell exits. | |
4525 | If a <var>sigspec</var> is <code>DEBUG</code>, the command <var>arg</var> is executed | |
4526 | before 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 | 4528 | the first command executes in a shell function. |
a0c0a00f CR |
4529 | Refer 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 | |
4531 | effect on the <code>DEBUG</code> trap. | |
4532 | If a <var>sigspec</var> is <code>RETURN</code>, the command <var>arg</var> is executed | |
4533 | each 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 |
4537 | is executed whenever |
4538 | a pipeline (which may consist of a single simple | |
a0c0a00f | 4539 | command), a list, or a compound command returns a |
ac50fbac | 4540 | non-zero exit status, |
17345e5a | 4541 | subject to the following conditions. |
a0c0a00f CR |
4542 | The <code>ERR</code> trap is not executed if the failed command is part of the |
4543 | command list immediately following an <code>until</code> or <code>while</code> keyword, | |
4544 | part of the test following the <code>if</code> or <code>elif</code> reserved words, | |
4545 | part of a command executed in a <code>&&</code> or <code>||</code> list | |
4546 | except the command following the final <code>&&</code> or <code>||</code>, | |
ac50fbac | 4547 | any command in a pipeline but the last, |
a0c0a00f CR |
4548 | or if the command’s return |
4549 | status is being inverted using <code>!</code>. | |
4550 | These are the same conditions obeyed by the <code>errexit</code> (<samp>-e</samp>) | |
ac50fbac | 4551 | option. |
a0c0a00f CR |
4552 | </p> |
4553 | <p>Signals ignored upon entry to the shell cannot be trapped or reset. | |
17345e5a | 4554 | Trapped signals that are not being ignored are reset to their original |
0001803f | 4555 | values 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 | 4558 | valid 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’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 | 4569 | if not, it is interpreted as a symbolic mode mask similar |
a0c0a00f CR |
4570 | to that accepted by the <code>chmod</code> command. If <var>mode</var> is |
4571 | omitted, the current value of the mask is printed. If the <samp>-S</samp> | |
4572 | option is supplied without a <var>mode</var> argument, the mask is printed | |
17345e5a | 4573 | in a symbolic format. |
a0c0a00f | 4574 | If the <samp>-p</samp> option is supplied, and <var>mode</var> |
17345e5a JA |
4575 | is omitted, the output is in a form that may be reused as input. |
4576 | The return status is zero if the mode is successfully changed or if | |
a0c0a00f CR |
4577 | no <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 | |
4580 | of the umask is subtracted from <code>7</code>. Thus, a umask of <code>022</code> | |
4581 | results 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>. | |
4591 | If the <samp>-v</samp> option is given, each | |
4592 | <var>name</var> refers to a shell variable and that variable is removed. | |
4593 | If the <samp>-f</samp> option is given, the <var>name</var>s refer to shell | |
17345e5a | 4594 | functions, and the function definition is removed. |
a0c0a00f CR |
4595 | If the <samp>-n</samp> option is supplied, and <var>name</var> is a variable with |
4596 | the <var>nameref</var> attribute, <var>name</var> will be unset rather than the | |
ac50fbac | 4597 | variable it references. |
a0c0a00f CR |
4598 | <samp>-n</samp> has no effect if the <samp>-f</samp> option is supplied. |
4599 | If no options are supplied, each <var>name</var> refers to a variable; if | |
ac50fbac CR |
4600 | there is no variable by that name, any function with that name is |
4601 | unset. | |
17345e5a | 4602 | Readonly variables and functions may not be unset. |
a0c0a00f CR |
4603 | The 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> | |
4611 | Next: <a href="#Modifying-Shell-Behavior" accesskey="n" rel="next">Modifying Shell Behavior</a>, Previous: <a href="#Bourne-Shell-Builtins" accesskey="p" rel="prev">Bourne Shell Builtins</a>, Up: <a href="#Shell-Builtin-Commands" accesskey="u" rel="up">Shell Builtin Commands</a> [<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 | 4617 | or have been extended in Bash. |
a0c0a00f CR |
4618 | Some 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>] …] | |
4625 | </pre></div> | |
4626 | ||
4627 | <p>Without arguments or with the <samp>-p</samp> option, <code>alias</code> prints | |
17345e5a JA |
4628 | the list of aliases on the standard output in a form that allows |
4629 | them to be reused as input. | |
a0c0a00f CR |
4630 | If arguments are supplied, an alias is defined for each <var>name</var> |
4631 | whose <var>value</var> is given. If no <var>value</var> is given, the name | |
17345e5a | 4632 | and value of the alias is printed. |
a0c0a00f CR |
4633 | Aliases 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] | |
4640 | bind [-m <var>keymap</var>] [-q <var>function</var>] [-u <var>function</var>] [-r <var>keyseq</var>] | |
4641 | bind [-m <var>keymap</var>] -f <var>filename</var> | |
4642 | bind [-m <var>keymap</var>] -x <var>keyseq:shell-command</var> | |
4643 | bind [-m <var>keymap</var>] <var>keyseq:function-name</var> | |
4644 | bind [-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 |
4648 | key and function bindings, |
4649 | bind a key sequence to a Readline function or macro, | |
4650 | or set a Readline variable. | |
4651 | Each non-option argument is a command as it would appear in a | |
a0c0a00f | 4652 | Readline initialization file (see <a href="#Readline-Init-File">Readline Init File</a>), |
17345e5a | 4653 | but each binding or command must be passed as a separate argument; e.g., |
a0c0a00f CR |
4654 | ‘<samp>"\C-x\C-r":re-read-init-file</samp>’. |
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 | |
4661 | the subsequent bindings. Acceptable <var>keymap</var> | |
17345e5a | 4662 | names 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 | |
4672 | synonym); <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 | 4681 | can 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 | 4690 | can 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 |
4699 | in such a way that they can be used as input or in a Readline |
4700 | initialization 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 | 4725 | entered. |
a0c0a00f CR |
4726 | When <var>shell-command</var> is executed, the shell sets the |
4727 | <code>READLINE_LINE</code> variable to the contents of the Readline line | |
4728 | buffer and the <code>READLINE_POINT</code> variable to the current location | |
17345e5a | 4729 | of the insertion point. |
a0c0a00f CR |
4730 | If 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 | 4732 | editing 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 | 4737 | in 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 | 4742 | error 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 |
4752 | This is useful when defining a shell function with the same |
4753 | name as a shell builtin, retaining the functionality of the builtin within | |
4754 | the function. | |
a0c0a00f | 4755 | The return status is non-zero if <var>shell-builtin</var> is not a shell |
17345e5a | 4756 | builtin 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 | |
4766 | a 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 | 4769 | filename of the current subroutine call. |
a0c0a00f | 4770 | If a non-negative integer is supplied as <var>expr</var>, <code>caller</code> |
17345e5a JA |
4771 | displays the line number, subroutine name, and source file corresponding |
4772 | to that position in the current execution call stack. This extra | |
4773 | information may be used, for example, to print a stack trace. The | |
4774 | current frame is frame 0. | |
a0c0a00f CR |
4775 | </p> |
4776 | <p>The return value is 0 unless the shell is not executing a subroutine | |
4777 | call or <var>expr</var> does not correspond to a valid position in the | |
17345e5a | 4778 | call 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> …] | |
4785 | </pre></div> | |
4786 | ||
4787 | <p>Runs <var>command</var> with <var>arguments</var> ignoring any shell function | |
4788 | named <var>command</var>. | |
17345e5a | 4789 | Only shell builtin commands or commands found by searching the |
a0c0a00f CR |
4790 | <code>PATH</code> are executed. |
4791 | If there is a shell function named <code>ls</code>, running ‘<samp>command ls</samp>’ | |
4792 | within the function will execute the external command <code>ls</code> | |
17345e5a | 4793 | instead of calling the function recursively. |
a0c0a00f | 4794 | The <samp>-p</samp> option means to use a default value for <code>PATH</code> |
17345e5a | 4795 | that is guaranteed to find all of the standard utilities. |
a0c0a00f CR |
4796 | The return status in this case is 127 if <var>command</var> cannot be |
4797 | found or an error occurred, and the exit status of <var>command</var> | |
17345e5a | 4798 | otherwise. |
a0c0a00f CR |
4799 | </p> |
4800 | <p>If either the <samp>-V</samp> or <samp>-v</samp> option is supplied, a | |
4801 | description of <var>command</var> is printed. The <samp>-v</samp> option | |
17345e5a | 4802 | causes a single word indicating the command or file name used to |
a0c0a00f | 4803 | invoke <var>command</var> to be displayed; the <samp>-V</samp> option produces |
17345e5a | 4804 | a more verbose description. In this case, the return status is |
a0c0a00f CR |
4805 | zero 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>] …] | |
4812 | </pre></div> | |
4813 | ||
4814 | <p>Declare variables and give them attributes. If no <var>name</var>s | |
17345e5a | 4815 | are 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>. | |
4819 | When <samp>-p</samp> is used with <var>name</var> arguments, additional options, | |
4820 | other 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 |
4823 | will display the attributes and values of all variables having the |
4824 | attributes specified by the additional options. | |
a0c0a00f CR |
4825 | If no other options are supplied with <samp>-p</samp>, <code>declare</code> will |
4826 | display the attributes and values of all shell variables. The <samp>-f</samp> | |
17345e5a | 4827 | option 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 | 4830 | only the function name and attributes are printed. |
a0c0a00f CR |
4831 | If 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 | |
4833 | each <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 | |
4837 | the global scope, even when <code>declare</code> is executed in a shell function. | |
495aee44 | 4838 | It 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 | 4841 | the 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 | |
4858 | an integer; arithmetic evaluation (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>) is | |
17345e5a | 4859 | performed 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 |
4864 | converted to lower-case. |
4865 | The 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 | 4870 | it a name reference to another variable. |
a0c0a00f CR |
4871 | That other variable is defined by the value of <var>name</var>. |
4872 | All references, assignments, and attribute modifications | |
4873 | to <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>’s value. | |
4876 | The 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 | 4881 | by 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. | |
4886 | Traced functions inherit the <code>DEBUG</code> and <code>RETURN</code> traps from | |
17345e5a JA |
4887 | the calling shell. |
4888 | The 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 |
4893 | converted to upper-case. |
4894 | The 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 | 4899 | the environment. |
a0c0a00f CR |
4900 | </p></dd> |
4901 | </dl> | |
17345e5a | 4902 | |
a0c0a00f CR |
4903 | <p>Using ‘<samp>+</samp>’ instead of ‘<samp>-</samp>’ turns off the attribute instead, |
4904 | with the exceptions that ‘<samp>+a</samp>’ | |
4905 | may not be used to destroy an array variable and ‘<samp>+r</samp>’ will not | |
17345e5a | 4906 | remove the readonly attribute. |
a0c0a00f CR |
4907 | When used in a function, <code>declare</code> makes each <var>name</var> local, |
4908 | as with the <code>local</code> command, unless the <samp>-g</samp> option is used. | |
4909 | If a variable name is followed by =<var>value</var>, the value of the variable | |
4910 | is 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 |
4913 | create array variables, additional attributes do not take effect until |
4914 | subsequent assignments. | |
a0c0a00f CR |
4915 | </p> |
4916 | <p>The return status is zero unless an invalid option is encountered, | |
4917 | an attempt is made to define a function using ‘<samp>-f foo=bar</samp>’, | |
17345e5a JA |
4918 | an attempt is made to assign a value to a readonly variable, |
4919 | an attempt is made to assign a value to an array variable without | |
a0c0a00f CR |
4920 | using the compound assignment syntax (see <a href="#Arrays">Arrays</a>), |
4921 | one of the <var>names</var> is not a valid shell variable name, | |
17345e5a JA |
4922 | an attempt is made to turn off readonly status for a readonly variable, |
4923 | an attempt is made to turn off array status for an array variable, | |
a0c0a00f CR |
4924 | or 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> …] | |
4931 | </pre></div> | |
4932 | ||
4933 | <p>Output the <var>arg</var>s, separated by spaces, terminated with a | |
17345e5a | 4934 | newline. |
ac50fbac | 4935 | The return status is 0 unless a write error occurs. |
a0c0a00f CR |
4936 | If <samp>-n</samp> is specified, the trailing newline is suppressed. |
4937 | If the <samp>-e</samp> option is given, interpretation of the following | |
17345e5a | 4938 | backslash-escaped characters is enabled. |
a0c0a00f | 4939 | The <samp>-E</samp> option disables the interpretation of these escape characters, |
17345e5a | 4940 | even on systems where they are interpreted by default. |
a0c0a00f CR |
4941 | The <code>xpg_echo</code> shell option may be used to |
4942 | dynamically determine whether or not <code>echo</code> expands these | |
17345e5a | 4943 | escape 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> …] | |
5002 | </pre></div> | |
5003 | ||
5004 | <p>Enable and disable builtin shell commands. | |
17345e5a JA |
5005 | Disabling a builtin allows a disk command which has the same name |
5006 | as a shell builtin to be executed without specifying a full pathname, | |
5007 | even though the shell normally searches for builtins before disk commands. | |
a0c0a00f CR |
5008 | If <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 | |
5010 | found via <code>$PATH</code> instead of the shell builtin version, type | |
5011 | ‘<samp>enable -n test</samp>’. | |
5012 | </p> | |
5013 | <p>If the <samp>-p</samp> option is supplied, or no <var>name</var> arguments appear, | |
17345e5a JA |
5014 | a list of shell builtins is printed. With no other arguments, the list |
5015 | consists of all enabled shell builtins. | |
a0c0a00f | 5016 | The <samp>-a</samp> option means to list |
17345e5a | 5017 | each 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> | |
5020 | from shared object <var>filename</var>, on systems that support dynamic loading. | |
5021 | The <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. | |
5024 | The <samp>-s</samp> option restricts <code>enable</code> to the <small>POSIX</small> special | |
5025 | builtins. If <samp>-s</samp> is used with <samp>-f</samp>, the new builtin becomes | |
5026 | a 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 | 5029 | or 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. | |
5039 | If <var>pattern</var> is specified, <code>help</code> gives detailed help | |
5040 | on all commands matching <var>pattern</var>, otherwise a list of | |
17345e5a | 5041 | the 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> …] | |
5064 | </pre></div> | |
5065 | ||
5066 | <p>The <code>let</code> builtin allows arithmetic to be performed on shell | |
5067 | variables. Each <var>expression</var> is evaluated according to the | |
5068 | rules given below in <a href="#Shell-Arithmetic">Shell Arithmetic</a>. If the | |
5069 | last <var>expression</var> evaluates to 0, <code>let</code> returns 1; | |
17345e5a | 5070 | otherwise 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>] … | |
5077 | </pre></div> | |
5078 | ||
5079 | <p>For each argument, a local variable named <var>name</var> is created, | |
5080 | and assigned <var>value</var>. | |
5081 | The <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 | |
5084 | children. | |
5085 | If <var>name</var> is ‘<samp>-</samp>’, the set of shell options is made local to the | |
5086 | function in which <code>local</code> is invoked: shell options changed using | |
5087 | the <code>set</code> builtin inside the function are restored to their original | |
5088 | values when the function returns. | |
5089 | The return status is zero unless <code>local</code> is used outside | |
5090 | a function, an invalid <var>name</var> is supplied, or <var>name</var> is a | |
17345e5a | 5091 | readonly 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’s | |
17345e5a | 5101 | parent. |
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>, | |
5112 | or from file descriptor <var>fd</var> | |
5113 | if the <samp>-u</samp> option is supplied. | |
5114 | The variable <code>MAPFILE</code> is the default <var>array</var>. | |
17345e5a | 5115 | Options, 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, | |
5120 | rather than newline. | |
9a51695b CR |
5121 | If <var>delim</var> is the empty string, <code>mapfile</code> will terminate a line |
5122 | when 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 | 5129 | The 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 |
5142 | The <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 | 5150 | the default quantum is 5000. |
a0c0a00f | 5151 | When <var>callback</var> is evaluated, it is supplied the index of the next |
495aee44 CR |
5152 | array element to be assigned and the line to be assigned to that element |
5153 | as additional arguments. | |
a0c0a00f | 5154 | <var>callback</var> is evaluated after the line is read but before the |
17345e5a | 5155 | array 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 | 5158 | before assigning to it. |
a0c0a00f CR |
5159 | </p> |
5160 | <p><code>mapfile</code> returns successfully unless an invalid option or option | |
5161 | argument is supplied, <var>array</var> is invalid or unassignable, or <var>array</var> | |
0001803f | 5162 | is 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 | |
5172 | control of the <var>format</var>. | |
5173 | The <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 |
5177 | plain characters, which are simply copied to standard output, character |
5178 | escape sequences, which are converted and copied to the standard output, and | |
5179 | format specifications, each of which causes printing of the next successive | |
a0c0a00f CR |
5180 | <var>argument</var>. |
5181 | In addition to the standard <code>printf(1)</code> formats, <code>printf</code> | |
495aee44 | 5182 | interprets 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 | |
5187 | corresponding <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 | |
5192 | corresponding <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). | |
5197 | The corresponding <var>argument</var> is an integer representing the number of | |
ac50fbac CR |
5198 | seconds since the epoch. |
5199 | Two special argument values may be used: -1 represents the current | |
495aee44 | 5200 | time, and -2 represents the time the shell was invoked. |
ac50fbac | 5201 | If no argument is specified, conversion behaves as if -1 had been given. |
a0c0a00f CR |
5202 | This 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 |
5207 | except that a leading plus or minus sign is allowed, and if the leading |
5208 | character is a single or double quote, the value is the ASCII value of | |
5209 | the following character. | |
a0c0a00f CR |
5210 | </p> |
5211 | <p>The <var>format</var> is reused as necessary to consume all of the <var>arguments</var>. | |
5212 | If the <var>format</var> requires more <var>arguments</var> than are supplied, the | |
17345e5a JA |
5213 | extra format specifications behave as if a zero value or null string, as |
5214 | appropriate, had been supplied. The return value is zero on success, | |
5215 | non-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> …] | |
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, | |
5227 | split into words as described above in <a href="#Word-Splitting">Word Splitting</a>, | |
5228 | and the first word | |
5229 | is assigned to the first <var>name</var>, the second word to the second <var>name</var>, | |
5230 | and so on. | |
5231 | If there are more words than names, | |
5232 | the remaining words and their intervening delimiters are assigned | |
5233 | to the last <var>name</var>. | |
17345e5a JA |
5234 | If there are fewer words read from the input stream than names, |
5235 | the remaining names are assigned empty values. | |
a0c0a00f | 5236 | The characters in the value of the <code>IFS</code> variable |
ac50fbac | 5237 | are used to split the line into words using the same rules the shell |
a0c0a00f CR |
5238 | uses for expansion (described above in <a href="#Word-Splitting">Word Splitting</a>). |
5239 | The backslash character ‘<samp>\</samp>’ may be used to remove any special | |
17345e5a JA |
5240 | meaning for the next character read and for line continuation. |
5241 | If no names are supplied, the line read is assigned to the | |
a0c0a00f CR |
5242 | variable <code>REPLY</code>. |
5243 | The exit status is zero, unless end-of-file is encountered, <code>read</code> | |
5244 | times out (in which case the status is greater than 128), | |
ac50fbac | 5245 | a variable assignment error (such as assigning to a readonly variable) occurs, |
a0c0a00f CR |
5246 | or 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. | |
5254 | All elements are removed from <var>aname</var> before the assignment. | |
5255 | Other <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 | 5260 | rather than newline. |
9a51695b CR |
5261 | If <var>delim</var> is the empty string, <code>read</code> will terminate a line |
5262 | when 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 | 5267 | Readline uses the current (or default, if line editing was not previously |
9a51695b | 5268 | active) editing settings, but uses Readline’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 | 5273 | the 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 | |
5278 | waiting for a complete line of input, but honors a delimiter if fewer | |
5279 | than <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 | 5284 | than waiting for a complete line of input, unless EOF is encountered or |
a0c0a00f | 5285 | <code>read</code> times out. |
0001803f | 5286 | Delimiter characters encountered in the input are |
a0c0a00f CR |
5287 | not treated specially and do not cause <code>read</code> to return until |
5288 | <var>nchars</var> characters are read. | |
5289 | The result is not split on the characters in <code>IFS</code>; the intent is | |
5290 | that 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 |
5296 | to read any input. |
5297 | The 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 |
5302 | The backslash is considered to be part of the line. |
5303 | In particular, a backslash-newline pair may not be used as a line | |
5304 | continuation. | |
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 | 5309 | not 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 | 5314 | input (or a specified number of characters) |
a0c0a00f CR |
5315 | is not read within <var>timeout</var> seconds. |
5316 | <var>timeout</var> may be a decimal number with a fractional portion following | |
17345e5a | 5317 | the decimal point. |
a0c0a00f | 5318 | This option is only effective if <code>read</code> is reading input from a |
17345e5a JA |
5319 | terminal, pipe, or other special file; it has no effect when reading |
5320 | from regular files. | |
a0c0a00f CR |
5321 | If <code>read</code> times out, <code>read</code> saves any partial input read into |
5322 | the specified variable <var>name</var>. | |
5323 | If <var>timeout</var> is 0, <code>read</code> returns immediately, without trying to | |
ac50fbac CR |
5324 | read and data. The exit status is 0 if input is available on |
5325 | the specified file descriptor, non-zero otherwise. | |
17345e5a | 5326 | The 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>, | |
5343 | or from file descriptor <var>fd</var> | |
5344 | if 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> …] | |
5362 | </pre></div> | |
5363 | ||
5364 | <p>For each <var>name</var>, indicate how it would be interpreted if used as a | |
17345e5a | 5365 | command name. |
a0c0a00f CR |
5366 | </p> |
5367 | <p>If the <samp>-t</samp> option is used, <code>type</code> prints a single word | |
5368 | which is one of ‘<samp>alias</samp>’, ‘<samp>function</samp>’, ‘<samp>builtin</samp>’, | |
5369 | ‘<samp>file</samp>’ or ‘<samp>keyword</samp>’, | |
5370 | if <var>name</var> is an alias, shell function, shell builtin, | |
17345e5a | 5371 | disk file, or shell reserved word, respectively. |
a0c0a00f CR |
5372 | If 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 | |
5376 | of the disk file that would be executed, or nothing if <samp>-t</samp> | |
5377 | would not return ‘<samp>file</samp>’. | |
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 ‘<samp>file</samp>’. | |
5381 | </p> | |
5382 | <p>If a command is hashed, <samp>-p</samp> and <samp>-P</samp> print the hashed value, | |
5383 | which 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 | |
5386 | that contain an executable named <var>file</var>. | |
5387 | This includes aliases and functions, if and only if the <samp>-p</samp> option | |
17345e5a | 5388 | is 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 | |
5391 | shell 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 | 5394 | if 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>] …] | |
5401 | </pre></div> | |
5402 | ||
5403 | <p>The <code>typeset</code> command is supplied for compatibility with the Korn | |
ac50fbac | 5404 | shell. |
a0c0a00f CR |
5405 | It 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 |
5415 | started by the shell, on systems that allow such control. If an |
5416 | option 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’s data segment. | |
5441 | </p> | |
5442 | </dd> | |
5443 | <dt><code>-e</code></dt> | |
5444 | <dd><p>The maximum scheduling priority ("nice"). | |
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 | 5469 | allow 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 | 5498 | some 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. | |
5516 | The 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 |
5518 | and no limit, respectively. |
5519 | A hard limit cannot be increased by a non-root user once it is set; | |
5520 | a soft limit may be increased up to the value of the hard limit. | |
5521 | Otherwise, the current value of the soft limit for the specified resource | |
a0c0a00f CR |
5522 | is printed, unless the <samp>-H</samp> option is supplied. |
5523 | When setting new limits, if neither <samp>-H</samp> nor <samp>-S</samp> is supplied, | |
17345e5a | 5524 | both the hard and soft limits are set. |
a0c0a00f CR |
5525 | If no option is given, then <samp>-f</samp> is assumed. Values are in 1024-byte |
5526 | increments, except for <samp>-t</samp>, which is in seconds; <samp>-p</samp>, | |
5527 | which 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; | |
5533 | and, 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 | 5537 | or 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> … ] | |
5544 | </pre></div> | |
5545 | ||
5546 | <p>Remove each <var>name</var> from the list of aliases. If <samp>-a</samp> is | |
17345e5a | 5547 | supplied, all aliases are removed. |
a0c0a00f CR |
5548 | Aliases 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> | |
5556 | Next: <a href="#Special-Builtins" accesskey="n" rel="next">Special Builtins</a>, Previous: <a href="#Bash-Builtins" accesskey="p" rel="prev">Bash Builtins</a>, Up: <a href="#Shell-Builtin-Commands" accesskey="u" rel="up">Shell Builtin Commands</a> [<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">• <a href="#The-Set-Builtin" accesskey="1">The Set Builtin</a>:</td><td> </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">• <a href="#The-Shopt-Builtin" accesskey="2">The Shopt Builtin</a>:</td><td> </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> | |
5573 | Next: <a href="#The-Shopt-Builtin" accesskey="n" rel="next">The Shopt Builtin</a>, Up: <a href="#Modifying-Shell-Behavior" accesskey="u" rel="up">Modifying Shell Behavior</a> [<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 |
5579 | allows you to change the values of shell options and set the positional |
5580 | parameters, 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> …] | |
5587 | set [+abefhkmnptuvxBCEHPT] [+o <var>option-name</var>] [<var>argument</var> …] | |
5588 | </pre></div> | |
5589 | ||
5590 | <p>If no options or arguments are supplied, <code>set</code> displays the names | |
17345e5a JA |
5591 | and values of all shell variables and functions, sorted according to the |
5592 | current locale, in a format that may be reused as input | |
5593 | for setting or resetting the currently-set variables. | |
5594 | Read-only variables cannot be reset. | |
a0c0a00f CR |
5595 | In <small>POSIX</small> mode, only shell variables are listed. |
5596 | </p> | |
5597 | <p>When options are supplied, they set or unset shell attributes. | |
17345e5a | 5598 | Options, 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 | |
5603 | export attribute and marked for export to the environment of | |
5604 | subsequent 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 | 5609 | immediately, 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 | |
5614 | a pipeline (see <a href="#Pipelines">Pipelines</a>), which may consist of a single simple command | |
5615 | (see <a href="#Simple-Commands">Simple Commands</a>), | |
5616 | a list (see <a href="#Lists">Lists</a>), | |
5617 | or a compound command (see <a href="#Compound-Commands">Compound Commands</a>) | |
0001803f CR |
5618 | returns a non-zero status. |
5619 | The shell does not exit if the command that fails is part of the | |
a0c0a00f CR |
5620 | command list immediately following a <code>while</code> or <code>until</code> keyword, |
5621 | part of the test in an <code>if</code> statement, | |
5622 | part of any command executed in a <code>&&</code> or <code>||</code> list except | |
5623 | the command following the final <code>&&</code> or <code>||</code>, | |
17345e5a | 5624 | any command in a pipeline but the last, |
a0c0a00f | 5625 | or if the command’s return status is being inverted with <code>!</code>. |
ac50fbac CR |
5626 | If a compound command other than a subshell |
5627 | returns a non-zero status because a command failed | |
a0c0a00f CR |
5628 | while <samp>-e</samp> was being ignored, the shell does not exit. |
5629 | A 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 | |
5632 | separately (see <a href="#Command-Execution-Environment">Command Execution Environment</a>), and may cause | |
0001803f | 5633 | subshells 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 | 5637 | none of the commands executed within the compound command or function body |
a0c0a00f | 5638 | will be affected by the <samp>-e</samp> setting, even if <samp>-e</samp> is set |
ac50fbac | 5639 | and a command returns a failure status. |
a0c0a00f CR |
5640 | If a compound command or shell function sets <samp>-e</samp> while executing in |
5641 | a context where <samp>-e</samp> is ignored, that setting will not have any | |
ac50fbac CR |
5642 | effect until the compound command or the command containing the function |
5643 | call 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 | 5652 | This 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 |
5657 | in the environment for a command, not just those that precede |
5658 | the 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 |
5663 | All processes run in a separate process group. |
5664 | When a background job completes, the shell prints a line | |
5665 | containing 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. | |
5670 | This may be used to check a script for syntax errors. | |
17345e5a | 5671 | This 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>). | |
5689 | This 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 | 5714 | This 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 |
5764 | commands in the pipeline exit successfully. | |
5765 | This 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 | |
5770 | from the <small>POSIX</small> standard to match the standard | |
5771 | (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>). | |
17345e5a JA |
5772 | This is intended to make Bash behave as a strict superset of that |
5773 | standard. | |
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. | |
5786 | This 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. | |
5797 | In this mode, the <code>$BASH_ENV</code> and <code>$ENV</code> files are not | |
17345e5a | 5798 | processed, shell functions are not inherited from the environment, |
a0c0a00f | 5799 | and the <code>SHELLOPTS</code>, <code>BASHOPTS</code>, <code>CDPATH</code> and <code>GLOBIGNORE</code> |
0001803f | 5800 | variables, if they appear in the environment, are ignored. |
17345e5a | 5801 | If the shell is started with the effective user (group) id not equal to the |
a0c0a00f | 5802 | real user (group) id, and the <samp>-p</samp> option is not supplied, these actions |
17345e5a | 5803 | are taken and the effective user id is set to the real user id. |
a0c0a00f | 5804 | If the <samp>-p</samp> option is supplied at startup, the effective user id is |
17345e5a JA |
5805 | not reset. |
5806 | Turning this option off causes the effective user | |
5807 | and 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 | ‘<samp>@</samp>’ or ‘<samp>*</samp>’ as an error when performing parameter expansion. | |
17345e5a JA |
5817 | An error message will be written to the standard error, and a non-interactive |
5818 | shell 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> | |
5827 | commands, <code>select</code> commands, and arithmetic <code>for</code> commands | |
17345e5a | 5828 | and their arguments or associated word lists after they are |
a0c0a00f | 5829 | expanded and before they are executed. The value of the <code>PS4</code> |
17345e5a JA |
5830 | variable is expanded and the resultant value is printed before |
5831 | the 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 | 5836 | This option is on by default. |
a0c0a00f CR |
5837 | </p> |
5838 | </dd> | |
5839 | <dt><code>-C</code></dt> | |
5840 | <dd><p>Prevent output redirection using ‘<samp>></samp>’, ‘<samp>>&</samp>’, and ‘<samp><></samp>’ | |
17345e5a | 5841 | from 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 | 5846 | substitutions, and commands executed in a subshell environment. |
a0c0a00f CR |
5847 | The <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 ‘<samp>!</samp>’ style history substitution (see <a href="#History-Interaction">History Interaction</a>). | |
17345e5a | 5852 | This 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 |
5858 | is used instead. By default, Bash follows |
5859 | the logical chain of directories when performing commands | |
5860 | which 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 | 5863 | then: |
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 |
5882 | shell functions, command substitutions, and commands executed |
5883 | in a subshell environment. | |
a0c0a00f | 5884 | The <code>DEBUG</code> and <code>RETURN</code> traps are normally not inherited |
17345e5a | 5885 | in 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 | 5890 | unset. Otherwise, the positional parameters are set to the |
a0c0a00f CR |
5891 | <var>arguments</var>, even if some of them begin with a ‘<samp>-</samp>’. |
5892 | </p> | |
5893 | </dd> | |
5894 | <dt><code>-</code></dt> | |
5895 | <dd><p>Signal the end of options, cause all remaining <var>arguments</var> | |
5896 | to be assigned to the positional parameters. The <samp>-x</samp> | |
5897 | and <samp>-v</samp> options are turned off. | |
17345e5a | 5898 | If there are no arguments, the positional parameters remain unchanged. |
a0c0a00f CR |
5899 | </p></dd> |
5900 | </dl> | |
17345e5a | 5901 | |
a0c0a00f | 5902 | <p>Using ‘<samp>+</samp>’ rather than ‘<samp>-</samp>’ causes these options to be |
17345e5a | 5903 | turned off. The options can also be used upon invocation of the |
a0c0a00f CR |
5904 | shell. 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 | |
5907 | assigned, in order, to <code>$1</code>, <code>$2</code>, … <code>$N</code>. | |
5908 | The 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> | |
5918 | Previous: <a href="#The-Set-Builtin" accesskey="p" rel="prev">The Set Builtin</a>, Up: <a href="#Modifying-Shell-Behavior" accesskey="u" rel="up">Modifying Shell Behavior</a> [<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> …] | |
5930 | </pre></div> | |
5931 | ||
5932 | <p>Toggle the values of settings controlling optional shell behavior. | |
ac50fbac | 5933 | The 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> |
5935 | option to the <code>set</code> builtin command (see <a href="#The-Set-Builtin">The Set Builtin</a>). | |
5936 | With no options, or with the <samp>-p</samp> option, a list of all settable | |
9a51695b CR |
5937 | options is displayed, with an indication of whether or not each is set; |
5938 | if <var>optnames</var> are supplied, the output is restricted to those options. | |
a0c0a00f | 5939 | The <samp>-p</samp> option causes output to be displayed in a form that |
17345e5a JA |
5940 | may be reused as input. |
5941 | Other 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 | |
5954 | indicates whether the <var>optname</var> is set or unset. | |
5955 | If multiple <var>optname</var> arguments are given with <samp>-q</samp>, | |
5956 | the return status is zero if all <var>optnames</var> are enabled; | |
17345e5a | 5957 | non-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> | |
5968 | is used with no <var>optname</var> arguments, <code>shopt</code> shows only | |
17345e5a | 5969 | those 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 | 5972 | by default. |
a0c0a00f CR |
5973 | </p> |
5974 | <p>The return status when listing options is zero if all <var>optnames</var> | |
17345e5a | 5975 | are enabled, non-zero otherwise. When setting or unsetting options, |
a0c0a00f | 5976 | the return status is zero unless an <var>optname</var> is not a valid shell |
17345e5a | 5977 | option. |
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 | |
5983 | subscripts during arithmetic expression evaluation and while executing | |
5984 | builtins 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 | |
5989 | it were the argument to the <code>cd</code> command. | |
17345e5a | 5990 | This 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 |
5995 | is not a directory is assumed to be the name of a variable whose |
5996 | value 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 |
6002 | The errors checked for are transposed characters, |
6003 | a missing character, and a character too many. | |
6004 | If a correction is found, the corrected path is printed, | |
6005 | and the command proceeds. | |
6006 | This 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 |
6011 | table exists before trying to execute it. If a hashed command no |
6012 | longer 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 |
6017 | exiting an interactive shell. If any jobs are running, this causes |
6018 | the exit to be deferred until a second exit is attempted without an | |
a0c0a00f | 6019 | intervening command (see <a href="#Job-Control">Job Control</a>). |
17345e5a | 6020 | The 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) |
6025 | command 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 |
6031 | attempts to save all lines of a multiple-line |
6032 | command in the same history entry. This allows | |
6033 | easy re-editing of multi-line commands. | |
9a51695b CR |
6034 | This option is enabled by default, but only has an effect if command |
6035 | history 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 | 6040 | changes its behavior to that of version 3.1 with respect to quoted |
a0c0a00f | 6041 | arguments to the conditional command’s ‘<samp>=~</samp>’ operator |
ac50fbac | 6042 | and with respect to locale-specific |
a0c0a00f CR |
6043 | string comparison when using the <code>[[</code> |
6044 | conditional command’s ‘<samp><</samp>’ and ‘<samp>></samp>’ operators. | |
ac50fbac | 6045 | Bash versions prior to bash-4.1 use ASCII collation and strcmp(3); |
a0c0a00f CR |
6046 | bash-4.1 and later use the current locale’s collation sequence and strcoll(3). |
6047 | </p> | |
6048 | </dd> | |
6049 | <dt><code>compat32</code></dt> | |
6050 | <dd><p>If set, Bash | |
495aee44 | 6051 | changes its behavior to that of version 3.2 with respect to locale-specific |
a0c0a00f CR |
6052 | string comparison when using the <code>[[</code> |
6053 | conditional command’s ‘<samp><</samp>’ and ‘<samp>></samp>’ operators (see previous item) | |
6054 | and the effect of interrupting a command list. | |
6055 | Bash versions 3.2 and earlier continue with the next command in the list | |
6056 | after one terminates due to an interrupt. | |
6057 | </p> | |
6058 | </dd> | |
6059 | <dt><code>compat40</code></dt> | |
6060 | <dd><p>If set, Bash | |
495aee44 | 6061 | changes its behavior to that of version 4.0 with respect to locale-specific |
a0c0a00f CR |
6062 | string comparison when using the <code>[[</code> |
6063 | conditional command’s ‘<samp><</samp>’ and ‘<samp>></samp>’ operators (see description | |
6064 | of <code>compat31</code>) | |
495aee44 | 6065 | and the effect of interrupting a command list. |
ac50fbac CR |
6066 | Bash versions 4.0 and later interrupt the list as if the shell received the |
6067 | interrupt; 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 |
6072 | parameter expansion as a special character. The single quotes must match |
6073 | (an even number) and the characters between the single quotes are considered | |
a0c0a00f | 6074 | quoted. This is the behavior of <small>POSIX</small> mode through version 4.1. |
495aee44 | 6075 | The 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 |
6080 | does not process the replacement string in the pattern substitution word |
6081 | expansion using quote removal. | |
a0c0a00f CR |
6082 | </p> |
6083 | </dd> | |
6084 | <dt><code>compat43</code></dt> | |
6085 | <dd><p>If set, Bash | |
6086 | does not print a warning message if an attempt is made to use a quoted compound | |
6087 | array assignment as an argument to <code>declare</code>, | |
6088 | makes word expansion errors | |
6089 | non-fatal errors that cause the current command to fail (the default behavior is | |
6090 | to make them fatal errors that cause the shell to exit), | |
6091 | and does not reset the | |
6092 | loop 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’s context). | |
6094 | </p> | |
6095 | </dd> | |
9a51695b CR |
6096 | <dt><code>compat44</code></dt> |
6097 | <dd><p>If set, Bash | |
6098 | saves the positional parameters to BASH_ARGV and BASH_ARGC before they are | |
6099 | used, 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 |
6104 | quotes all shell metacharacters in filenames and directory names when |
6105 | performing completion. | |
6106 | If not set, Bash | |
6107 | removes metacharacters such as the dollar sign from the set of | |
6108 | characters that will be quoted in completed filenames | |
6109 | when these metacharacters appear in shell variable references in words to be | |
6110 | completed. | |
6111 | This means that dollar signs in variable names that expand to directories | |
6112 | will not be quoted; | |
6113 | however, any dollar signs appearing in filenames will not be quoted, either. | |
6114 | This is active only when bash is using backslashes to quote completed | |
6115 | filenames. | |
6116 | This variable is set by default, which is the default Bash behavior in | |
6117 | versions through 4.2. | |
a0c0a00f CR |
6118 | </p> |
6119 | </dd> | |
6120 | <dt><code>direxpand</code></dt> | |
6121 | <dd><p>If set, Bash | |
ac50fbac CR |
6122 | replaces directory names with the results of word expansion when performing |
6123 | filename completion. This changes the contents of the readline editing | |
6124 | buffer. | |
6125 | If 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 |
6130 | attempts spelling correction on directory names during word completion |
6131 | if 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 ‘.’ in | |
17345e5a | 6136 | the results of filename expansion. |
9a51695b CR |
6137 | The filenames ‘<samp>.</samp>’ and ‘<samp>..</samp>’ must always be matched explicitly, |
6138 | even 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 | |
6143 | it cannot execute the file specified as an argument to the <code>exec</code> | |
6144 | builtin command. An interactive shell does not exit if <code>exec</code> | |
17345e5a | 6145 | fails. |
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 | 6151 | This 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 | |
6156 | before the shell starts, identical to the <samp>--debugger</samp> option. | |
6157 | If 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 |
6161 | displays the source file name and line number corresponding to each function |
6162 | name 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 | 6165 | next 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 | 6168 | shell is executing in a subroutine (a shell function or a shell script |
a0c0a00f CR |
6169 | executed by the <code>.</code> or <code>source</code> builtins), the shell simulates |
6170 | a call to <code>return</code>. | |
6171 | ||
6172 | </li><li> <code>BASH_ARGC</code> and <code>BASH_ARGV</code> are updated as described in their | |
6173 | descriptions (see <a href="#Bash-Variables">Bash Variables</a>). | |
6174 | ||
6175 | </li><li> Function tracing is enabled: command substitution, shell functions, and | |
6176 | subshells 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 | |
6180 | subshells 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>$"<var>string</var>"</code> quoting is | |
6192 | performed within <code>${<var>parameter</var>}</code> expansions | |
17345e5a | 6193 | enclosed 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 | 6198 | result 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 |
6203 | cause words to be ignored when performing word completion even if |
6204 | the ignored words are the only possible completions. | |
a0c0a00f | 6205 | See <a href="#Bash-Variables">Bash Variables</a>, for a description of <code>FIGNORE</code>. |
17345e5a | 6206 | This 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 | 6212 | behave as if in the traditional C locale when performing |
a0c0a00f | 6213 | comparisons. That is, the current locale’s collating sequence |
ac50fbac | 6214 | is not taken into account, so |
a0c0a00f | 6215 | ‘<samp>b</samp>’ will not collate between ‘<samp>A</samp>’ and ‘<samp>B</samp>’, |
ac50fbac | 6216 | and 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 ‘<samp>**</samp>’ used in a filename expansion context will | |
ac50fbac | 6221 | match all files and zero or more directories and subdirectories. |
a0c0a00f | 6222 | If the pattern is followed by a ‘<samp>/</samp>’, only directories and |
17345e5a | 6223 | subdirectories 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 | 6228 | message 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 | |
6233 | of the <code>HISTFILE</code> | |
17345e5a | 6234 | variable 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 |
6239 | is being used, a user is given the opportunity to re-edit a |
6240 | failed history substitution. | |
a0c0a00f CR |
6241 | </p> |
6242 | </dd> | |
6243 | <dt><code>histverify</code></dt> | |
6244 | <dd><p>If set, and Readline | |
17345e5a JA |
6245 | is being used, the results of history substitution are not immediately |
6246 | passed to the shell parser. Instead, the resulting line is loaded into | |
6247 | the 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 | |
6252 | hostname completion when a word containing a ‘<samp>@</samp>’ is being | |
6253 | completed (see <a href="#Commands-For-Completion">Commands For Completion</a>). This option is enabled | |
17345e5a | 6254 | by 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 | |
6259 | login 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, | |
6264 | instead of unsetting it in the subshell environment. | |
6265 | This 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 ‘<samp>#</samp>’ | |
17345e5a JA |
6270 | to cause that word and all remaining characters on that |
6271 | line to be ignored in an interactive shell. | |
6272 | This 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 | 6277 | a 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 |
6282 | option is enabled, multi-line commands are saved to the history with |
6283 | embedded 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 | |
6288 | the same name that exists at a previous scope before any new value is | |
6289 | assigned. 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 | 6295 | The 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 | 6300 | accessed since the last time it was checked, the message |
a0c0a00f CR |
6301 | <code>"The mail in <var>mailfile</var> has been read"</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 | |
6306 | the <code>PATH</code> for possible completions when completion is attempted | |
17345e5a | 6307 | on 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 | 6312 | performing 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 | |
6317 | performing matching while executing <code>case</code> or <code>[[</code> | |
6318 | conditional commands, | |
6319 | when performing pattern substitution word expansions, | |
6320 | or 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 | 6325 | files 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 | 6331 | This 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 |
6336 | parameter expansion, command substitution, arithmetic |
6337 | expansion, and quote removal after being expanded | |
a0c0a00f | 6338 | as described below (see <a href="#Controlling-the-Prompt">Controlling the Prompt</a>). |
17345e5a | 6339 | This 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 |
6345 | The value may not be changed. |
6346 | This is not reset when the startup files are executed, allowing | |
6347 | the 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 |
6352 | builtin prints an error message when the shift count exceeds the |
6353 | number 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 |
6358 | to find the directory containing the file supplied as an argument. |
6359 | This 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 | 6364 | by 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 |
6370 | are enabled, non-zero otherwise. |
6371 | When 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> | |
6380 | Previous: <a href="#Modifying-Shell-Behavior" accesskey="p" rel="prev">Modifying Shell Behavior</a>, Up: <a href="#Shell-Builtin-Commands" accesskey="u" rel="up">Shell Builtin Commands</a> [<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 | |
6387 | several builtin commands as <em>special</em>. | |
6388 | When Bash is executing in <small>POSIX</small> mode, the special builtins | |
17345e5a | 6389 | differ 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 | 6397 | environment 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 | 6401 | differently than the rest of the Bash builtin commands. |
a0c0a00f CR |
6402 | The 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 --> | |
6407 | shift trap unset<!-- /@w --> | |
6408 | </pre></div> | |
6409 | ||
6410 | <hr> | |
6411 | <a name="Shell-Variables"></a> | |
6412 | <div class="header"> | |
6413 | <p> | |
6414 | Next: <a href="#Bash-Features" accesskey="n" rel="next">Bash Features</a>, Previous: <a href="#Shell-Builtin-Commands" accesskey="p" rel="prev">Shell Builtin Commands</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<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">• <a href="#Bourne-Shell-Variables" accesskey="1">Bourne Shell Variables</a>:</td><td> </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">• <a href="#Bash-Variables" accesskey="2">Bash Variables</a>:</td><td> </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 | 6428 | Bash 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> | |
6434 | Next: <a href="#Bash-Variables" accesskey="n" rel="next">Bash Variables</a>, Up: <a href="#Shell-Variables" accesskey="u" rel="up">Shell Variables</a> [<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 | 6440 | In 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 | |
6447 | the <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’s home directory; the default for the <code>cd</code> builtin | |
17345e5a JA |
6454 | command. |
6455 | The 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 | 6463 | words 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 | |
6470 | and the <code>MAILPATH</code> variable | |
17345e5a | 6471 | is not set, Bash informs the user of the arrival of mail in |
495aee44 | 6472 | the 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 |
6479 | for new mail. |
6480 | Each list entry can specify the message that is printed when new mail | |
ac50fbac | 6481 | arrives in the mail file by separating the filename from the message with |
a0c0a00f CR |
6482 | a ‘<samp>?</samp>’. |
6483 | When used in the text of the message, <code>$_</code> expands to the name of | |
17345e5a | 6484 | the 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 | 6503 | commands. |
a0c0a00f | 6504 | A zero-length (null) directory name in the value of <code>PATH</code> indicates the |
17345e5a JA |
6505 | current directory. |
6506 | A null directory name may appear as two adjacent colons, or as an initial | |
6507 | or 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 ‘<samp>\s-\v\$ </samp>’. | |
6514 | See <a href="#Controlling-the-Prompt">Controlling the Prompt</a>, for the complete list of escape | |
6515 | sequences 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 ‘<samp>> </samp>’. | |
9a51695b CR |
6522 | <code>PS2</code> is expanded in the same way as <code>PS1</code> before being |
6523 | displayed. | |
a0c0a00f CR |
6524 | </p> |
6525 | </dd> | |
6526 | </dl> | |
6527 | ||
6528 | <hr> | |
6529 | <a name="Bash-Variables"></a> | |
6530 | <div class="header"> | |
6531 | <p> | |
6532 | Previous: <a href="#Bourne-Shell-Variables" accesskey="p" rel="prev">Bourne Shell Variables</a>, Up: <a href="#Shell-Variables" accesskey="u" rel="up">Shell Variables</a> [<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 | 6538 | do not normally treat them specially. |
a0c0a00f CR |
6539 | </p> |
6540 | <p>A few variables used by Bash are described in different chapters: | |
17345e5a | 6541 | variables 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 | |
6555 | the 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>). | |
6557 | The options appearing in <code>BASHOPTS</code> are those reported | |
6558 | as ‘<samp>on</samp>’ by ‘<samp>shopt</samp>’. | |
0001803f CR |
6559 | If this variable is in the environment when Bash |
6560 | starts up, each shell option in the list will be enabled before | |
6561 | reading 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. | |
6568 | This differs from <code>$$</code> under certain circumstances, such as subshells | |
17345e5a | 6569 | that do not require Bash to be re-initialized. |
9a51695b CR |
6570 | Assignments to <code>BASHPID</code> have no effect. |
6571 | If <code>BASHPID</code> | |
6572 | is unset, it loses its special properties, even if it is | |
6573 | subsequently 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 | |
6580 | list of aliases as maintained by the <code>alias</code> builtin. | |
6581 | (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>). | |
6582 | Elements added to this array appear in the alias list; however, | |
6583 | unsetting array elements currently does not cause aliases to be removed | |
6584 | from the alias list. | |
6585 | If <code>BASH_ALIASES</code> | |
6586 | is unset, it loses its special properties, even if it is | |
6587 | subsequently 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 |
6594 | frame of the current bash execution call stack. The number of |
6595 | parameters to the current subroutine (shell function or script executed | |
a0c0a00f | 6596 | with <code>.</code> or <code>source</code>) is at the top of the stack. When a |
17345e5a | 6597 | subroutine is executed, the number of parameters passed is pushed onto |
a0c0a00f CR |
6598 | <code>BASH_ARGC</code>. |
6599 | The shell sets <code>BASH_ARGC</code> only when in extended debugging mode | |
6600 | (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a> | |
6601 | for a description of the <code>extdebug</code> option to the <code>shopt</code> | |
17345e5a | 6602 | builtin). |
2f5dfe5a CR |
6603 | Setting <code>extdebug</code> after the shell has started to execute a script, |
6604 | or referencing this variable when <code>extdebug</code> is not set, | |
9a51695b | 6605 | may 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 |
6612 | execution call stack. The final parameter of the last subroutine call |
6613 | is at the top of the stack; the first parameter of the initial call is | |
6614 | at the bottom. When a subroutine is executed, the parameters supplied | |
a0c0a00f CR |
6615 | are pushed onto <code>BASH_ARGV</code>. |
6616 | The shell sets <code>BASH_ARGV</code> only when in extended debugging mode | |
6617 | (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a> | |
6618 | for a description of the <code>extdebug</code> option to the <code>shopt</code> | |
17345e5a | 6619 | builtin). |
2f5dfe5a CR |
6620 | Setting <code>extdebug</code> after the shell has started to execute a script, |
6621 | or referencing this variable when <code>extdebug</code> is not set, | |
9a51695b CR |
6622 | may 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 | |
6629 | script (identical to <code>$0</code>; See <a href="#Special-Parameters">Special Parameters</a>, | |
6630 | for the description of special parameter 0). | |
6631 | Assignment to <code>BASH_ARGV0</code> | |
6632 | causes the value assigned to also be assigned to <code>$0</code>. | |
6633 | If <code>BASH_ARGV0</code> | |
6634 | is unset, it loses its special properties, even if it is | |
6635 | subsequently 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 | |
6642 | hash table of commands as maintained by the <code>hash</code> builtin | |
6643 | (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>). | |
6644 | Elements added to this array appear in the hash table; however, | |
6645 | unsetting array elements currently does not cause command names to be removed | |
6646 | from the hash table. | |
6647 | If <code>BASH_CMDS</code> | |
6648 | is unset, it loses its special properties, even if it is | |
6649 | subsequently 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 |
6656 | shell is executing a command as the result of a trap, |
6657 | in 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’s compatibility level. | |
6664 | See <a href="#The-Shopt-Builtin">The Shopt Builtin</a>, for a description of the various compatibility | |
ac50fbac CR |
6665 | levels and their effects. |
6666 | The value may be a decimal number (e.g., 4.2) or an integer (e.g., 42) | |
6667 | corresponding to the desired compatibility level. | |
a0c0a00f | 6668 | If <code>BASH_COMPAT</code> is unset or set to the empty string, the compatibility |
ac50fbac | 6669 | level is set to the default for the current version. |
a0c0a00f | 6670 | If <code>BASH_COMPAT</code> is set to a value that is not one of the valid |
ac50fbac CR |
6671 | compatibility levels, the shell prints an error message and sets the |
6672 | compatibility level to the default for the current version. | |
6673 | The valid compatibility levels correspond to the compatibility options | |
a0c0a00f CR |
6674 | accepted by the <code>shopt</code> builtin described above (for example, |
6675 | <var>compat42</var> means that 4.2 and 42 are valid values). | |
ac50fbac | 6676 | The 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 | 6683 | script, its value is expanded and used as the name of a startup file |
a0c0a00f CR |
6684 | to 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 | |
6697 | where 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 | 6701 | referenced within another shell function). |
a0c0a00f CR |
6702 | Use <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 | |
6709 | dynamically 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 ‘<samp>=~</samp>’ binary | |
6717 | operator to the <code>[[</code> conditional command | |
6718 | (see <a href="#Conditional-Constructs">Conditional Constructs</a>). | |
17345e5a JA |
6719 | The element with index 0 is the portion of the string |
6720 | matching the entire regular expression. | |
a0c0a00f CR |
6721 | The element with index <var>n</var> is the portion of the |
6722 | string matching the <var>n</var>th parenthesized subexpression. | |
17345e5a | 6723 | This 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 | |
6730 | corresponding shell function names in the <code>FUNCNAME</code> array | |
495aee44 | 6731 | variable are defined. |
a0c0a00f CR |
6732 | The 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 | 6740 | the shell begins executing in that environment. |
17345e5a | 6741 | The 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 |
6748 | whose members hold version information for this instance of Bash. |
6749 | The 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 | |
6788 | will write the trace output generated when ‘<samp>set -x</samp>’ | |
0001803f CR |
6789 | is enabled to that file descriptor. |
6790 | This allows tracing output to be separated from diagnostic and error | |
6791 | messages. | |
a0c0a00f | 6792 | The file descriptor is closed when <code>BASH_XTRACEFD</code> is unset or assigned |
0001803f | 6793 | a new value. |
a0c0a00f | 6794 | Unsetting <code>BASH_XTRACEFD</code> or assigning it the empty string causes the |
0001803f | 6795 | trace output to be sent to the standard error. |
a0c0a00f | 6796 | Note that setting <code>BASH_XTRACEFD</code> to 2 (the standard error file |
0001803f CR |
6797 | descriptor) and then unsetting it will result in the standard error |
6798 | being 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. | |
6805 | Bash will not allow this value to be decreased below a <small>POSIX</small>-mandated | |
ac50fbac CR |
6806 | minimum, and there is a maximum value (currently 8192) that this may |
6807 | not exceed. | |
6808 | The 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 | 6815 | when printing selection lists. |
a0c0a00f CR |
6816 | Automatically 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 |
6825 | cursor position. |
6826 | This variable is available only in shell functions invoked by the | |
a0c0a00f CR |
6827 | programmable 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 |
6834 | This variable is available only in shell functions and external |
6835 | commands invoked by the | |
a0c0a00f CR |
6836 | programmable 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 |
6843 | the current command. |
6844 | If the current cursor position is at the end of the current command, | |
a0c0a00f | 6845 | the value of this variable is equal to <code>${#COMP_LINE}</code>. |
17345e5a JA |
6846 | This variable is available only in shell functions and external |
6847 | commands invoked by the | |
a0c0a00f CR |
6848 | programmable 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 | 6855 | that caused a completion function to be called: |
a0c0a00f CR |
6856 | <var>TAB</var>, for normal completion, |
6857 | ‘<samp>?</samp>’, for listing completions after successive tabs, | |
6858 | ‘<samp>!</samp>’, for listing alternatives on partial word completion, | |
6859 | ‘<samp>@</samp>’, to list completions if the word is not unmodified, | |
17345e5a | 6860 | or |
a0c0a00f | 6861 | ‘<samp>%</samp>’, for menu completion. |
17345e5a JA |
6862 | This variable is available only in shell functions and external |
6863 | commands invoked by the | |
a0c0a00f CR |
6864 | programmable 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 | 6871 | completion 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 | 6878 | separators when performing word completion. |
a0c0a00f | 6879 | If <code>COMP_WORDBREAKS</code> is unset, it loses its special properties, |
17345e5a | 6880 | even 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 | 6887 | words in the current command line. |
0001803f | 6888 | The line is split into words as Readline would split it, using |
a0c0a00f | 6889 | <code>COMP_WORDBREAKS</code> as described above. |
17345e5a | 6890 | This variable is available only in shell functions invoked by the |
a0c0a00f CR |
6891 | programmable 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 | 6898 | generated by a shell function invoked by the programmable completion |
a0c0a00f | 6899 | facility (see <a href="#Programmable-Completion">Programmable Completion</a>). |
ac50fbac | 6900 | Each 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 | |
6907 | for 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 | 6914 | Directories appear in the stack in the order they are displayed by the |
a0c0a00f | 6915 | <code>dirs</code> builtin. |
17345e5a | 6916 | Assigning to members of this array variable may be used to modify |
a0c0a00f | 6917 | directories already in the stack, but the <code>pushd</code> and <code>popd</code> |
17345e5a JA |
6918 | builtins must be used to add and remove directories. |
6919 | Assignment to this variable will not change the current directory. | |
a0c0a00f | 6920 | If <code>DIRSTACK</code> is unset, it loses its special properties, even if |
17345e5a | 6921 | it 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 | |
6928 | starts with value ‘<samp>t</samp>’, it assumes that the shell is running in an | |
495aee44 | 6929 | Emacs 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 | |
6943 | since 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 | |
6945 | definition of Epoch). | |
6946 | Assignments to <code>EPOCHREALTIME</code> are ignored. | |
6947 | If <code>EPOCHREALTIME</code> is unset, it loses its special properties, even if | |
6948 | it 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 | |
6955 | since the Unix Epoch (see the documentation for the C library function | |
6956 | <var>time</var> for the definition of Epoch). | |
6957 | Assignments to <code>EPOCHSECONDS</code> are ignored. | |
6958 | If <code>EPOCHSECONDS</code> is unset, it loses its special properties, even if | |
6959 | it 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 | 6966 | is 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>) | |
6973 | defining the list of filenames to be ignored by command search using | |
6974 | <code>PATH</code>. | |
6975 | Files whose full pathnames match one of these patterns are not considered | |
6976 | executable files for the purposes of completion and command execution | |
6977 | via <code>PATH</code> lookup. | |
6978 | This does not affect the behavior of the <code>[</code>, <code>test</code>, and <code>[[</code> | |
6979 | commands. | |
6980 | Full pathnames in the command hash table are not subject to <code>EXECIGNORE</code>. | |
6981 | Use this variable to ignore shared library files that have the executable | |
6982 | bit set, but are not executable files. | |
6983 | The pattern matching honors the setting of the <code>extglob</code> shell | |
6984 | option. | |
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 | 6991 | builtin 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 | 6998 | filename completion. |
ac50fbac | 6999 | A filename whose suffix matches one of the entries in |
a0c0a00f | 7000 | <code>FIGNORE</code> |
ac50fbac | 7001 | is excluded from the list of matched filenames. A sample |
a0c0a00f CR |
7002 | value is ‘<samp>.o:~</samp>’ |
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 |
7009 | currently in the execution call stack. |
7010 | The element with index 0 is the name of any currently-executing | |
7011 | shell function. | |
495aee44 | 7012 | The bottom-most element (the one with the highest index) |
a0c0a00f | 7013 | is <code>"main"</code>. |
17345e5a | 7014 | This variable exists only when a shell function is executing. |
a0c0a00f CR |
7015 | Assignments to <code>FUNCNAME</code> have no effect. |
7016 | If <code>FUNCNAME</code> is unset, it loses its special properties, even if | |
17345e5a | 7017 | it is subsequently reset. |
a0c0a00f CR |
7018 | </p> |
7019 | <p>This variable can be used with <code>BASH_LINENO</code> and <code>BASH_SOURCE</code>. | |
7020 | Each element of <code>FUNCNAME</code> has corresponding elements in | |
7021 | <code>BASH_LINENO</code> and <code>BASH_SOURCE</code> to describe the call stack. | |
7022 | For 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>. | |
7024 | The <code>caller</code> builtin displays the current call stack using this | |
495aee44 | 7025 | information. |
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 |
7032 | nesting level. Function invocations that exceed this nesting level |
7033 | will 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 | 7040 | be ignored by filename expansion. |
9a51695b | 7041 | If a file name matched by a filename expansion pattern also matches one |
a0c0a00f | 7042 | of the patterns in <code>GLOBIGNORE</code>, it is removed from the list |
17345e5a | 7043 | of matches. |
a0c0a00f CR |
7044 | The pattern matching honors the setting of the <code>extglob</code> shell |
7045 | option. | |
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 | 7052 | user is a member. |
a0c0a00f CR |
7053 | Assignments to <code>GROUPS</code> have no effect. |
7054 | If <code>GROUPS</code> is unset, it loses its special properties, even if it is | |
17345e5a | 7055 | subsequently 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 | |
7062 | substitution, and tokenization (see <a href="#History-Interaction">History Interaction</a>). | |
17345e5a | 7063 | The first character is the |
a0c0a00f CR |
7064 | <var>history expansion</var> character, that is, the character which signifies the |
7065 | start of a history expansion, normally ‘<samp>!</samp>’. The second character is the | |
7066 | character which signifies ‘quick substitution’ when seen as the first | |
7067 | character on a line, normally ‘<samp>^</samp>’. The optional third character is the | |
17345e5a | 7068 | character which indicates that the remainder of the line is a comment when |
a0c0a00f | 7069 | found as the first character of a word, usually ‘<samp>#</samp>’. The history |
17345e5a JA |
7070 | comment character causes history substitution to be skipped for the |
7071 | remaining words on the line. It does not necessarily cause the shell | |
7072 | parser 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 | |
7079 | command. If <code>HISTCMD</code> is unset, it loses its special properties, | |
17345e5a | 7080 | even 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 | 7087 | the history list. |
a0c0a00f | 7088 | If the list of values includes ‘<samp>ignorespace</samp>’, lines which begin |
17345e5a | 7089 | with a space character are not saved in the history list. |
a0c0a00f | 7090 | A value of ‘<samp>ignoredups</samp>’ causes lines which match the previous |
17345e5a | 7091 | history entry to not be saved. |
a0c0a00f CR |
7092 | A value of ‘<samp>ignoreboth</samp>’ is shorthand for |
7093 | ‘<samp>ignorespace</samp>’ and ‘<samp>ignoredups</samp>’. | |
7094 | A value of ‘<samp>erasedups</samp>’ causes all previous lines matching the | |
17345e5a JA |
7095 | current line to be removed from the history list before that line |
7096 | is saved. | |
7097 | Any value not in the above list is ignored. | |
a0c0a00f | 7098 | If <code>HISTCONTROL</code> is unset, or does not include a valid value, |
17345e5a | 7099 | all lines read by the shell parser are saved on the history list, |
a0c0a00f | 7100 | subject to the value of <code>HISTIGNORE</code>. |
17345e5a JA |
7101 | The second and subsequent lines of a multi-line compound command are |
7102 | not 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 | |
7110 | default 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 |
7117 | When this variable is assigned a value, the history file is truncated, |
7118 | if necessary, to contain no more than that number of lines | |
7119 | by removing the oldest entries. | |
17345e5a | 7120 | The history file is also truncated to this size after |
ac50fbac CR |
7121 | writing it when a shell exits. |
7122 | If the value is 0, the history file is truncated to zero size. | |
7123 | Non-numeric values and numeric values less than zero inhibit truncation. | |
a0c0a00f | 7124 | The shell sets the default value to the value of <code>HISTSIZE</code> |
ac50fbac | 7125 | after 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 |
7132 | lines should be saved on the history list. Each pattern is |
7133 | anchored at the beginning of the line and must match the complete | |
a0c0a00f CR |
7134 | line (no implicit ‘<samp>*</samp>’ is appended). Each pattern is tested |
7135 | against the line after the checks specified by <code>HISTCONTROL</code> | |
17345e5a | 7136 | are applied. In addition to the normal shell pattern matching |
a0c0a00f | 7137 | characters, ‘<samp>&</samp>’ matches the previous history line. ‘<samp>&</samp>’ |
17345e5a JA |
7138 | may be escaped using a backslash; the backslash is removed |
7139 | before attempting a match. | |
7140 | The second and subsequent lines of a multi-line compound command are | |
7141 | not tested, and are added to the history regardless of the value of | |
a0c0a00f CR |
7142 | <code>HISTIGNORE</code>. |
7143 | The pattern matching honors the setting of the <code>extglob</code> shell | |
7144 | option. | |
7145 | </p> | |
7146 | <p><code>HISTIGNORE</code> subsumes the function of <code>HISTCONTROL</code>. A | |
7147 | pattern of ‘<samp>&</samp>’ is identical to <code>ignoredups</code>, and a | |
7148 | pattern of ‘<samp>[ ]*</samp>’ is identical to <code>ignorespace</code>. | |
17345e5a | 7149 | Combining these two patterns, separating them with a colon, |
a0c0a00f CR |
7150 | provides 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 |
7157 | If the value is 0, commands are not saved in the history list. |
7158 | Numeric values less than zero result in every command being saved | |
7159 | on the history list (there is no limit). | |
7160 | The 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 | |
7167 | for <var>strftime</var> to print the time stamp associated with each history | |
7168 | entry displayed by the <code>history</code> builtin. | |
17345e5a JA |
7169 | If this variable is set, time stamps are written to the history file so |
7170 | they may be preserved across shell sessions. | |
7171 | This uses the history comment character to distinguish timestamps from | |
7172 | other 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 |
7179 | should be read when the shell needs to complete a hostname. |
7180 | The list of possible hostname completions may be changed while the shell | |
7181 | is running; | |
7182 | the next time hostname completion is attempted after the | |
7183 | value is changed, Bash adds the contents of the new file to the | |
7184 | existing list. | |
a0c0a00f | 7185 | If <code>HOSTFILE</code> is set, but has no value, or does not name a readable file, |
0001803f | 7186 | Bash attempts to read |
a0c0a00f CR |
7187 | <samp>/etc/hosts</samp> to obtain the list of possible hostname completions. |
7188 | When <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 | 7207 | as the sole input. If set, the value denotes the number |
a0c0a00f | 7208 | of consecutive <code>EOF</code> characters that can be read as the |
17345e5a JA |
7209 | first character on an input line |
7210 | before the shell will exit. If the variable exists but does not | |
2f5dfe5a | 7211 | have a numeric value, or has no value, then the default is 10. |
a0c0a00f | 7212 | If the variable does not exist, then <code>EOF</code> signifies the end of |
17345e5a | 7213 | input 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 | |
7220 | of <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 | |
7227 | starts, it assumes that the shell is running in an Emacs shell buffer | |
7228 | and 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 | |
7235 | selected 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 |
7249 | results of filename expansion, and |
7250 | determines the behavior of range expressions, equivalence classes, | |
7251 | and 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 | 7259 | behavior of character classes within filename expansion and pattern |
a0c0a00f CR |
7260 | matching (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 | |
7267 | strings preceded by a ‘<samp>$</samp>’ (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 | |
7280 | formatting. | |
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 | 7293 | for printing selection lists. |
a0c0a00f CR |
7294 | Automatically 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 | |
7303 | is 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 | |
7310 | files specified in the <code>MAILPATH</code> or <code>MAIL</code> variables. | |
17345e5a JA |
7311 | The default is 60 seconds. When it is time to check |
7312 | for mail, the shell does so before displaying the primary prompt. | |
7313 | If this variable is unset, or set to a value that is not a number | |
7314 | greater 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 | |
7334 | generated 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 |
7347 | containing a list of exit status values from the processes |
7348 | in the most-recently-executed foreground pipeline (which may | |
7349 | contain 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 | |
7356 | enters <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>) before reading the | |
7357 | startup files, as if the <samp>--posix</samp> invocation option had been supplied. | |
7358 | If it is set while the shell is running, Bash enables <small>POSIX</small> mode, | |
17345e5a | 7359 | as 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. |
7364 | When the shell enters <small>POSIX</small> mode, it sets this variable if it was | |
7365 | not 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’s parent process. This variable | |
17345e5a | 7372 | is 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 | |
7379 | before 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 | |
7386 | trailing 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 | 7388 | Characters 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> | |
7395 | and displayed by interactive shells after reading a command | |
7396 | and 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 ‘<samp>#? </samp>’ | |
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> |
7411 | and the expanded value is the prompt printed before the command line | |
7412 | is echoed when the <samp>-x</samp> option is set (see <a href="#The-Set-Builtin">The Set Builtin</a>). | |
7413 | The first character of the expanded value is replicated multiple times, | |
7414 | as necessary, to indicate multiple levels of indirection. | |
a0c0a00f CR |
7415 | The default is ‘<samp>+ </samp>’. |
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 |
7428 | between 0 and 32767 is generated. Assigning a value to this |
7429 | variable 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 | |
7436 | with ‘<samp>bind -x</samp>’ (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 | |
7443 | with ‘<samp>bind -x</samp>’ (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 |
7456 | shell was started. Assignment to this variable resets |
7457 | the count to the value assigned, and the expanded value | |
7458 | becomes the value assigned plus the number of seconds | |
7459 | since 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 | 7466 | If it is not set when the shell starts, |
a0c0a00f CR |
7467 | Bash assigns to it the full pathname of the current user’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 | |
7474 | the 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>). | |
7476 | The options appearing in <code>SHELLOPTS</code> are those reported | |
7477 | as ‘<samp>on</samp>’ by ‘<samp>set -o</samp>’. | |
17345e5a JA |
7478 | If this variable is in the environment when Bash |
7479 | starts up, each shell option in the list will be enabled before | |
7480 | reading 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 | 7487 | intended 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 | |
7494 | how the timing information for pipelines prefixed with the <code>time</code> | |
17345e5a | 7495 | reserved word should be displayed. |
a0c0a00f | 7496 | The ‘<samp>%</samp>’ character introduces an |
17345e5a JA |
7497 | escape sequence that is expanded to a time value or other |
7498 | information. | |
7499 | The escape sequences and their meanings are as | |
7500 | follows; the braces denote optional portions. | |
a0c0a00f CR |
7501 | </p> |
7502 | <dl compact="compact"> | |
7503 | <dt><code>%%</code></dt> | |
7504 | <dd><p>A literal ‘<samp>%</samp>’. | |
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 |
7525 | fractional digits after a decimal point. |
7526 | A value of 0 causes no decimal point or fraction to be output. | |
7527 | At most three places after the decimal point may be specified; values | |
a0c0a00f CR |
7528 | of <var>p</var> greater than 3 are changed to 3. |
7529 | If <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 | |
7532 | the form <var>MM</var>m<var>SS</var>.<var>FF</var>s. | |
7533 | The 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 | 7540 | A 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 | |
7547 | default timeout for the <code>read</code> builtin (see <a href="#Bash-Builtins">Bash Builtins</a>). | |
7548 | The <code>select</code> command (see <a href="#Conditional-Constructs">Conditional Constructs</a>) terminates | |
7549 | if input does not arrive after <code>TMOUT</code> seconds when input is coming | |
17345e5a | 7550 | from a terminal. |
a0c0a00f CR |
7551 | </p> |
7552 | <p>In an interactive shell, the value is interpreted as | |
ac50fbac CR |
7553 | the number of seconds to wait for a line of input after issuing |
7554 | the primary prompt. | |
7555 | Bash | |
7556 | terminates after waiting for that number of seconds if a complete | |
7557 | line 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 | |
7564 | Bash creates temporary files for the shell’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> | |
7579 | Next: <a href="#Job-Control" accesskey="n" rel="next">Job Control</a>, Previous: <a href="#Shell-Variables" accesskey="p" rel="prev">Shell Variables</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<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">• <a href="#Invoking-Bash" accesskey="1">Invoking Bash</a>:</td><td> </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">• <a href="#Bash-Startup-Files" accesskey="2">Bash Startup Files</a>:</td><td> </td><td align="left" valign="top">When and how Bash executes scripts. | |
7591 | </td></tr> | |
7592 | <tr><td align="left" valign="top">• <a href="#Interactive-Shells" accesskey="3">Interactive Shells</a>:</td><td> </td><td align="left" valign="top">What an interactive shell is. | |
7593 | </td></tr> | |
7594 | <tr><td align="left" valign="top">• <a href="#Bash-Conditional-Expressions" accesskey="4">Bash Conditional Expressions</a>:</td><td> </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">• <a href="#Shell-Arithmetic" accesskey="5">Shell Arithmetic</a>:</td><td> </td><td align="left" valign="top">Arithmetic on shell variables. | |
7598 | </td></tr> | |
7599 | <tr><td align="left" valign="top">• <a href="#Aliases" accesskey="6">Aliases</a>:</td><td> </td><td align="left" valign="top">Substituting one command for another. | |
7600 | </td></tr> | |
7601 | <tr><td align="left" valign="top">• <a href="#Arrays" accesskey="7">Arrays</a>:</td><td> </td><td align="left" valign="top">Array Variables. | |
7602 | </td></tr> | |
7603 | <tr><td align="left" valign="top">• <a href="#The-Directory-Stack" accesskey="8">The Directory Stack</a>:</td><td> </td><td align="left" valign="top">History of visited directories. | |
7604 | </td></tr> | |
7605 | <tr><td align="left" valign="top">• <a href="#Controlling-the-Prompt" accesskey="9">Controlling the Prompt</a>:</td><td> </td><td align="left" valign="top">Customizing the various prompt strings. | |
7606 | </td></tr> | |
7607 | <tr><td align="left" valign="top">• <a href="#The-Restricted-Shell">The Restricted Shell</a>:</td><td> </td><td align="left" valign="top">A more controlled mode of shell execution. | |
7608 | </td></tr> | |
7609 | <tr><td align="left" valign="top">• <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>:</td><td> </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> | |
7618 | Next: <a href="#Bash-Startup-Files" accesskey="n" rel="next">Bash Startup Files</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> [<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> …] | |
7626 | bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o <var>option</var>] | |
7627 | [-O <var>shopt_option</var>] -c <var>string</var> [<var>argument</var> …] | |
7628 | bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o <var>option</var>] | |
7629 | [-O <var>shopt_option</var>] [<var>argument</var> …] | |
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 | 7634 | In addition, there are several multi-character |
17345e5a JA |
7635 | options that you can use. These options must appear on the command |
7636 | line 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 | |
7641 | starts. Turns on extended debugging mode (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a> | |
7642 | for a description of the <code>extdebug</code> option to the <code>shopt</code> | |
495aee44 | 7643 | builtin). |
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 ‘<samp>$</samp>’ | |
17345e5a | 7648 | is printed on the standard output |
a0c0a00f CR |
7649 | in the <small>GNU</small> <code>gettext</code> PO (portable object) file format. |
7650 | Equivalent 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 | 7664 | in 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 | 7673 | to read command lines when the shell is interactive. |
a0c0a00f CR |
7674 | </p> |
7675 | </dd> | |
7676 | <dt><code>--noprofile</code></dt> | |
7677 | <dd><p>Don’t load the system-wide startup file <samp>/etc/profile</samp> | |
17345e5a | 7678 | or any of the personal initialization files |
a0c0a00f | 7679 | <samp>~/.bash_profile</samp>, <samp>~/.bash_login</samp>, or <samp>~/.profile</samp> |
17345e5a | 7680 | when Bash is invoked as a login shell. |
a0c0a00f CR |
7681 | </p> |
7682 | </dd> | |
7683 | <dt><code>--norc</code></dt> | |
7684 | <dd><p>Don’t read the <samp>~/.bashrc</samp> initialization file in an | |
17345e5a | 7685 | interactive shell. This is on by default if the shell is |
a0c0a00f CR |
7686 | invoked 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 | |
7691 | from the <small>POSIX</small> standard to match the standard. This | |
17345e5a | 7692 | is intended to make Bash behave as a strict superset of that |
a0c0a00f CR |
7693 | standard. 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’re read. | |
7703 | </p> | |
7704 | </dd> | |
7705 | <dt><code>--version</code></dt> | |
7706 | <dd><p>Show version information for this instance of | |
17345e5a | 7707 | Bash 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 | |
7712 | invocation 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. | |
7718 | If there are arguments after the <var>command_string</var>, | |
7719 | the first argument is assigned to <code>$0</code> | |
7720 | and any remaining arguments are assigned to the positional parameters. | |
7721 | The assignment to <code>$0</code> sets the name of the shell, which is used | |
7722 | in 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 | |
7727 | described 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 | 7732 | When the shell is interactive, this is equivalent to starting a |
a0c0a00f | 7733 | login shell with ‘<samp>exec -l bash</samp>’. |
17345e5a JA |
7734 | When the shell is not interactive, the login shell startup files will |
7735 | be executed. | |
a0c0a00f | 7736 | ‘<samp>exec bash -l</samp>’ or ‘<samp>exec bash --login</samp>’ |
17345e5a | 7737 | will replace the current shell with a Bash login shell. |
a0c0a00f | 7738 | See <a href="#Bash-Startup-Files">Bash Startup Files</a>, for a description of the special behavior |
17345e5a | 7739 | of 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 |
7748 | processing, then commands are read from the standard input. |
7749 | This option allows the positional parameters to be set | |
9a51695b CR |
7750 | when invoking an interactive shell or when reading input |
7751 | through 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 ‘<samp>$</samp>’ | |
17345e5a JA |
7756 | is printed on the standard output. |
7757 | These are the strings that | |
7758 | are subject to language translation when the current locale | |
a0c0a00f CR |
7759 | is not <code>C</code> or <code>POSIX</code> (see <a href="#Locale-Translation">Locale Translation</a>). |
7760 | This 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>). | |
7766 | If <var>shopt_option</var> is present, <samp>-O</samp> sets the value of that option; | |
7767 | <samp>+O</samp> unsets it. | |
7768 | If <var>shopt_option</var> is not supplied, the names and values of the shell | |
7769 | options accepted by <code>shopt</code> are printed on the standard output. | |
7770 | If the invocation option is <samp>+O</samp>, the output is displayed in a format | |
17345e5a | 7771 | that 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 | 7776 | processing. |
a0c0a00f CR |
7777 | Any 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 | ‘<samp>-</samp>’, 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, | |
7787 | unless <samp>-s</samp> is specified, | |
7788 | without specifying the <samp>-c</samp> option, and whose input and output are both | |
7789 | connected to terminals (as determined by <code>isatty(3)</code>), or one | |
7790 | started with the <samp>-i</samp> option. See <a href="#Interactive-Shells">Interactive Shells</a>, for more | |
17345e5a | 7791 | information. |
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 | 7795 | option has been supplied, the first argument is assumed to |
a0c0a00f CR |
7796 | be the name of a file containing shell commands (see <a href="#Shell-Scripts">Shell Scripts</a>). |
7797 | When Bash is invoked in this fashion, <code>$0</code> | |
17345e5a JA |
7798 | is set to the name of the file, and the positional parameters |
7799 | are set to the remaining arguments. | |
7800 | Bash reads and executes commands from this file, then exits. | |
a0c0a00f | 7801 | Bash’s exit status is the exit status of the last command executed |
17345e5a | 7802 | in 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> | |
7808 | Next: <a href="#Interactive-Shells" accesskey="n" rel="next">Interactive Shells</a>, Previous: <a href="#Invoking-Bash" accesskey="p" rel="prev">Invoking Bash</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> [<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 | 7815 | If any of the files exist but cannot be read, Bash reports an error. |
ac50fbac | 7816 | Tildes are expanded in filenames as described above under |
a0c0a00f CR |
7817 | Tilde 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 | |
7825 | non-interactive shell with the <samp>--login</samp> option, it first reads and | |
7826 | executes commands from the file <samp>/etc/profile</samp>, if that file exists. | |
7827 | After 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 | 7829 | and executes commands from the first one that exists and is readable. |
a0c0a00f | 7830 | The <samp>--noprofile</samp> option may be used when the shell is started to |
17345e5a | 7831 | inhibit this behavior. |
a0c0a00f CR |
7832 | </p> |
7833 | <p>When an interactive login shell exits, | |
7834 | or a non-interactive login shell executes the <code>exit</code> builtin command, | |
7835 | Bash reads and executes commands from | |
7836 | the 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 | |
7842 | reads and executes commands from <samp>~/.bashrc</samp>, if that file exists. | |
7843 | This may be inhibited by using the <samp>--norc</samp> option. | |
7844 | The <samp>--rcfile <var>file</var></samp> option will force Bash to read and | |
7845 | execute 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, | |
7857 | for example, it looks for the variable <code>BASH_ENV</code> in the environment, | |
17345e5a JA |
7858 | expands its value if it appears there, and uses the expanded value as |
7859 | the name of a file to read and execute. Bash behaves as if the | |
7860 | following command were executed: | |
a0c0a00f CR |
7861 | </p><div class="example"> |
7862 | <pre class="example"><code>if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi</code> | |
7863 | </pre></div> | |
7864 | <p>but the value of the <code>PATH</code> variable is not used to search for the | |
ac50fbac | 7865 | filename. |
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 | 7869 | login 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 | |
7875 | startup behavior of historical versions of <code>sh</code> as closely as | |
7876 | possible, 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 | |
7879 | shell with the <samp>--login</samp> option, it first attempts to read | |
7880 | and execute commands from <samp>/etc/profile</samp> and <samp>~/.profile</samp>, in | |
17345e5a | 7881 | that order. |
a0c0a00f CR |
7882 | The <samp>--noprofile</samp> option may be used to inhibit this behavior. |
7883 | When invoked as an interactive shell with the name <code>sh</code>, Bash | |
7884 | looks for the variable <code>ENV</code>, expands its value if it is defined, | |
17345e5a | 7885 | and uses the expanded value as the name of a file to read and execute. |
a0c0a00f CR |
7886 | Since a shell invoked as <code>sh</code> does not attempt to read and execute |
7887 | commands from any other startup files, the <samp>--rcfile</samp> option has | |
17345e5a | 7888 | no effect. |
a0c0a00f | 7889 | A non-interactive shell invoked with the name <code>sh</code> does not attempt |
17345e5a | 7890 | to 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 | 7893 | the 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 | 7900 | for startup files. |
a0c0a00f | 7901 | In this mode, interactive shells expand the <code>ENV</code> variable |
17345e5a JA |
7902 | and commands are read and executed from the file whose name is the |
7903 | expanded value. | |
7904 | No 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 | 7910 | connected to a network connection, as when executed by the remote shell |
a0c0a00f | 7911 | daemon, usually <code>rshd</code>, or the secure shell daemon <code>sshd</code>. |
17345e5a | 7912 | If Bash determines it is being run in |
a0c0a00f | 7913 | this fashion, it reads and executes commands from <samp>~/.bashrc</samp>, if that |
17345e5a | 7914 | file exists and is readable. |
a0c0a00f CR |
7915 | It will not do this if invoked as <code>sh</code>. |
7916 | The <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 | |
7918 | neither <code>rshd</code> nor <code>sshd</code> generally invoke the shell with those | |
ac50fbac | 7919 | options 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 |
7925 | real user (group) id, and the <samp>-p</samp> option is not supplied, no startup | |
17345e5a | 7926 | files are read, shell functions are not inherited from the environment, |
a0c0a00f | 7927 | the <code>SHELLOPTS</code>, <code>BASHOPTS</code>, <code>CDPATH</code>, and <code>GLOBIGNORE</code> |
0001803f CR |
7928 | variables, if they appear in the environment, are ignored, and the effective |
7929 | user id is set to the real user id. | |
a0c0a00f | 7930 | If the <samp>-p</samp> option is supplied at invocation, the startup behavior is |
17345e5a | 7931 | the 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> | |
7937 | Next: <a href="#Bash-Conditional-Expressions" accesskey="n" rel="next">Bash Conditional Expressions</a>, Previous: <a href="#Bash-Startup-Files" accesskey="p" rel="prev">Bash Startup Files</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> [<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">• <a href="#What-is-an-Interactive-Shell_003f" accesskey="1">What is an Interactive Shell?</a>:</td><td> </td><td align="left" valign="top">What determines whether a shell is Interactive. | |
7946 | </td></tr> | |
7947 | <tr><td align="left" valign="top">• <a href="#Is-this-Shell-Interactive_003f" accesskey="2">Is this Shell Interactive?</a>:</td><td> </td><td align="left" valign="top">How to tell if a shell is interactive. | |
7948 | </td></tr> | |
7949 | <tr><td align="left" valign="top">• <a href="#Interactive-Shell-Behavior" accesskey="3">Interactive Shell Behavior</a>:</td><td> </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> | |
7957 | Next: <a href="#Is-this-Shell-Interactive_003f" accesskey="n" rel="next">Is this Shell Interactive?</a>, Up: <a href="#Interactive-Shells" accesskey="u" rel="up">Interactive Shells</a> [<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 | |
7963 | is one started without non-option arguments, unless <samp>-s</samp> is | |
7964 | specified, without specifying the <samp>-c</samp> option, and | |
17345e5a | 7965 | whose input and error output are both |
a0c0a00f CR |
7966 | connected to terminals (as determined by <code>isatty(3)</code>), |
7967 | or one started with the <samp>-i</samp> option. | |
7968 | </p> | |
7969 | <p>An interactive shell generally reads from and writes to a user’s | |
17345e5a | 7970 | terminal. |
a0c0a00f CR |
7971 | </p> |
7972 | <p>The <samp>-s</samp> invocation option may be used to set the positional parameters | |
17345e5a | 7973 | when 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> | |
7979 | Next: <a href="#Interactive-Shell-Behavior" accesskey="n" rel="next">Interactive Shell Behavior</a>, Previous: <a href="#What-is-an-Interactive-Shell_003f" accesskey="p" rel="prev">What is an Interactive Shell?</a>, Up: <a href="#Interactive-Shells" accesskey="u" rel="up">Interactive Shells</a> [<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 | 7985 | running interactively, |
a0c0a00f CR |
7986 | test the value of the ‘<samp>-</samp>’ special parameter. |
7987 | It contains <code>i</code> when the shell is interactive. For example: | |
7988 | </p> | |
7989 | <div class="example"> | |
7990 | <pre class="example">case "$-" in | |
17345e5a JA |
7991 | *i*) echo This shell is interactive ;; |
7992 | *) echo This shell is not interactive ;; | |
7993 | esac | |
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 | 7998 | interactive shells. Thus: |
a0c0a00f CR |
7999 | </p> |
8000 | <div class="example"> | |
8001 | <pre class="example">if [ -z "$PS1" ]; then | |
17345e5a JA |
8002 | echo This shell is not interactive |
8003 | else | |
8004 | echo This shell is interactive | |
8005 | fi | |
a0c0a00f CR |
8006 | </pre></div> |
8007 | ||
8008 | <hr> | |
8009 | <a name="Interactive-Shell-Behavior"></a> | |
8010 | <div class="header"> | |
8011 | <p> | |
8012 | Previous: <a href="#Is-this-Shell-Interactive_003f" accesskey="p" rel="prev">Is this Shell Interactive?</a>, Up: <a href="#Interactive-Shells" accesskey="u" rel="up">Interactive Shells</a> [<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 | 8018 | several 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 | 8024 | control is in effect, Bash ignores the keyboard-generated job control |
a0c0a00f | 8025 | signals <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 |
8028 | of a command, and expands and displays <code>PS2</code> before reading the | |
17345e5a | 8029 | second and subsequent lines of a multi-line command. |
9a51695b CR |
8030 | Bash expands and displays <code>PS0</code> after it reads a command but before |
8031 | executing it. | |
8032 | See <a href="#Controlling-the-Prompt">Controlling the Prompt</a>, for a complete list of prompt | |
8033 | string escape sequences. | |
17345e5a | 8034 | |
a0c0a00f CR |
8035 | </li><li> Bash executes the value of the <code>PROMPT_COMMAND</code> variable as a command |
8036 | before 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 |
8040 | the user’s terminal. | |
17345e5a | 8041 | |
a0c0a00f CR |
8042 | </li><li> Bash inspects the value of the <code>ignoreeof</code> option to <code>set -o</code> |
8043 | instead of exiting immediately when it receives an <code>EOF</code> on its | |
8044 | standard 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>) |
8047 | and history expansion (see <a href="#History-Interaction">History Interaction</a>) | |
8048 | are enabled by default. | |
8049 | Bash will save the command history to the file named by <code>$HISTFILE</code> | |
8050 | when 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 |
8062 | if 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 ‘<samp>set -n</samp>’ has |
8065 | no 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 | ‘<samp>set -u</samp>’ 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 |
8076 | or 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 |
8080 | shell to exit. | |
17345e5a | 8081 | |
a0c0a00f CR |
8082 | </li><li> When running in <small>POSIX</small> mode, a special builtin returning an error |
8083 | status 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> |
8091 | builtin is enabled by default (see the description of the <code>cdspell</code> | |
8092 | option 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 |
8095 | if a command is not read within the specified number of seconds after | |
8096 | printing <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> | |
8104 | Next: <a href="#Shell-Arithmetic" accesskey="n" rel="next">Shell Arithmetic</a>, Previous: <a href="#Interactive-Shells" accesskey="p" rel="prev">Interactive Shells</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> [<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 | |
8111 | and the <code>test</code> and <code>[</code> builtin commands. | |
8112 | </p> | |
8113 | <p>Expressions may be unary or binary. | |
8114 | Unary expressions are often used to examine the status of a file. | |
8115 | There are string operators and numeric comparison operators as well. | |
8116 | Bash handles several filenames specially when they are used in | |
8117 | expressions. | |
8118 | If the operating system on which Bash is running provides these | |
8119 | special files, Bash will use them; otherwise it will emulate them | |
8120 | internally with this behavior: | |
8121 | If 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. | |
8123 | If 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 | |
8125 | descriptor 0, 1, or 2, respectively, is checked. | |
8126 | </p> | |
8127 | <p>When used with <code>[[</code>, the ‘<samp><</samp>’ and ‘<samp>></samp>’ operators sort | |
8128 | lexicographically using the current locale. | |
8129 | The <code>test</code> command uses ASCII ordering. | |
8130 | </p> | |
8131 | <p>Unless otherwise specified, primaries that operate on files follow symbolic | |
8132 | links 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 "sticky" 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 | 8221 | inode 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) | |
8226 | than <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>, | |
8231 | or 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. | |
8236 | The list of options appears in the description of the <samp>-o</samp> | |
8237 | option 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. | |
8260 | When used with the <code>[[</code> command, this performs pattern matching as | |
8261 | described above (see <a href="#Conditional-Constructs">Conditional Constructs</a>). | |
8262 | </p> | |
8263 | <p>‘<samp>=</samp>’ 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> < <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> > <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 | ‘<samp>-eq</samp>’, ‘<samp>-ne</samp>’, ‘<samp>-lt</samp>’, ‘<samp>-le</samp>’, ‘<samp>-gt</samp>’, or ‘<samp>-ge</samp>’. | |
8281 | These arithmetic binary operators return true if <var>arg1</var> | |
17345e5a | 8282 | is equal to, not equal to, less than, less than or equal to, |
a0c0a00f CR |
8283 | greater than, or greater than or equal to <var>arg2</var>, |
8284 | respectively. <var>Arg1</var> and <var>arg2</var> | |
17345e5a | 8285 | may be positive or negative integers. |
9a51695b CR |
8286 | When used with the <code>[[</code> command, <var>Arg1</var> and <var>Arg2</var> |
8287 | are 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> | |
8295 | Next: <a href="#Aliases" accesskey="n" rel="next">Aliases</a>, Previous: <a href="#Bash-Conditional-Expressions" accesskey="p" rel="prev">Bash Conditional Expressions</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> [<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 | |
8306 | the 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 |
8310 | though division by 0 is trapped and flagged as an error. |
8311 | The operators and their precedence, associativity, and values | |
8312 | are the same as in the C language. | |
8313 | The following list of operators is grouped into levels of | |
8314 | equal-precedence operators. | |
8315 | The 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><< >></code></dt> | |
8347 | <dd><p>left and right bitwise shifts | |
8348 | </p> | |
8349 | </dd> | |
8350 | <dt><code><= >= < ></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>&</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>&&</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>= *= /= %= += -= <<= >>= &= ^= |=</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 |
8392 | performed before the expression is evaluated. |
8393 | Within an expression, shell variables may also be referenced by name | |
8394 | without using the parameter expansion syntax. | |
8395 | A shell variable that is null or unset evaluates to 0 when referenced | |
8396 | by name without using the parameter expansion syntax. | |
8397 | The value of a variable is evaluated as an arithmetic expression | |
8398 | when it is referenced, or when a variable which has been given the | |
a0c0a00f | 8399 | <var>integer</var> attribute using ‘<samp>declare -i</samp>’ is assigned a value. |
17345e5a | 8400 | A null value evaluates to 0. |
a0c0a00f | 8401 | A shell variable need not have its <var>integer</var> attribute turned on |
17345e5a | 8402 | to be used in an expression. |
a0c0a00f CR |
8403 | </p> |
8404 | <p>Constants with a leading 0 are interpreted as octal numbers. | |
8405 | A leading ‘<samp>0x</samp>’ or ‘<samp>0X</samp>’ denotes hexadecimal. Otherwise, | |
8406 | numbers take the form [<var>base</var><code>#</code>]<var>n</var>, where the optional <var>base</var> | |
17345e5a | 8407 | is a decimal number between 2 and 64 representing the arithmetic |
a0c0a00f CR |
8408 | base, and <var>n</var> is a number in that base. |
8409 | If <var>base</var><code>#</code> is omitted, then base 10 is used. | |
8410 | When specifying <var>n</var>, | |
8411 | the digits greater than 9 are represented by the lowercase letters, | |
8412 | the uppercase letters, ‘<samp>@</samp>’, and ‘<samp>_</samp>’, in that order. | |
8413 | If <var>base</var> is less than or equal to 36, lowercase and uppercase | |
17345e5a JA |
8414 | letters may be used interchangeably to represent numbers between 10 |
8415 | and 35. | |
a0c0a00f CR |
8416 | </p> |
8417 | <p>Operators are evaluated in order of precedence. Sub-expressions in | |
17345e5a JA |
8418 | parentheses are evaluated first and may override the precedence |
8419 | rules above. | |
a0c0a00f CR |
8420 | </p> |
8421 | <hr> | |
8422 | <a name="Aliases"></a> | |
8423 | <div class="header"> | |
8424 | <p> | |
8425 | Next: <a href="#Arrays" accesskey="n" rel="next">Arrays</a>, Previous: <a href="#Shell-Arithmetic" accesskey="p" rel="prev">Shell Arithmetic</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> [<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 |
8432 | as the first word of a simple command. |
8433 | The shell maintains a list of aliases that may be set and unset with | |
a0c0a00f CR |
8434 | the <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 |
8437 | if it has an alias. |
8438 | If so, that word is replaced by the text of the alias. | |
a0c0a00f | 8439 | The characters ‘<samp>/</samp>’, ‘<samp>$</samp>’, ‘<samp>`</samp>’, ‘<samp>=</samp>’ and any of the |
17345e5a JA |
8440 | shell metacharacters or quoting characters listed above may not appear |
8441 | in an alias name. | |
8442 | The replacement text may contain any valid | |
8443 | shell input, including shell metacharacters. | |
8444 | The first word of the replacement text is tested for | |
8445 | aliases, but a word that is identical to an alias being expanded | |
8446 | is not expanded a second time. | |
a0c0a00f | 8447 | This means that one may alias <code>ls</code> to <code>"ls -F"</code>, |
17345e5a | 8448 | for instance, and Bash does not try to recursively expand the |
ac50fbac CR |
8449 | replacement text. |
8450 | If the last character of the alias value is a | |
a0c0a00f | 8451 | <var>blank</var>, then the next command word following the |
17345e5a | 8452 | alias is also checked for alias expansion. |
a0c0a00f CR |
8453 | </p> |
8454 | <p>Aliases are created and listed with the <code>alias</code> | |
8455 | command, and removed with the <code>unalias</code> command. | |
8456 | </p> | |
8457 | <p>There is no mechanism for using arguments in the replacement text, | |
8458 | as in <code>csh</code>. | |
17345e5a | 8459 | If 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, | |
8463 | unless 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 |
8467 | somewhat confusing. Bash |
8468 | always reads at least one complete line | |
8469 | of input before executing any | |
8470 | of the commands on that line. Aliases are expanded when a | |
8471 | command is read, not when it is executed. Therefore, an | |
8472 | alias definition appearing on the same line as another | |
8473 | command does not take effect until the next line of input is read. | |
8474 | The commands following the alias definition | |
8475 | on that line are not affected by the new alias. | |
8476 | This behavior is also an issue when functions are executed. | |
8477 | Aliases are expanded when a function definition is read, | |
8478 | not when the function is executed, because a function definition | |
a0c0a00f | 8479 | is itself a command. As a consequence, aliases |
17345e5a JA |
8480 | defined in a function are not available until after that |
8481 | function is executed. To be safe, always put | |
a0c0a00f | 8482 | alias definitions on a separate line, and do not use <code>alias</code> |
17345e5a | 8483 | in 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> | |
8491 | Next: <a href="#The-Directory-Stack" accesskey="n" rel="next">The Directory Stack</a>, Previous: <a href="#Aliases" accesskey="p" rel="prev">Aliases</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> [<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 | 8498 | Any variable may be used as an indexed array; |
a0c0a00f | 8499 | the <code>declare</code> builtin will explicitly declare an array. |
17345e5a JA |
8500 | There is no maximum |
8501 | limit on the size of an array, nor any requirement that members | |
8502 | be indexed or assigned contiguously. | |
8503 | Indexed arrays are referenced using integers (including arithmetic | |
a0c0a00f | 8504 | expressions (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>)) and are zero-based; |
17345e5a | 8505 | associative arrays use arbitrary strings. |
ac50fbac | 8506 | Unless 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 | 8509 | using 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 | 8515 | is treated as an arithmetic expression that must evaluate to a number. |
495aee44 | 8516 | To 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 | |
8532 | specified for an array variable using the <code>declare</code> and | |
8533 | <code>readonly</code> builtins. Each attribute applies to all members of | |
17345e5a | 8534 | an 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> … ) | |
8539 | </pre></div> | |
8540 | <p>where each | |
8541 | <var>value</var> is of the form <code>[<var>subscript</var>]=</code><var>string</var>. | |
8542 | Indexed array assignments do not require anything but <var>string</var>. | |
17345e5a JA |
8543 | When assigning to indexed arrays, if |
8544 | the optional subscript is supplied, that index is assigned to; | |
8545 | otherwise the index of the element assigned is the last index assigned | |
8546 | to 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 | 8551 | builtin. 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 |
8555 | is subscripted by a negative number, that number is |
8556 | interpreted 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 | 8558 | array, 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 | 8562 | The braces are required to avoid |
a0c0a00f CR |
8563 | conflicts with the shell’s filename expansion operators. If the |
8564 | <var>subscript</var> is ‘<samp>@</samp>’ or ‘<samp>*</samp>’, the word expands to all members | |
8565 | of the array <var>name</var>. These subscripts differ only when the word | |
17345e5a JA |
8566 | appears within double quotes. |
8567 | If the word is double-quoted, | |
a0c0a00f | 8568 | <code>${<var>name</var>[*]}</code> expands to a single word with |
17345e5a | 8569 | the 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 |
8573 | If the double-quoted expansion occurs within a word, the expansion of |
8574 | the first parameter is joined with the beginning part of the original | |
8575 | word, and the expansion of the last parameter is joined with the last | |
8576 | part of the original word. | |
8577 | This is analogous to the | |
a0c0a00f CR |
8578 | expansion of the special parameters ‘<samp>@</samp>’ and ‘<samp>*</samp>’. |
8579 | <code>${#<var>name</var>[<var>subscript</var>]}</code> expands to the length of | |
8580 | <code>${<var>name</var>[<var>subscript</var>]}</code>. | |
8581 | If <var>subscript</var> is ‘<samp>@</samp>’ or | |
8582 | ‘<samp>*</samp>’, the expansion is the number of elements in the array. | |
8583 | If the <var>subscript</var> | |
ac50fbac | 8584 | used to reference an element of an indexed array |
a0c0a00f | 8585 | evaluates to a number less than zero, it is |
ac50fbac CR |
8586 | interpreted as relative to one greater than the maximum index of the array, |
8587 | so negative indices count back from the end of the array, | |
8588 | and 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 | |
8591 | referencing with a subscript of 0. | |
8592 | Any 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 | 8596 | value. 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 | |
8600 | assigned in array variable <var>name</var>. | |
ac50fbac | 8601 | The treatment when in double quotes is similar to the expansion of the |
a0c0a00f CR |
8602 | special parameters ‘<samp>@</samp>’ and ‘<samp>*</samp>’ 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> | |
8606 | destroys the array element at index <var>subscript</var>. | |
ac50fbac | 8607 | Negative subscripts to indexed arrays are interpreted as described above. |
9a51695b | 8608 | Unsetting 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 |
8610 | entire array. A subscript of ‘<samp>*</samp>’ or ‘<samp>@</samp>’ also removes the | |
17345e5a | 8611 | entire array. |
a0c0a00f | 8612 | </p> |
9a51695b CR |
8613 | <p>When using a variable name with a subscript as an argument to a command, |
8614 | such as with <code>unset</code>, without using the word expansion syntax | |
8615 | described above, the argument is subject to the shell’s filename expansion. | |
8616 | If 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> |
8619 | builtins each accept a <samp>-a</samp> option to specify an indexed | |
8620 | array and a <samp>-A</samp> option to specify an associative array. | |
8621 | If both options are supplied, <samp>-A</samp> takes precedence. | |
8622 | The <code>read</code> builtin accepts a <samp>-a</samp> | |
17345e5a JA |
8623 | option to assign a list of words read from the standard input |
8624 | to an array, and can read values from the standard input into | |
a0c0a00f | 8625 | individual array elements. The <code>set</code> and <code>declare</code> |
17345e5a JA |
8626 | builtins display array values in a way that allows them to be |
8627 | reused as input. | |
a0c0a00f CR |
8628 | </p> |
8629 | <hr> | |
8630 | <a name="The-Directory-Stack"></a> | |
8631 | <div class="header"> | |
8632 | <p> | |
8633 | Next: <a href="#Controlling-the-Prompt" accesskey="n" rel="next">Controlling the Prompt</a>, Previous: <a href="#Arrays" accesskey="p" rel="prev">Arrays</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> [<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">• <a href="#Directory-Stack-Builtins" accesskey="1">Directory Stack Builtins</a>:</td><td> </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 | |
8647 | the current directory, and the <code>popd</code> builtin removes specified | |
17345e5a | 8648 | directories from the stack and changes the current directory to |
a0c0a00f CR |
8649 | the directory removed. The <code>dirs</code> builtin displays the contents |
8650 | of the directory stack. The current directory is always the "top" | |
17345e5a | 8651 | of the directory stack. |
a0c0a00f CR |
8652 | </p> |
8653 | <p>The contents of the directory stack are also visible | |
8654 | as 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> | |
8660 | Up: <a href="#The-Directory-Stack" accesskey="u" rel="up">The Directory Stack</a> [<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 | |
8673 | are added to the list with the <code>pushd</code> command; the | |
8674 | <code>popd</code> command removes directories from the list. | |
8675 | The 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 | 8683 | the 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 | 8687 | line. |
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 | 8691 | line, 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 | |
8695 | list printed by <code>dirs</code> when invoked without options), starting | |
ac50fbac | 8696 | with 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 | |
8700 | list printed by <code>dirs</code> when invoked without options), starting | |
ac50fbac | 8701 | with 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 | 8713 | removes the top directory from the stack and |
a0c0a00f CR |
8714 | performs a <code>cd</code> to the new top directory. |
8715 | The elements are numbered from 0 starting at the first directory | |
8716 | listed 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 | 8721 | from 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 | |
8725 | list 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 | |
8729 | list 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 | |
8741 | and then <code>cd</code> to <var>dir</var>. | |
8742 | With no arguments, <code>pushd</code> exchanges the top two directories | |
8743 | and 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 | |
8748 | adding 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 | |
8752 | list printed by <code>dirs</code>, starting with zero) to the top of | |
17345e5a | 8753 | the 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 | |
8757 | list printed by <code>dirs</code>, starting with zero) to the top of | |
17345e5a | 8758 | the 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 | 8762 | it the new current directory as if it had been supplied as an argument |
a0c0a00f CR |
8763 | to 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> | |
8773 | Next: <a href="#The-Restricted-Shell" accesskey="n" rel="next">The Restricted Shell</a>, Previous: <a href="#The-Directory-Stack" accesskey="p" rel="prev">The Directory Stack</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> [<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 | |
8780 | Bash prints each primary prompt. If <code>PROMPT_COMMAND</code> is set and | |
17345e5a JA |
8781 | has a non-null value, then the |
8782 | value 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 |
8785 | can 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 "Weekday Month Date" format (e.g., "Tue May 26"). | |
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 | |
8797 | into the prompt string; an empty <var>format</var> results in a locale-specific | |
17345e5a | 8798 | time 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 ‘.’. | |
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’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 | 8823 | following 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 | 8870 | embed 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 |
8878 | the history number of a command is its position in the history |
8879 | list, 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 |
8881 | the position in the sequence of commands executed during the current |
8882 | shell session. | |
a0c0a00f CR |
8883 | </p> |
8884 | <p>After the string is decoded, it is expanded via | |
17345e5a JA |
8885 | parameter expansion, command substitution, arithmetic |
8886 | expansion, 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> | |
8893 | Next: <a href="#Bash-POSIX-Mode" accesskey="n" rel="next">Bash POSIX Mode</a>, Previous: <a href="#Controlling-the-Prompt" accesskey="p" rel="prev">Controlling the Prompt</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> [<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 | 8901 | or |
a0c0a00f | 8902 | <samp>-r</samp> |
17345e5a JA |
8903 | option is supplied at invocation, the shell becomes restricted. |
8904 | A restricted shell is used to | |
8905 | set up an environment more controlled than the standard shell. | |
a0c0a00f | 8906 | A restricted shell behaves identically to <code>bash</code> |
17345e5a | 8907 | with 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 | 8915 | builtin command. |
a0c0a00f CR |
8916 | </li><li> Specifying a filename containing a slash as an argument to the <samp>-p</samp> |
8917 | option 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 ‘<samp>></samp>’, ‘<samp>>|</samp>’, ‘<samp><></samp>’, ‘<samp>>&</samp>’, | |
8921 | ‘<samp>&></samp>’, and ‘<samp>>></samp>’ 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 ‘<samp>set +r</samp>’ or ‘<samp>set +o restricted</samp>’. | |
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 | 8934 | the 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> | |
8940 | Previous: <a href="#The-Restricted-Shell" accesskey="p" rel="prev">The Restricted Shell</a>, Up: <a href="#Bash-Features" accesskey="u" rel="up">Bash Features</a> [<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 | ‘<samp>set -o posix</samp>’ while Bash is running will cause Bash to conform more | |
8948 | closely to the <small>POSIX</small> standard by changing the behavior to | |
8949 | match 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 | 8952 | startup files. |
a0c0a00f CR |
8953 | </p> |
8954 | <p>The following list is what’s changed when ‘<small>POSIX</small> mode’ 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 | ‘<samp>shopt -s checkhash</samp>’. | |
17345e5a | 8962 | |
a0c0a00f CR |
8963 | </li><li> The message printed by the job control code and builtins when a job |
8964 | exits with a non-zero status is ‘Done(status)’. | |
17345e5a | 8965 | |
a0c0a00f CR |
8966 | </li><li> The message printed by the job control code and builtins when a job |
8967 | is stopped is ‘Stopped(<var>signame</var>)’, where <var>signame</var> is, for | |
8968 | example, <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 |
8973 | do not undergo alias expansion. | |
17345e5a | 8974 | |
a0c0a00f CR |
8975 | </li><li> The <small>POSIX</small> <code>PS1</code> and <code>PS2</code> expansions of ‘<samp>!</samp>’ to |
8976 | the history number and ‘<samp>!!</samp>’ to ‘<samp>!</samp>’ are enabled, | |
8977 | and 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 |
8981 | the normal Bash files. | |
17345e5a | 8982 | |
a0c0a00f CR |
8983 | </li><li> Tilde expansion is only performed on assignments preceding a command |
8984 | name, 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 |
8987 | default value of <code>$HISTFILE</code>). | |
495aee44 | 8988 | |
a0c0a00f | 8989 | </li><li> Redirection operators do not perform filename expansion on the word |
17345e5a | 8990 | in 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 | 8993 | redirection. |
17345e5a | 8994 | |
a0c0a00f | 8995 | </li><li> Function names must be valid shell <code>name</code>s. That is, they may not |
17345e5a JA |
8996 | contain characters other than letters, digits, and underscores, and |
8997 | may not start with a digit. Declaring a function with an invalid name | |
8998 | causes 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 | 9001 | builtins. |
ac50fbac | 9002 | |
a0c0a00f | 9003 | </li><li> <small>POSIX</small> special builtins are found before shell functions |
17345e5a | 9004 | during command lookup. |
17345e5a | 9005 | |
a0c0a00f CR |
9006 | </li><li> When printing shell function definitions (e.g., by <code>type</code>), Bash does |
9007 | not print the <code>function</code> keyword. | |
9008 | ||
9009 | </li><li> Literal tildes that appear as the first character in elements of | |
9010 | the <code>PATH</code> variable are not expanded as described above | |
9011 | under <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 | 9014 | used in this way, it displays timing statistics for the shell and its |
a0c0a00f | 9015 | completed children. The <code>TIMEFORMAT</code> variable controls the format |
495aee44 | 9016 | of the timing information. |
495aee44 | 9017 | |
a0c0a00f | 9018 | </li><li> When parsing and expanding a ${…} expansion that appears within |
495aee44 CR |
9019 | double quotes, single quotes are no longer special and cannot be used to |
9020 | quote a closing brace or other special character, unless the operator is | |
9021 | one of those defined to perform pattern removal. In this case, they do | |
9022 | not 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 |
9025 | token begins with a ‘<samp>-</samp>’. | |
9026 | ||
9027 | </li><li> The ‘<samp>!</samp>’ character does not introduce history expansion within a | |
9028 | double-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 | 9031 | non-interactive shell exits. The fatal errors are those listed in |
a0c0a00f | 9032 | the <small>POSIX</small> standard, and include things like passing incorrect options, |
17345e5a JA |
9033 | redirection errors, variable assignment errors for assignments preceding |
9034 | the 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 |
9037 | assignment error occurs when no command name follows the assignment |
9038 | statements. | |
9039 | A variable assignment error occurs, for example, when trying to assign | |
9040 | a 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 |
9043 | assignment error occurs in an assignment statement preceding a special |
9044 | builtin, 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 |
9047 | variable 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> |
9051 | is not found. | |
9052 | ||
9053 | </li><li> Non-interactive shells exit if a syntax error in an arithmetic expansion | |
9054 | results 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 |
9059 | with the <code>.</code> or <code>source</code> builtins, or in a string processed by | |
9060 | the <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 | ‘<samp>#</samp>’ and ‘<samp>?</samp>’ special parameters. | |
9066 | ||
9067 | </li><li> When expanding the ‘<samp>*</samp>’ special parameter in a pattern context where the | |
9068 | expansion is double-quoted does not treat the <code>$*</code> as if it were | |
9069 | double-quoted. | |
ac50fbac | 9070 | |
a0c0a00f | 9071 | </li><li> Assignment statements preceding <small>POSIX</small> special builtins |
17345e5a | 9072 | persist in the shell environment after the builtin completes. |
17345e5a | 9073 | |
a0c0a00f CR |
9074 | </li><li> Assignment statements preceding shell function calls persist in the |
9075 | shell environment after the function returns, as if a <small>POSIX</small> | |
17345e5a | 9076 | special builtin command had been executed. |
17345e5a | 9077 | |
a0c0a00f CR |
9078 | </li><li> The <code>command</code> builtin does not prevent builtins that take assignment |
9079 | statements as arguments from expanding them as assignment statements; | |
9080 | when not in <small>POSIX</small> mode, assignment builtins lose their assignment | |
9081 | statement 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 | |
9084 | in the background, which does not include an indication of whether the job | |
9085 | is the current or previous job. | |
9086 | ||
9087 | </li><li> The output of ‘<samp>kill -l</samp>’ prints all the signal names on a single line, | |
9088 | separated by spaces, without the ‘<samp>SIG</samp>’ prefix. | |
9089 | ||
9090 | </li><li> The <code>kill</code> builtin does not accept signal names with a ‘<samp>SIG</samp>’ | |
9091 | prefix. | |
9092 | ||
9093 | </li><li> The <code>export</code> and <code>readonly</code> builtin commands display their | |
9094 | output 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’t check the first argument for a possible |
17345e5a JA |
9100 | signal specification and revert the signal handling to the original |
9101 | disposition if it is, unless that argument consists solely of digits and | |
9102 | is a valid signal number. If users want to reset the handler for a given | |
a0c0a00f | 9103 | signal to the original disposition, they should use ‘<samp>-</samp>’ as the |
17345e5a | 9104 | first argument. |
a0c0a00f CR |
9105 | |
9106 | </li><li> The <code>.</code> and <code>source</code> builtins do not search the current directory | |
9107 | for 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 | |
9111 | subshells spawned to execute command substitutions inherit the value of | |
9112 | the <samp>-e</samp> option from the parent shell. | |
9113 | When the <code>inherit_errexit</code> option is not enabled, | |
9114 | Bash 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 | |
9117 | display them with a leading ‘<samp>alias </samp>’ unless the <samp>-p</samp> option | |
17345e5a | 9118 | is supplied. |
17345e5a | 9119 | |
a0c0a00f | 9120 | </li><li> When the <code>set</code> builtin is invoked without options, it does not display |
17345e5a | 9121 | shell function names and definitions. |
17345e5a | 9122 | |
a0c0a00f | 9123 | </li><li> When the <code>set</code> builtin is invoked without options, it displays |
17345e5a JA |
9124 | variable values without quotes, unless they contain shell metacharacters, |
9125 | even 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 |
9128 | constructed from <code>$PWD</code> and the directory name supplied as an argument | |
9129 | does not refer to an existing directory, <code>cd</code> will fail instead of | |
9130 | falling 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 | 9133 | current 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 | 9137 | indication 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 | 9142 | file as having been found, though the shell will attempt to execute such a |
a0c0a00f CR |
9143 | file 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 | |
9146 | the ‘<samp>v</samp>’ 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 | |
9150 | any arguments to <code>echo</code> as options. Each argument is displayed, after | |
17345e5a | 9151 | escape 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> |
9154 | and <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 |
9157 | not interrupt the <code>wait</code> builtin and cause it to return immediately. | |
0001803f | 9158 | The 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 | 9161 | has been set. |
a0c0a00f CR |
9162 | If Bash receives a trapped signal while executing <code>read</code>, the trap |
9163 | handler executes and <code>read</code> returns an exit status greater than 128. | |
9164 | ||
9165 | </li><li> Bash removes an exited background process’s status from the list of such | |
9166 | statuses 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 |
9171 | default even when in <small>POSIX</small> mode. | |
17345e5a | 9172 | Specifically: |
a0c0a00f CR |
9173 | </p> |
9174 | <ol> | |
9175 | <li> The <code>fc</code> builtin checks <code>$EDITOR</code> as a program to edit history | |
9176 | entries 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 | |
9180 | the <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 | |
9185 | the <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> | |
9192 | Next: <a href="#Command-Line-Editing" accesskey="n" rel="next">Command Line Editing</a>, Previous: <a href="#Bash-Features" accesskey="p" rel="prev">Bash Features</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<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 | 9198 | Bash 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">• <a href="#Job-Control-Basics" accesskey="1">Job Control Basics</a>:</td><td> </td><td align="left" valign="top">How job control works. | |
9202 | </td></tr> | |
9203 | <tr><td align="left" valign="top">• <a href="#Job-Control-Builtins" accesskey="2">Job Control Builtins</a>:</td><td> </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">• <a href="#Job-Control-Variables" accesskey="3">Job Control Variables</a>:</td><td> </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> | |
9215 | Next: <a href="#Job-Control-Builtins" accesskey="n" rel="next">Job Control Builtins</a>, Up: <a href="#Job-Control" accesskey="u" rel="up">Job Control</a> [<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 |
9225 | refers to the ability to selectively stop (suspend) |
9226 | the execution of processes and continue (resume) | |
9227 | their execution at a later point. A user typically employs | |
9228 | this facility via an interactive interface supplied jointly | |
a0c0a00f CR |
9229 | by the operating system kernel’s terminal driver and Bash. |
9230 | </p> | |
9231 | <p>The shell associates a <var>job</var> with each pipeline. It keeps a | |
17345e5a | 9232 | table of currently executing jobs, which may be listed with the |
a0c0a00f | 9233 | <code>jobs</code> command. When Bash starts a job |
17345e5a JA |
9234 | asynchronously, it prints a line that looks |
9235 | like: | |
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 |
9240 | of the last process in the pipeline associated with this job is |
9241 | 25647. All of the processes in a single pipeline are members of | |
a0c0a00f | 9242 | the same job. Bash uses the <var>job</var> abstraction as the |
17345e5a | 9243 | basis for job control. |
a0c0a00f CR |
9244 | </p> |
9245 | <p>To facilitate the implementation of the user interface to job | |
17345e5a | 9246 | control, the operating system maintains the notion of a current terminal |
a0c0a00f CR |
9247 | process group <small>ID</small>. Members of this process group (processes whose |
9248 | process 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 | 9250 | These processes are said to be in the foreground. Background |
a0c0a00f CR |
9251 | processes are those whose process group <small>ID</small> differs from the |
9252 | terminal’s; such processes are immune to keyboard-generated | |
0001803f | 9253 | signals. Only foreground processes are allowed to read from or, if |
a0c0a00f | 9254 | the user so specifies with <code>stty tostop</code>, write to the terminal. |
0001803f | 9255 | Background processes which attempt to |
a0c0a00f CR |
9256 | read from (write to when <code>stty tostop</code> is in effect) the |
9257 | terminal are sent a <code>SIGTTIN</code> (<code>SIGTTOU</code>) | |
9258 | signal by the kernel’s terminal driver, | |
0001803f | 9259 | which, unless caught, suspends the process. |
a0c0a00f CR |
9260 | </p> |
9261 | <p>If the operating system on which Bash is running supports | |
17345e5a | 9262 | job control, Bash contains facilities to use it. Typing the |
a0c0a00f | 9263 | <var>suspend</var> character (typically ‘<samp>^Z</samp>’, Control-Z) while a |
17345e5a | 9264 | process is running causes that process to be stopped and returns |
a0c0a00f CR |
9265 | control to Bash. Typing the <var>delayed suspend</var> character |
9266 | (typically ‘<samp>^Y</samp>’, Control-Y) causes the process to be stopped | |
17345e5a JA |
9267 | when it attempts to read input from the terminal, and control to |
9268 | be returned to Bash. The user then manipulates the state of | |
a0c0a00f CR |
9269 | this job, using the <code>bg</code> command to continue it in the |
9270 | background, the <code>fg</code> command to continue it in the | |
9271 | foreground, or the <code>kill</code> command to kill it. A ‘<samp>^Z</samp>’ | |
17345e5a JA |
9272 | takes effect immediately, and has the additional side effect of |
9273 | causing 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 | |
9276 | character ‘<samp>%</samp>’ introduces a job specification (<var>jobspec</var>). | |
9277 | </p> | |
9278 | <p>Job number <code>n</code> may be referred to as ‘<samp>%n</samp>’. | |
9279 | The symbols ‘<samp>%%</samp>’ and ‘<samp>%+</samp>’ refer to the shell’s notion of the | |
17345e5a JA |
9280 | current job, which is the last job stopped while it was in the foreground |
9281 | or started in the background. | |
a0c0a00f | 9282 | A single ‘<samp>%</samp>’ (with no accompanying job specification) also refers |
17345e5a | 9283 | to the current job. |
a0c0a00f CR |
9284 | The previous job may be referenced using ‘<samp>%-</samp>’. |
9285 | If there is only a single job, ‘<samp>%+</samp>’ and ‘<samp>%-</samp>’ can both be used | |
17345e5a | 9286 | to refer to that job. |
a0c0a00f CR |
9287 | In output pertaining to jobs (e.g., the output of the <code>jobs</code> |
9288 | command), the current job is always flagged with a ‘<samp>+</samp>’, and the | |
9289 | previous job with a ‘<samp>-</samp>’. | |
9290 | </p> | |
9291 | <p>A job may also be referred to | |
17345e5a | 9292 | using a prefix of the name used to start it, or using a substring |
a0c0a00f CR |
9293 | that appears in its command line. For example, ‘<samp>%ce</samp>’ refers |
9294 | to a stopped <code>ce</code> job. Using ‘<samp>%?ce</samp>’, on the | |
9295 | other hand, refers to any job containing the string ‘<samp>ce</samp>’ in | |
17345e5a JA |
9296 | its command line. If the prefix or substring matches more than one job, |
9297 | Bash reports an error. | |
a0c0a00f CR |
9298 | </p> |
9299 | <p>Simply naming a job can be used to bring it into the foreground: | |
9300 | ‘<samp>%1</samp>’ is a synonym for ‘<samp>fg %1</samp>’, bringing job 1 from the | |
9301 | background into the foreground. Similarly, ‘<samp>%1 &</samp>’ resumes | |
9302 | job 1 in the background, equivalent to ‘<samp>bg %1</samp>’ | |
9303 | </p> | |
9304 | <p>The shell learns immediately whenever a job changes state. | |
17345e5a | 9305 | Normally, Bash waits until it is about to print a prompt |
a0c0a00f | 9306 | before reporting changes in a job’s status so as to not interrupt |
17345e5a | 9307 | any other output. |
a0c0a00f CR |
9308 | If the <samp>-b</samp> option to the <code>set</code> builtin is enabled, |
9309 | Bash reports such changes immediately (see <a href="#The-Set-Builtin">The Set Builtin</a>). | |
9310 | Any trap on <code>SIGCHLD</code> is executed for each child process | |
17345e5a | 9311 | that exits. |
a0c0a00f CR |
9312 | </p> |
9313 | <p>If an attempt to exit Bash is made while jobs are stopped, (or running, if | |
9314 | the <code>checkjobs</code> option is enabled – see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), the | |
9315 | shell prints a warning message, and if the <code>checkjobs</code> option is | |
17345e5a | 9316 | enabled, lists the jobs and their statuses. |
a0c0a00f | 9317 | The <code>jobs</code> command may then be used to inspect their status. |
17345e5a JA |
9318 | If a second attempt to exit is made without an intervening command, |
9319 | Bash 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> |
9322 | builtin, and job control is enabled, <code>wait</code> will return when the | |
9323 | job changes state. The <samp>-f</samp> option will force <code>wait</code> to wait | |
9324 | until 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> | |
9330 | Next: <a href="#Job-Control-Variables" accesskey="n" rel="next">Job Control Variables</a>, Previous: <a href="#Job-Control-Basics" accesskey="p" rel="prev">Job Control Basics</a>, Up: <a href="#Job-Control" accesskey="u" rel="up">Job Control</a> [<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> …] | |
9340 | </pre></div> | |
9341 | ||
9342 | <p>Resume each suspended job <var>jobspec</var> in the background, as if it | |
9343 | had been started with ‘<samp>&</samp>’. | |
9344 | If <var>jobspec</var> is not supplied, the current job is used. | |
17345e5a JA |
9345 | The return status is zero unless it is run when job control is not |
9346 | enabled, or, when run with job control enabled, any | |
a0c0a00f | 9347 | <var>jobspec</var> was not found or specifies a job |
17345e5a | 9348 | that 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. | |
9358 | If <var>jobspec</var> is not supplied, the current job is used. | |
17345e5a JA |
9359 | The return status is that of the command placed into the foreground, |
9360 | or non-zero if run when job control is disabled or, when run with | |
a0c0a00f CR |
9361 | job 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>] | |
9369 | jobs -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 | 9373 | following 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 | 9382 | the 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’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 | 9399 | output is restricted to information about that job. |
a0c0a00f | 9400 | If <var>jobspec</var> is not supplied, the status of all jobs is |
17345e5a | 9401 | listed. |
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 | |
9405 | corresponding process group <small>ID</small>, and executes <var>command</var>, | |
9406 | passing 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> | |
9413 | kill -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 | |
9417 | named 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) | |
9420 | or a signal number; <var>signum</var> is a signal number. | |
9421 | If <var>sigspec</var> and <var>signum</var> are not present, <code>SIGTERM</code> is used. | |
9422 | The <samp>-l</samp> option lists the signal names. | |
9423 | If any arguments are supplied when <samp>-l</samp> is given, the names of the | |
17345e5a JA |
9424 | signals corresponding to the arguments are listed, and the return status |
9425 | is zero. | |
a0c0a00f | 9426 | <var>exit_status</var> is a number specifying a signal number or the exit |
17345e5a | 9427 | status of a process terminated by a signal. |
a0c0a00f | 9428 | The <samp>-L</samp> option is equivalent to <samp>-l</samp>. |
17345e5a JA |
9429 | The return status is zero if at least one signal was successfully sent, |
9430 | or 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> …] |
a0c0a00f CR |
9437 | </pre></div> |
9438 | ||
9439 | <p>Wait until the child process specified by each process <small>ID</small> <var>pid</var> | |
9440 | or job specification <var>jobspec</var> exits and return the exit status of the | |
17345e5a JA |
9441 | last command waited for. |
9442 | If a job spec is given, all processes in the job are waited for. | |
9443 | If no arguments are given, all currently active child processes are | |
9444 | waited for, and the return status is zero. | |
a0c0a00f | 9445 | If the <samp>-n</samp> option is supplied, <code>wait</code> waits for any job to |
ac50fbac | 9446 | terminate and returns its exit status. |
9a51695b CR |
9447 | If 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 | |
9449 | returning its status, intead of returning when it changes status. | |
a0c0a00f | 9450 | If neither <var>jobspec</var> nor <var>pid</var> specifies an active child process |
17345e5a | 9451 | of 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> … | <var>pid</var> … ] | |
9458 | </pre></div> | |
9459 | ||
9460 | <p>Without options, remove each <var>jobspec</var> from the table of | |
17345e5a | 9461 | active jobs. |
a0c0a00f CR |
9462 | If the <samp>-h</samp> option is given, the job is not removed from the table, |
9463 | but is marked so that <code>SIGHUP</code> is not sent to the job if the shell | |
9464 | receives a <code>SIGHUP</code>. | |
9465 | If <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. | |
9467 | If no <var>jobspec</var> is supplied, the <samp>-a</samp> option means to remove or | |
9468 | mark all jobs; the <samp>-r</samp> option without a <var>jobspec</var> | |
17345e5a | 9469 | argument 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. | |
9480 | A login shell cannot be suspended; the <samp>-f</samp> | |
17345e5a | 9481 | option 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> | |
9486 | builtins do not accept <var>jobspec</var> arguments. They must be | |
9487 | supplied process <small>ID</small>s. | |
9488 | </p> | |
9489 | <hr> | |
9490 | <a name="Job-Control-Variables"></a> | |
9491 | <div class="header"> | |
9492 | <p> | |
9493 | Previous: <a href="#Job-Control-Builtins" accesskey="p" rel="prev">Job Control Builtins</a>, Up: <a href="#Job-Control" accesskey="u" rel="up">Job Control</a> [<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 |
9503 | job control. If this variable exists then single word simple |
9504 | commands without redirections are treated as candidates for resumption | |
9505 | of an existing job. There is no ambiguity allowed; if there is | |
9506 | more than one job beginning with the string typed, then | |
9507 | the most recently accessed job will be selected. | |
9508 | The name of a stopped job, in this context, is the command line | |
a0c0a00f | 9509 | used to start it. If this variable is set to the value ‘<samp>exact</samp>’, |
17345e5a | 9510 | the string supplied must match the name of a stopped job exactly; |
a0c0a00f | 9511 | if set to ‘<samp>substring</samp>’, |
17345e5a | 9512 | the string supplied needs to match a substring of the name of a |
a0c0a00f CR |
9513 | stopped job. The ‘<samp>substring</samp>’ value provides functionality |
9514 | analogous to the ‘<samp>%?</samp>’ job <small>ID</small> (see <a href="#Job-Control-Basics">Job Control Basics</a>). | |
17345e5a | 9515 | If set to any other value, the supplied string must |
a0c0a00f CR |
9516 | be a prefix of a stopped job’s name; this provides functionality |
9517 | analogous to the ‘<samp>%</samp>’ 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> | |
9531 | Next: <a href="#Using-History-Interactively" accesskey="n" rel="next">Using History Interactively</a>, Previous: <a href="#Job-Control" accesskey="p" rel="prev">Job Control</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<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 |
9537 | command line editing interface. |
9538 | Command line editing is provided by the Readline library, which is | |
9539 | used by several different programs, including Bash. | |
9540 | Command line editing is enabled by default when using an interactive shell, | |
a0c0a00f CR |
9541 | unless the <samp>--noediting</samp> option is supplied at shell invocation. |
9542 | Line 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 | 9544 | By default, the line editing commands are similar to those of Emacs. |
17345e5a | 9545 | A vi-style line editing interface is also available. |
a0c0a00f CR |
9546 | Line 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">• <a href="#Introduction-and-Notation" accesskey="1">Introduction and Notation</a>:</td><td> </td><td align="left" valign="top">Notation used in this text. | |
9553 | </td></tr> | |
9554 | <tr><td align="left" valign="top">• <a href="#Readline-Interaction" accesskey="2">Readline Interaction</a>:</td><td> </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">• <a href="#Readline-Init-File" accesskey="3">Readline Init File</a>:</td><td> </td><td align="left" valign="top">Customizing Readline from a user’s view. | |
9557 | </td></tr> | |
9558 | <tr><td align="left" valign="top">• <a href="#Bindable-Readline-Commands" accesskey="4">Bindable Readline Commands</a>:</td><td> </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">• <a href="#Readline-vi-Mode" accesskey="5">Readline vi Mode</a>:</td><td> </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">• <a href="#Programmable-Completion" accesskey="6">Programmable Completion</a>:</td><td> </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">• <a href="#Programmable-Completion-Builtins" accesskey="7">Programmable Completion Builtins</a>:</td><td> </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">• <a href="#A-Programmable-Completion-Example" accesskey="8">A Programmable Completion Example</a>:</td><td> </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> | |
9579 | Next: <a href="#Readline-Interaction" accesskey="n" rel="next">Readline Interaction</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> [<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 | 9585 | keystrokes. |
a0c0a00f CR |
9586 | </p> |
9587 | <p>The text <kbd>C-k</kbd> is read as ‘Control-K’ and describes the character | |
9588 | produced when the <tt class="key">k</tt> key is pressed while the Control key | |
17345e5a | 9589 | is depressed. |
a0c0a00f CR |
9590 | </p> |
9591 | <p>The text <kbd>M-k</kbd> is read as ‘Meta-K’ and describes the character | |
9592 | produced when the Meta key (if you have one) is depressed, and the <tt class="key">k</tt> | |
17345e5a | 9593 | key is pressed. |
a0c0a00f CR |
9594 | The Meta key is labeled <tt class="key">ALT</tt> on many keyboards. |
9595 | On keyboards with two keys labeled <tt class="key">ALT</tt> (usually to either side of | |
9596 | the space bar), the <tt class="key">ALT</tt> on the left side is generally set to | |
17345e5a | 9597 | work as a Meta key. |
a0c0a00f | 9598 | The <tt class="key">ALT</tt> key on the right may also be configured to work as a |
17345e5a JA |
9599 | Meta key or may be configured as some other modifier, such as a |
9600 | Compose 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 | |
9603 | a 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>. | |
9605 | Either 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 ‘Meta-Control-k’ and describes the | |
9608 | character 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 | 9612 | stand 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>). |
9614 | If your keyboard lacks a <tt class="key">LFD</tt> key, typing <tt class="key">C-j</tt> will | |
17345e5a | 9615 | produce the desired character. |
a0c0a00f | 9616 | The <tt class="key">RET</tt> key may be labeled <tt class="key">Return</tt> or <tt class="key">Enter</tt> on |
17345e5a | 9617 | some keyboards. |
a0c0a00f CR |
9618 | </p> |
9619 | <hr> | |
9620 | <a name="Readline-Interaction"></a> | |
9621 | <div class="header"> | |
9622 | <p> | |
9623 | Next: <a href="#Readline-Init-File" accesskey="n" rel="next">Readline Init File</a>, Previous: <a href="#Introduction-and-Notation" accesskey="p" rel="prev">Introduction and Notation</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> [<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 |
9630 | only to notice that the first word on the line is misspelled. The |
9631 | Readline library gives you a set of commands for manipulating the text | |
9632 | as you type it in, allowing you to just fix your typo, and not forcing | |
9633 | you to retype the majority of the line. Using these editing commands, | |
9634 | you move the cursor to the place that needs correction, and delete or | |
9635 | insert the text of the corrections. Then, when you are satisfied with | |
a0c0a00f CR |
9636 | the line, you simply press <tt class="key">RET</tt>. You do not have to be at the |
9637 | end of the line to press <tt class="key">RET</tt>; the entire line is accepted | |
17345e5a | 9638 | regardless 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">• <a href="#Readline-Bare-Essentials" accesskey="1">Readline Bare Essentials</a>:</td><td> </td><td align="left" valign="top">The least you need to know about Readline. | |
9642 | </td></tr> | |
9643 | <tr><td align="left" valign="top">• <a href="#Readline-Movement-Commands" accesskey="2">Readline Movement Commands</a>:</td><td> </td><td align="left" valign="top">Moving about the input line. | |
9644 | </td></tr> | |
9645 | <tr><td align="left" valign="top">• <a href="#Readline-Killing-Commands" accesskey="3">Readline Killing Commands</a>:</td><td> </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">• <a href="#Readline-Arguments" accesskey="4">Readline Arguments</a>:</td><td> </td><td align="left" valign="top">Giving numeric arguments to commands. | |
9648 | </td></tr> | |
9649 | <tr><td align="left" valign="top">• <a href="#Searching" accesskey="5">Searching</a>:</td><td> </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> | |
9657 | Next: <a href="#Readline-Movement-Commands" accesskey="n" rel="next">Readline Movement Commands</a>, Up: <a href="#Readline-Interaction" accesskey="u" rel="up">Readline Interaction</a> [<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 |
9666 | character appears where the cursor was, and then the cursor moves one |
9667 | space to the right. If you mistype a character, you can use your | |
9668 | erase character to back up and delete the mistyped character. | |
a0c0a00f CR |
9669 | </p> |
9670 | <p>Sometimes you may mistype a character, and | |
17345e5a | 9671 | not notice the error until you have typed several other characters. In |
a0c0a00f | 9672 | that case, you can type <kbd>C-b</kbd> to move the cursor to the left, and then |
17345e5a | 9673 | correct your mistake. Afterwards, you can move the cursor to the right |
a0c0a00f CR |
9674 | with <kbd>C-f</kbd>. |
9675 | </p> | |
9676 | <p>When you add text in the middle of a line, you will notice that characters | |
9677 | to the right of the cursor are ‘pushed over’ to make room for the text | |
17345e5a | 9678 | that you have inserted. Likewise, when you delete text behind the cursor, |
a0c0a00f | 9679 | characters to the right of the cursor are ‘pulled back’ to fill in the |
17345e5a JA |
9680 | blank space created by the removal of the text. A list of the bare |
9681 | essentials 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 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 | 9701 | empty 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 |
9706 | delete the character to the left of the cursor and the <tt class="key">DEL</tt> key set | |
9707 | to delete the character underneath the cursor, like <kbd>C-d</kbd>, rather | |
17345e5a | 9708 | than 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> | |
9714 | Next: <a href="#Readline-Killing-Commands" accesskey="n" rel="next">Readline Killing Commands</a>, Previous: <a href="#Readline-Bare-Essentials" accesskey="p" rel="prev">Readline Bare Essentials</a>, Up: <a href="#Readline-Interaction" accesskey="u" rel="up">Readline Interaction</a> [<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 | 9721 | in order to do editing of the input line. For your convenience, many |
a0c0a00f CR |
9722 | other 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 | 9724 | about 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 |
9745 | forward a word. It is a loose convention that control keystrokes |
9746 | operate 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> | |
9752 | Next: <a href="#Readline-Arguments" accesskey="n" rel="next">Readline Arguments</a>, Previous: <a href="#Readline-Movement-Commands" accesskey="p" rel="prev">Readline Movement Commands</a>, Up: <a href="#Readline-Interaction" accesskey="u" rel="up">Readline Interaction</a> [<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 | |
9761 | it away for later use, usually by <em>yanking</em> (re-inserting) | |
17345e5a | 9762 | it back into the line. |
a0c0a00f CR |
9763 | (‘Cut’ and ‘paste’ are more recent jargon for ‘kill’ and ‘yank’.) |
9764 | </p> | |
9765 | <p>If the description for a command says that it ‘kills’ text, then you can | |
17345e5a JA |
9766 | be sure that you can get the text back in a different (or the same) |
9767 | place 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 |
9770 | Any number of consecutive kills save all of the killed text together, so |
9771 | that when you yank it back, you get it all. The kill | |
9772 | ring is not line specific; the text that you killed on a previously | |
9773 | typed line is available to be yanked back later, when you are typing | |
9774 | another 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 | 9786 | words, to the end of the next word. |
a0c0a00f CR |
9787 | Word 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 | 9792 | words, to the start of the previous word. |
a0c0a00f CR |
9793 | Word 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 | 9804 | means 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 | |
9813 | the 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> | |
9821 | Next: <a href="#Searching" accesskey="n" rel="next">Searching</a>, Previous: <a href="#Readline-Killing-Commands" accesskey="p" rel="prev">Readline Killing Commands</a>, Up: <a href="#Readline-Interaction" accesskey="u" rel="up">Readline Interaction</a> [<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 | |
9827 | argument acts as a repeat count, other times it is the <i>sign</i> of the | |
17345e5a JA |
9828 | argument that is significant. If you pass a negative argument to a |
9829 | command which normally acts in a forward direction, that command will | |
9830 | act in a backward direction. For example, to kill text back to the | |
a0c0a00f CR |
9831 | start of the line, you might type ‘<samp>M-- C-k</samp>’. |
9832 | </p> | |
9833 | <p>The general way to pass numeric arguments to a command is to type meta | |
9834 | digits before the command. If the first ‘digit’ typed is a minus | |
9835 | sign (‘<samp>-</samp>’), then the sign of the argument will be negative. Once | |
17345e5a JA |
9836 | you have typed one meta digit to get the argument started, you can type |
9837 | the remainder of the digits, and then the command. For example, to give | |
a0c0a00f | 9838 | the <kbd>C-d</kbd> command an argument of 10, you could type ‘<samp>M-1 0 C-d</samp>’, |
17345e5a | 9839 | which 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> | |
9845 | Previous: <a href="#Readline-Arguments" accesskey="p" rel="prev">Readline Arguments</a>, Up: <a href="#Readline-Interaction" accesskey="u" rel="up">Readline Interaction</a> [<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 | 9852 | for lines containing a specified string. |
a0c0a00f CR |
9853 | There 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 |
9856 | search string. |
9857 | As each character of the search string is typed, Readline displays | |
9858 | the next entry from the history matching the string typed so far. | |
9859 | An incremental search requires only as many characters as needed to | |
9860 | find the desired history entry. | |
9861 | To 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. |
9863 | The characters present in the value of the <code>isearch-terminators</code> variable | |
17345e5a | 9864 | are used to terminate an incremental search. |
a0c0a00f CR |
9865 | If 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 |
9868 | When the search is terminated, the history entry containing the |
9869 | search 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 |
9873 | This will search backward or forward in the history for the next |
9874 | entry matching the search string typed so far. | |
9875 | Any other key sequence bound to a Readline command will terminate | |
9876 | the search and execute that command. | |
a0c0a00f | 9877 | For instance, a <tt class="key">RET</tt> will terminate the search and accept |
17345e5a JA |
9878 | the line, thereby executing the command from the history list. |
9879 | A movement command will terminate the search, make the last line found | |
9880 | the 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 | 9884 | search 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 |
9887 | to search for matching history lines. The search string may be |
9888 | typed 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> | |
9894 | Next: <a href="#Bindable-Readline-Commands" accesskey="n" rel="next">Bindable Readline Commands</a>, Previous: <a href="#Readline-Interaction" accesskey="p" rel="prev">Readline Interaction</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> [<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 |
9901 | keybindings installed by default, it is possible to use a different set |
9902 | of keybindings. | |
9903 | Any user can customize programs that use Readline by putting | |
a0c0a00f | 9904 | commands in an <em>inputrc</em> file, conventionally in his home directory. |
17345e5a | 9905 | The name of this |
a0c0a00f CR |
9906 | file is taken from the value of the shell variable <code>INPUTRC</code>. If |
9907 | that variable is unset, the default is <samp>~/.inputrc</samp>. If that | |
17345e5a | 9908 | file 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 | 9912 | init 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 | 9915 | incorporating 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">• <a href="#Readline-Init-File-Syntax" accesskey="1">Readline Init File Syntax</a>:</td><td> </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">• <a href="#Conditional-Init-Constructs" accesskey="2">Conditional Init Constructs</a>:</td><td> </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">• <a href="#Sample-Init-File" accesskey="3">Sample Init File</a>:</td><td> </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> | |
9934 | Next: <a href="#Conditional-Init-Constructs" accesskey="n" rel="next">Conditional Init Constructs</a>, Up: <a href="#Readline-Init-File" accesskey="u" rel="up">Readline Init File</a> [<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 | 9940 | Readline init file. Blank lines are ignored. |
a0c0a00f CR |
9941 | Lines beginning with a ‘<samp>#</samp>’ are comments. |
9942 | Lines beginning with a ‘<samp>$</samp>’ indicate conditional | |
9943 | constructs (see <a href="#Conditional-Init-Constructs">Conditional Init Constructs</a>). Other lines | |
17345e5a | 9944 | denote 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 | 9949 | altering the values of variables in Readline |
a0c0a00f | 9950 | using the <code>set</code> command within the init file. |
17345e5a | 9951 | The 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 | 9958 | change 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 | 9966 | to 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 | |
9969 | the value is null or empty, <var>on</var> (case-insensitive), or 1. Any other | |
17345e5a | 9970 | value results in the variable being set to off. |
a0c0a00f CR |
9971 | </p> |
9972 | <p>The <code>bind <span class="nolinebreak">-V</span></code><!-- /@w --> command lists the current Readline variable names | |
9973 | and 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 | 9976 | variables. |
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. | |
9983 | If set to ‘<samp>none</samp>’, Readline never rings the bell. If set to | |
9984 | ‘<samp>visible</samp>’, Readline uses a visible bell if one is available. | |
9985 | If set to ‘<samp>audible</samp>’ (the default), Readline attempts to ring | |
9986 | the terminal’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 ‘<samp>on</samp>’ (the default), Readline attempts to bind the control | |
9992 | characters treated specially by the kernel’s terminal driver to their | |
9993 | Readline 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 ‘<samp>on</samp>’, Readline attempts to briefly move the cursor to an | |
9999 | opening parenthesis when a closing parenthesis is inserted. The default | |
10000 | is ‘<samp>off</samp>’. | |
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 ‘<samp>on</samp>’, when listing completions, Readline displays the | |
10006 | common prefix of the set of possible completions using a different color. | |
10007 | The color definitions are taken from the value of the <code>LS_COLORS</code> | |
10008 | environment variable. | |
10009 | The default is ‘<samp>off</samp>’. | |
10010 | </p> | |
10011 | </dd> | |
10012 | <dt><code>colored-stats</code></dt> | |
10013 | <dd><a name="index-colored_002dstats"></a> | |
10014 | <p>If set to ‘<samp>on</samp>’, Readline displays possible completions using different | |
ac50fbac | 10015 | colors to indicate their file type. |
a0c0a00f | 10016 | The color definitions are taken from the value of the <code>LS_COLORS</code> |
ac50fbac | 10017 | environment variable. |
a0c0a00f CR |
10018 | The default is ‘<samp>off</samp>’. |
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 | |
10025 | is <code>"#"</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 |
10031 | when performing completion. |
10032 | The value is ignored if it is less than 0 or greater than the terminal | |
10033 | screen width. | |
10034 | A value of 0 will cause matches to be displayed one per line. | |
10035 | The 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 ‘<samp>on</samp>’, Readline performs filename matching and completion | |
17345e5a | 10041 | in a case-insensitive fashion. |
a0c0a00f CR |
10042 | The default value is ‘<samp>off</samp>’. |
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 ‘<samp>on</samp>’, and <var>completion-ignore-case</var> is enabled, Readline | |
10048 | treats hyphens (‘<samp>-</samp>’) and underscores (‘<samp>_</samp>’) as equivalent when | |
495aee44 | 10049 | performing case-insensitive filename matching and completion. |
2f5dfe5a | 10050 | The default value is ‘<samp>off</samp>’. |
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 |
10056 | completions that is displayed without modification. When set to a |
10057 | value greater than zero, common prefixes longer than this value are | |
10058 | replaced 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 |
10064 | asked whether the list of possibilities should be displayed. |
10065 | If the number of possible completions is greater than this value, | |
10066 | Readline will ask the user whether or not he wishes to view | |
10067 | them; otherwise, they are simply listed. | |
10068 | This variable must be set to an integer value greater than or equal to 0. | |
10069 | A negative value means Readline should never ask. | |
a0c0a00f CR |
10070 | The 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 ‘<samp>on</samp>’, Readline will convert characters with the | |
10076 | eighth bit set to an <small>ASCII</small> key sequence by stripping the eighth | |
10077 | bit and prefixing an <tt class="key">ESC</tt> character, converting them to a | |
10078 | meta-prefixed key sequence. The default value is ‘<samp>on</samp>’, but | |
10079 | will be set to ‘<samp>off</samp>’ if the locale is one that contains | |
10080 | eight-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 ‘<samp>On</samp>’, Readline will inhibit word completion. | |
17345e5a | 10086 | Completion characters will be inserted into the line as if they had |
a0c0a00f CR |
10087 | been mapped to <code>self-insert</code>. The default is ‘<samp>off</samp>’. |
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 ‘<samp>on</samp>’, on operating systems that indicate they support it, | |
10093 | readline echoes a character corresponding to a signal generated from the | |
10094 | keyboard. The default is ‘<samp>on</samp>’. | |
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 |
10100 | key bindings is used. By default, Readline starts up in Emacs editing |
10101 | mode, where the keystrokes are most similar to Emacs. This variable can be | |
a0c0a00f CR |
10102 | set to either ‘<samp>emacs</samp>’ or ‘<samp>vi</samp>’. |
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, |
10108 | this string is displayed immediately before the last line of the primary | |
a0c0a00f CR |
10109 | prompt when emacs editing mode is active. The value is expanded like a |
10110 | key binding, so the standard set of meta- and control prefixes and | |
10111 | backslash escape sequences is available. | |
10112 | Use the ‘<samp>\1</samp>’ and ‘<samp>\2</samp>’ escapes to begin and end sequences of | |
10113 | non-printing characters, which can be used to embed a terminal control | |
10114 | sequence into the mode string. | |
10115 | The default is ‘<samp>@</samp>’. | |
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 ‘<samp>On</samp>’, Readline will configure the terminal in a way | |
10121 | that will enable it to insert each paste into the editing buffer as a | |
10122 | single string of characters, instead of treating each character as if | |
10123 | it had been read from the keyboard. This can prevent pasted characters | |
10124 | from being interpreted as editing commands. The default is ‘<samp>off</samp>’. | |
10125 | </p> | |
10126 | </dd> | |
10127 | <dt><code>enable-keypad</code></dt> | |
10128 | <dd><a name="index-enable_002dkeypad"></a> | |
10129 | <p>When set to ‘<samp>on</samp>’, Readline will try to enable the application | |
17345e5a | 10130 | keypad when it is called. Some systems need this to enable the |
a0c0a00f CR |
10131 | arrow keys. The default is ‘<samp>off</samp>’. |
10132 | </p> | |
10133 | </dd> | |
10134 | <dt><code>enable-meta-key</code></dt> | |
10135 | <dd><p>When set to ‘<samp>on</samp>’, Readline will try to enable any meta modifier | |
0001803f CR |
10136 | key the terminal claims to support when it is called. On many terminals, |
10137 | the meta key is used to send eight-bit characters. | |
a0c0a00f CR |
10138 | The default is ‘<samp>on</samp>’. |
10139 | </p> | |
10140 | </dd> | |
10141 | <dt><code>expand-tilde</code></dt> | |
10142 | <dd><a name="index-expand_002dtilde"></a> | |
10143 | <p>If set to ‘<samp>on</samp>’, tilde expansion is performed when Readline | |
10144 | attempts word completion. The default is ‘<samp>off</samp>’. | |
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 ‘<samp>on</samp>’, the history code attempts to place the point (the | |
17345e5a | 10150 | current cursor position) at the |
a0c0a00f CR |
10151 | same location on each history line retrieved with <code>previous-history</code> |
10152 | or <code>next-history</code>. The default is ‘<samp>off</samp>’. | |
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 |
10158 | If set to zero, any existing history entries are deleted and no new entries |
10159 | are saved. | |
10160 | If set to a value less than zero, the number of history entries is not | |
10161 | limited. | |
10162 | By default, the number of history entries is not limited. | |
a0c0a00f CR |
10163 | If an attempt is made to set <var>history-size</var> to a non-numeric value, |
10164 | the 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 ‘<samp>on</samp>’ or ‘<samp>off</samp>’. Setting it | |
10170 | to ‘<samp>on</samp>’ means that the text of the lines being edited will scroll | |
17345e5a JA |
10171 | horizontally on a single screen line when they are longer than the width |
10172 | of the screen, instead of wrapping onto a new screen line. By default, | |
a0c0a00f CR |
10173 | this variable is set to ‘<samp>off</samp>’. |
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 ‘<samp>on</samp>’, Readline will enable eight-bit input (it | |
17345e5a JA |
10180 | will not clear the eighth bit in the characters it reads), |
10181 | regardless of what the terminal claims it can support. The | |
a0c0a00f CR |
10182 | default value is ‘<samp>off</samp>’, but Readline will set it to ‘<samp>on</samp>’ if the |
10183 | locale contains eight-bit characters. | |
10184 | The 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 | |
10190 | subsequently executing the character as a command (see <a href="#Searching">Searching</a>). | |
10191 | If 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’s idea of the current keymap for key binding commands. | |
10198 | Acceptable <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 | |
10208 | synonym); <code>emacs</code> is equivalent to <code>emacs-standard</code>. | |
10209 | The default value is <code>emacs</code>. | |
10210 | The value of the <code>editing-mode</code> variable also affects the | |
17345e5a | 10211 | default 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 |
10216 | ambiguous key sequence (one that can form a complete key sequence using |
10217 | the input read so far, or can take additional input to complete a longer | |
10218 | key sequence). | |
10219 | If no input is received within the timeout, Readline will use the shorter | |
10220 | but complete key sequence. | |
10221 | Readline uses this value to determine whether or not input is | |
a0c0a00f | 10222 | available on the current input source (<code>rl_instream</code> by default). |
ac50fbac CR |
10223 | The value is specified in milliseconds, so a value of 1000 means that |
10224 | Readline will wait one second for additional input. | |
10225 | If this variable is set to a value less than or equal to zero, or to a | |
10226 | non-numeric value, Readline will wait until another key is pressed to | |
10227 | decide which key sequence to complete. | |
a0c0a00f CR |
10228 | The default value is <code>500</code>. |
10229 | </p> | |
10230 | </dd> | |
10231 | <dt><code>mark-directories</code></dt> | |
10232 | <dd><p>If set to ‘<samp>on</samp>’, completed directory names have a slash | |
10233 | appended. The default is ‘<samp>on</samp>’. | |
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 ‘<samp>on</samp>’, causes Readline to display an | |
10239 | asterisk (‘<samp>*</samp>’) at the start of history lines which have been modified. | |
10240 | This variable is ‘<samp>off</samp>’ 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 ‘<samp>on</samp>’, completed names which are symbolic links | |
17345e5a | 10246 | to directories have a slash appended (subject to the value of |
a0c0a00f CR |
10247 | <code>mark-directories</code>). |
10248 | The default is ‘<samp>off</samp>’. | |
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 ‘<samp>on</samp>’, causes Readline to match files whose | |
10254 | names begin with a ‘<samp>.</samp>’ (hidden files) when performing filename | |
495aee44 | 10255 | completion. |
a0c0a00f | 10256 | If set to ‘<samp>off</samp>’, the leading ‘<samp>.</samp>’ must be |
17345e5a | 10257 | supplied by the user in the filename to be completed. |
a0c0a00f CR |
10258 | This variable is ‘<samp>on</samp>’ 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 ‘<samp>on</samp>’, menu completion displays the common prefix of the | |
495aee44 | 10264 | list of possible completions (which may be empty) before cycling through |
a0c0a00f CR |
10265 | the list. The default is ‘<samp>off</samp>’. |
10266 | </p> | |
10267 | </dd> | |
10268 | <dt><code>output-meta</code></dt> | |
10269 | <dd><a name="index-output_002dmeta"></a> | |
10270 | <p>If set to ‘<samp>on</samp>’, Readline will display characters with the | |
17345e5a | 10271 | eighth bit set directly rather than as a meta-prefixed escape |
a0c0a00f CR |
10272 | sequence. |
10273 | The default is ‘<samp>off</samp>’, but Readline will set it to ‘<samp>on</samp>’ if the | |
10274 | locale 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 ‘<samp>on</samp>’, Readline uses an internal <code>more</code>-like pager | |
17345e5a | 10280 | to display a screenful of possible completions at a time. |
a0c0a00f CR |
10281 | This variable is ‘<samp>on</samp>’ by default. |
10282 | </p> | |
10283 | </dd> | |
10284 | <dt><code>print-completions-horizontally</code></dt> | |
10285 | <dd><p>If set to ‘<samp>on</samp>’, Readline will display completions with matches | |
17345e5a | 10286 | sorted horizontally in alphabetical order, rather than down the screen. |
a0c0a00f CR |
10287 | The default is ‘<samp>off</samp>’. |
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 ‘<samp>on</samp>’, Readline will undo all changes to history lines | |
10293 | before returning when <code>accept-line</code> is executed. By default, | |
17345e5a | 10294 | history lines may be modified and retain individual undo lists across |
a0c0a00f CR |
10295 | calls to <code>readline</code>. The default is ‘<samp>off</samp>’. |
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 | |
10301 | set to ‘<samp>on</samp>’, | |
17345e5a JA |
10302 | words which have more than one possible completion cause the |
10303 | matches to be listed immediately instead of ringing the bell. | |
a0c0a00f CR |
10304 | The default value is ‘<samp>off</samp>’. |
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 | |
10310 | a fashion similar to <var>show-all-if-ambiguous</var>. | |
10311 | If set to ‘<samp>on</samp>’, | |
17345e5a | 10312 | words which have more than one possible completion without any |
a0c0a00f | 10313 | possible partial completion (the possible completions don’t share |
17345e5a JA |
10314 | a common prefix) cause the matches to be listed immediately instead |
10315 | of ringing the bell. | |
a0c0a00f CR |
10316 | The default value is ‘<samp>off</samp>’. |
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 ‘<samp>on</samp>’, add a string to the beginning of the prompt |
a0c0a00f | 10322 | indicating the editing mode: emacs, vi command, or vi insertion. |
9a51695b | 10323 | The mode strings are user-settable (e.g., <var>emacs-mode-string</var>). |
a0c0a00f CR |
10324 | The default value is ‘<samp>off</samp>’. |
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 ‘<samp>on</samp>’, this alters the default completion behavior when | |
10330 | inserting a single match into the line. It’s only active when | |
0001803f CR |
10331 | performing completion in the middle of a word. If enabled, readline |
10332 | does not insert characters from the completion that match characters | |
10333 | after point in the word being completed, so portions of the word | |
10334 | following the cursor are not duplicated. | |
10335 | For instance, if this is enabled, attempting completion when the cursor | |
a0c0a00f CR |
10336 | is after the ‘<samp>e</samp>’ in ‘<samp>Makefile</samp>’ will result in ‘<samp>Makefile</samp>’ |
10337 | rather than ‘<samp>Makefilefile</samp>’, assuming there is a single possible | |
0001803f | 10338 | completion. |
a0c0a00f CR |
10339 | The default value is ‘<samp>off</samp>’. |
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, |
10345 | this string is displayed immediately before the last line of the primary | |
a0c0a00f CR |
10346 | prompt when vi editing mode is active and in command mode. |
10347 | The value is expanded like a | |
10348 | key binding, so the standard set of meta- and control prefixes and | |
10349 | backslash escape sequences is available. | |
10350 | Use the ‘<samp>\1</samp>’ and ‘<samp>\2</samp>’ escapes to begin and end sequences of | |
10351 | non-printing characters, which can be used to embed a terminal control | |
10352 | sequence into the mode string. | |
10353 | The default is ‘<samp>(cmd)</samp>’. | |
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, |
10359 | this string is displayed immediately before the last line of the primary | |
a0c0a00f CR |
10360 | prompt when vi editing mode is active and in insertion mode. |
10361 | The value is expanded like a | |
10362 | key binding, so the standard set of meta- and control prefixes and | |
10363 | backslash escape sequences is available. | |
10364 | Use the ‘<samp>\1</samp>’ and ‘<samp>\2</samp>’ escapes to begin and end sequences of | |
10365 | non-printing characters, which can be used to embed a terminal control | |
10366 | sequence into the mode string. | |
10367 | The default is ‘<samp>(ins)</samp>’. | |
10368 | </p> | |
10369 | </dd> | |
10370 | <dt><code>visible-stats</code></dt> | |
10371 | <dd><a name="index-visible_002dstats"></a> | |
10372 | <p>If set to ‘<samp>on</samp>’, a character denoting a file’s type | |
17345e5a | 10373 | is appended to the filename when listing possible |
a0c0a00f CR |
10374 | completions. The default is ‘<samp>off</samp>’. |
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 |
10382 | simple. First you need to find the name of the command that you |
10383 | want to change. The following sections contain tables of the command | |
10384 | name, the default keybinding, if any, and a short description of what | |
10385 | the command does. | |
a0c0a00f CR |
10386 | </p> |
10387 | <p>Once you know the name of the command, simply place on a line | |
17345e5a JA |
10388 | in the init file the name of the key |
10389 | you wish to bind the command to, a colon, and then the name of the | |
10390 | command. | |
a0c0a00f | 10391 | There can be no space between the key name and the colon – that will be |
17345e5a JA |
10392 | interpreted as part of the key name. |
10393 | The name of the key can be expressed in different ways, depending on | |
10394 | what you find most comfortable. | |
a0c0a00f CR |
10395 | </p> |
10396 | <p>In addition to command names, readline allows keys to be bound | |
10397 | to a string that is inserted when the key is pressed (a <var>macro</var>). | |
10398 | </p> | |
10399 | <p>The <code>bind <span class="nolinebreak">-p</span></code><!-- /@w --> command displays Readline function names and | |
17345e5a | 10400 | bindings in a format that can put directly into an initialization file. |
a0c0a00f CR |
10401 | See <a href="#Bash-Builtins">Bash Builtins</a>. |
10402 | </p> | |
10403 | <dl compact="compact"> | |
10404 | <dt><var>keyname</var>: <var><span class="nolinebreak">function-name</span></var> or <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 | 10408 | Meta-Rubout: backward-kill-word |
a0c0a00f CR |
10409 | Control-o: "> output" |
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 | 10416 | expressed on the right hand side (that is, to insert the text |
a0c0a00f CR |
10417 | ‘<samp>> output</samp>’ into the line). |
10418 | </p> | |
10419 | <p>A number of symbolic character names are recognized while | |
17345e5a | 10420 | processing 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 | 10431 | and |
a0c0a00f CR |
10432 | <var>TAB</var>. |
10433 | </p> | |
10434 | </dd> | |
10435 | <dt>"<var>keyseq</var>": <var><span class="nolinebreak">function-name</span></var> or <var>macro</var><!-- /@w --></dt> | |
10436 | <dd><p><var>keyseq</var> differs from <var>keyname</var> above in that strings | |
17345e5a | 10437 | denoting an entire key sequence can be specified, by placing |
a0c0a00f | 10438 | the key sequence in double quotes. Some <small>GNU</small> Emacs style key |
17345e5a JA |
10439 | escapes can be used, as in the following example, but the |
10440 | special character names are not recognized. | |
a0c0a00f CR |
10441 | </p> |
10442 | <div class="example"> | |
10443 | <pre class="example">"\C-u": universal-argument | |
10444 | "\C-x\C-r": re-read-init-file | |
10445 | "\e[11~": "Function Key 1" | |
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 | ‘<samp><kbd>C-x</kbd> <kbd>C-r</kbd></samp>’ is bound to the function <code>re-read-init-file</code>, | |
10451 | and ‘<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>’ is bound to insert | |
10452 | the text ‘<samp>Function Key 1</samp>’. | |
10453 | </p> | |
10454 | </dd> | |
10455 | </dl> | |
10456 | ||
10457 | <p>The following <small>GNU</small> Emacs style escape sequences are available when | |
17345e5a | 10458 | specifying 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>\"</kbd></code></dt> | |
10474 | <dd><p><tt class="key">"</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 | 10482 | set 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 |
10520 | be used to indicate a macro definition. |
10521 | Unquoted text is assumed to be a function name. | |
10522 | In the macro body, the backslash escapes described above are expanded. | |
10523 | Backslash will quote any other character in the macro text, | |
a0c0a00f CR |
10524 | including ‘<samp>"</samp>’ and ‘<samp>'</samp>’. |
10525 | For example, the following binding will make ‘<samp><kbd>C-x</kbd> \</samp>’ | |
10526 | insert a single ‘<samp>\</samp>’ into the line: | |
10527 | </p><div class="example"> | |
10528 | <pre class="example">"\C-x\\": "\\" | |
10529 | </pre></div> | |
10530 | ||
10531 | </dd> | |
10532 | </dl> | |
10533 | ||
10534 | <hr> | |
10535 | <a name="Conditional-Init-Constructs"></a> | |
10536 | <div class="header"> | |
10537 | <p> | |
10538 | Next: <a href="#Sample-Init-File" accesskey="n" rel="next">Sample Init File</a>, Previous: <a href="#Readline-Init-File-Syntax" accesskey="p" rel="prev">Readline Init File Syntax</a>, Up: <a href="#Readline-Init-File" accesskey="u" rel="up">Readline Init File</a> [<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 |
10544 | compilation features of the C preprocessor which allows key |
10545 | bindings and variable settings to be performed as the result | |
10546 | of 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 | 10551 | editing mode, the terminal being used, or the application using |
9a51695b CR |
10552 | Readline. The text of the test, after any comparison operator, |
10553 | extends to the end of the line; | |
10554 | unless 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 | |
10559 | whether Readline is in <code>emacs</code> or <code>vi</code> mode. | |
17345e5a | 10560 | This may be used in conjunction |
a0c0a00f CR |
10561 | with the ‘<samp>set keymap</samp>’ command, for instance, to set bindings in |
10562 | the <code>emacs-standard</code> and <code>emacs-ctlx</code> keymaps only if | |
10563 | Readline 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 | 10568 | key bindings, perhaps to bind the key sequences output by the |
a0c0a00f CR |
10569 | terminal’s function keys. The word on the right side of the |
10570 | ‘<samp>=</samp>’ is tested against both the full name of the terminal and | |
10571 | the portion of the terminal name before the first ‘<samp>-</samp>’. This | |
10572 | allows <code>sun</code> to match both <code>sun</code> and <code>sun-cmd</code>, | |
17345e5a | 10573 | for 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 | |
10578 | specific Readline versions. | |
10579 | The <code>version</code> expands to the current Readline version. | |
10580 | The set of comparison operators includes | |
10581 | ‘<samp>=</samp>’ (and ‘<samp>==</samp>’), ‘<samp>!=</samp>’, ‘<samp><=</samp>’, ‘<samp>>=</samp>’, ‘<samp><</samp>’, | |
10582 | and ‘<samp>></samp>’. | |
10583 | The version number supplied on the right side of the operator consists | |
10584 | of a major version number, an optional decimal point, and an optional | |
10585 | minor version (e.g., ‘<samp>7.1</samp>’). If the minor version is omitted, it | |
10586 | is assumed to be ‘<samp>0</samp>’. | |
10587 | The operator may be separated from the string <code>version</code> and | |
10588 | from the version number argument by whitespace. | |
10589 | The following example sets a variable if the Readline version being used | |
10590 | is 7.0 or newer: | |
10591 | </p><div class="example"> | |
10592 | <pre class="example">$if version >= 7.0 | |
10593 | set 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 | 10600 | application-specific settings. Each program using the Readline |
a0c0a00f | 10601 | library sets the <var>application name</var>, and you can test for |
17345e5a JA |
10602 | a particular value. |
10603 | This could be used to bind key sequences to functions useful for | |
10604 | a specific program. For instance, the following command adds a | |
10605 | key 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 | "\C-xq": "\eb\"\ef\"" |
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 | |
10616 | variables and values. | |
10617 | The permitted comparison operators are ‘<samp>=</samp>’, ‘<samp>==</samp>’, and ‘<samp>!=</samp>’. | |
10618 | The variable name must be separated from the comparison operator by | |
10619 | whitespace; the operator may be separated from the value on the right hand | |
10620 | side by whitespace. | |
10621 | Both string and boolean variables may be tested. Boolean variables must be | |
10622 | tested against the values <var>on</var> and <var>off</var>. | |
10623 | The following example is equivalent to the <code>mode=emacs</code> test described | |
10624 | above: | |
10625 | </p><div class="example"> | |
10626 | <pre class="example">$if editing-mode == emacs | |
10627 | set 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 | 10641 | the 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 | 10646 | and bindings from that file. |
a0c0a00f CR |
10647 | For 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> | |
10658 | Previous: <a href="#Conditional-Init-Constructs" accesskey="p" rel="prev">Conditional Init Constructs</a>, Up: <a href="#Readline-Init-File" accesskey="u" rel="up">Readline Init File</a> [<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 | 10664 | binding, 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 | ||
10681 | set editing-mode emacs | |
10682 | ||
10683 | $if mode=emacs | |
10684 | ||
10685 | Meta-Control-h: backward-kill-word Text after the function name is ignored | |
10686 | ||
10687 | # | |
10688 | # Arrow keys in keypad mode | |
10689 | # | |
a0c0a00f CR |
10690 | #"\M-OD": backward-char |
10691 | #"\M-OC": forward-char | |
10692 | #"\M-OA": previous-history | |
10693 | #"\M-OB": next-history | |
17345e5a JA |
10694 | # |
10695 | # Arrow keys in ANSI mode | |
10696 | # | |
a0c0a00f CR |
10697 | "\M-[D": backward-char |
10698 | "\M-[C": forward-char | |
10699 | "\M-[A": previous-history | |
10700 | "\M-[B": next-history | |
17345e5a JA |
10701 | # |
10702 | # Arrow keys in 8 bit keypad mode | |
10703 | # | |
a0c0a00f CR |
10704 | #"\M-\C-OD": backward-char |
10705 | #"\M-\C-OC": forward-char | |
10706 | #"\M-\C-OA": previous-history | |
10707 | #"\M-\C-OB": next-history | |
17345e5a JA |
10708 | # |
10709 | # Arrow keys in 8 bit ANSI mode | |
10710 | # | |
a0c0a00f CR |
10711 | #"\M-\C-[D": backward-char |
10712 | #"\M-\C-[C": forward-char | |
10713 | #"\M-\C-[A": previous-history | |
10714 | #"\M-\C-[B": next-history | |
17345e5a JA |
10715 | |
10716 | C-q: quoted-insert | |
10717 | ||
10718 | $endif | |
10719 | ||
10720 | # An old-style binding. This happens to be the default. | |
10721 | TAB: complete | |
10722 | ||
10723 | # Macros that are convenient for shell interaction | |
10724 | $if Bash | |
10725 | # edit the path | |
a0c0a00f | 10726 | "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f" |
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 | "\C-x\"": "\"\"\C-b" |
17345e5a JA |
10731 | # insert a backslash (testing backslash escapes |
10732 | # in sequences and macros) | |
a0c0a00f | 10733 | "\C-x\\": "\\" |
17345e5a | 10734 | # Quote the current or previous word |
a0c0a00f | 10735 | "\C-xq": "\eb\"\ef\"" |
17345e5a | 10736 | # Add a binding to refresh the line, which is unbound |
a0c0a00f | 10737 | "\C-xr": redraw-current-line |
17345e5a | 10738 | # Edit variable on current line. |
a0c0a00f | 10739 | "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y=" |
17345e5a JA |
10740 | $endif |
10741 | ||
10742 | # use a visible bell if one is available | |
10743 | set bell-style visible | |
10744 | ||
10745 | # don't strip characters to 7 bits when reading | |
10746 | set input-meta on | |
10747 | ||
10748 | # allow iso-latin1 characters to be inserted rather | |
10749 | # than converted to prefix-meta sequences | |
10750 | set convert-meta off | |
10751 | ||
10752 | # display characters with the eighth bit set directly | |
10753 | # rather than as meta-prefixed characters | |
10754 | set 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 | |
10758 | set completion-query-items 150 | |
10759 | ||
10760 | # For FTP | |
10761 | $if Ftp | |
a0c0a00f CR |
10762 | "\C-xg": "get \M-?" |
10763 | "\C-xt": "put \M-?" | |
10764 | "\M-.": 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> | |
10772 | Next: <a href="#Readline-vi-Mode" accesskey="n" rel="next">Readline vi Mode</a>, Previous: <a href="#Readline-Init-File" accesskey="p" rel="prev">Readline Init File</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> [<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">• <a href="#Commands-For-Moving" accesskey="1">Commands For Moving</a>:</td><td> </td><td align="left" valign="top">Moving about the line. | |
10779 | </td></tr> | |
10780 | <tr><td align="left" valign="top">• <a href="#Commands-For-History" accesskey="2">Commands For History</a>:</td><td> </td><td align="left" valign="top">Getting at previous lines. | |
10781 | </td></tr> | |
10782 | <tr><td align="left" valign="top">• <a href="#Commands-For-Text" accesskey="3">Commands For Text</a>:</td><td> </td><td align="left" valign="top">Commands for changing text. | |
10783 | </td></tr> | |
10784 | <tr><td align="left" valign="top">• <a href="#Commands-For-Killing" accesskey="4">Commands For Killing</a>:</td><td> </td><td align="left" valign="top">Commands for killing and yanking. | |
10785 | </td></tr> | |
10786 | <tr><td align="left" valign="top">• <a href="#Numeric-Arguments" accesskey="5">Numeric Arguments</a>:</td><td> </td><td align="left" valign="top">Specifying numeric arguments, repeat counts. | |
10787 | </td></tr> | |
10788 | <tr><td align="left" valign="top">• <a href="#Commands-For-Completion" accesskey="6">Commands For Completion</a>:</td><td> </td><td align="left" valign="top">Getting Readline to do the typing for you. | |
10789 | </td></tr> | |
10790 | <tr><td align="left" valign="top">• <a href="#Keyboard-Macros" accesskey="7">Keyboard Macros</a>:</td><td> </td><td align="left" valign="top">Saving and re-executing typed characters | |
10791 | </td></tr> | |
10792 | <tr><td align="left" valign="top">• <a href="#Miscellaneous-Commands" accesskey="8">Miscellaneous Commands</a>:</td><td> </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 |
10797 | sequences. |
10798 | You can list your key bindings by executing | |
a0c0a00f CR |
10799 | <code>bind <span class="nolinebreak">-P</span></code><!-- /@w --> or, for a more terse format, suitable for an |
10800 | <var>inputrc</var> file, <code>bind <span class="nolinebreak">-p</span></code><!-- /@w -->. (See <a href="#Bash-Builtins">Bash Builtins</a>.) | |
17345e5a | 10801 | Command 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 | |
10804 | position, and <em>mark</em> refers to a cursor position saved by the | |
10805 | <code>set-mark</code> command. | |
10806 | The 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> | |
10812 | Next: <a href="#Commands-For-History" accesskey="n" rel="next">Commands For History</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> [<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 | 10845 | Words 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 | 10852 | Words 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 | 10859 | Words 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 | 10866 | Words 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 | |
10873 | physical screen line. This will not have the desired effect if the current | |
10874 | Readline line does not take up more than one physical line or if point is not | |
10875 | greater 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 | |
10882 | physical screen line. This will not have the desired effect if the current | |
10883 | Readline line does not take up more than one physical line or if the length | |
10884 | of the current Readline line is not greater than the length of the prompt | |
10885 | plus 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 | 10892 | leaving 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> | |
10907 | Next: <a href="#Commands-For-Text" accesskey="n" rel="next">Commands For Text</a>, Previous: <a href="#Commands-For-Moving" accesskey="p" rel="prev">Commands For Moving</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> [<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 |
10917 | If this line is |
10918 | non-empty, add it to the history list according to the setting of | |
a0c0a00f | 10919 | the <code>HISTCONTROL</code> and <code>HISTIGNORE</code> variables. |
17345e5a JA |
10920 | If this line is a modified history line, then restore the history line |
10921 | to 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 ‘back’ 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 ‘forward’ through the history list, fetching the next command. | |
10934 | </p> | |
10935 | </dd> | |
10936 | <dt><code>beginning-of-history (M-<)</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->)</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 | 10946 | being 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 ‘up’ through | |
10953 | the 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 ‘down’ through | |
17345e5a | 10960 | the 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 ‘up’ | |
17345e5a JA |
10967 | through the history as necessary using a non-incremental search |
10968 | for a string supplied by the user. | |
a0c0a00f CR |
10969 | The 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 ‘down’ | |
10976 | through the history as necessary using a non-incremental search | |
17345e5a | 10977 | for a string supplied by the user. |
a0c0a00f CR |
10978 | The 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 | 10985 | between the start of the current line and the point. |
ac50fbac | 10986 | The search string must match at the beginning of a history line. |
17345e5a JA |
10987 | This is a non-incremental search. |
10988 | By 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 |
10995 | between the start of the current line and the point. |
10996 | The search string must match at the beginning of a history line. | |
10997 | This is a non-incremental search. | |
10998 | By 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 |
11005 | between the start of the current line and the point. |
11006 | The search string may match anywhere in a history line. | |
11007 | This is a non-incremental search. | |
11008 | By 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 |
11015 | between the start of the current line and the point. |
11016 | The search string may match anywhere in a history line. | |
11017 | This is a non-incremental search. | |
11018 | By 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 | 11025 | the second word on the previous line) at point. |
a0c0a00f CR |
11026 | With an argument <var>n</var>, |
11027 | insert the <var>n</var>th word from the previous command (the words | |
17345e5a | 11028 | in the previous command begin with word 0). A negative argument |
a0c0a00f CR |
11029 | inserts the <var>n</var>th word from the end of the previous command. |
11030 | Once the argument <var>n</var> is computed, the argument is extracted | |
11031 | as if the ‘<samp>!<var>n</var></samp>’ 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 | 11038 | previous history entry). |
a0c0a00f CR |
11039 | With a numeric argument, behave exactly like <code>yank-nth-arg</code>. |
11040 | Successive calls to <code>yank-last-arg</code> move back through the history | |
495aee44 CR |
11041 | list, inserting the last word (or the word specified by the argument to |
11042 | the first call) of each line in turn. | |
11043 | Any numeric argument supplied to these successive calls determines | |
11044 | the direction to move through the history. A negative argument switches | |
11045 | the direction through the history (back or forward). | |
17345e5a | 11046 | The history expansion facilities are used to extract the last argument, |
a0c0a00f CR |
11047 | as if the ‘<samp>!$</samp>’ 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> | |
11056 | Next: <a href="#Commands-For-Killing" accesskey="n" rel="next">Commands For Killing</a>, Previous: <a href="#Commands-For-History" accesskey="p" rel="prev">Commands For History</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> [<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 | 11067 | on the line, and point is at the beginning of the line, Readline |
a0c0a00f CR |
11068 | interprets 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 | |
11075 | same character as the tty <small>EOF</small> character, as <kbd>C-d</kbd> | |
ac50fbac | 11076 | commonly 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 | 11083 | to 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 |
11090 | end of the line, in which case the character behind the cursor is |
11091 | deleted. 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 | |
11098 | how 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, !, …)</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 "bracketed paste" escape | |
11112 | sequence sent by some terminals, and such a binding is assigned by default. | |
11113 | It allows Readline to insert the pasted text as a single unit without treating | |
11114 | each character as if it had been read from the keyboard. The characters | |
2f5dfe5a | 11115 | are inserted as if each one was bound to <code>self-insert</code> instead of |
a0c0a00f CR |
11116 | executing 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 |
11123 | the character at the cursor, moving the |
11124 | cursor forward as well. If the insertion point | |
11125 | is at the end of the line, then this | |
11126 | transposes the last two characters of the line. | |
11127 | Negative 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 |
11134 | moving point past that word as well. |
11135 | If the insertion point is at the end of the line, this transposes | |
11136 | the 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 | 11143 | uppercase 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 | 11150 | lowercase 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 | 11157 | capitalize 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 |
11164 | switches to overwrite mode. With an explicit non-positive numeric |
11165 | argument, switches to insert mode. This command affects only | |
a0c0a00f CR |
11166 | <code>emacs</code> mode; <code>vi</code> mode does overwrite differently. |
11167 | Each 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 | 11170 | the text at point rather than pushing the text to the right. |
a0c0a00f | 11171 | Characters bound to <code>backward-delete-char</code> replace the character |
17345e5a | 11172 | before 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> | |
11183 | Next: <a href="#Numeric-Arguments" accesskey="n" rel="next">Numeric Arguments</a>, Previous: <a href="#Commands-For-Text" accesskey="p" rel="prev">Commands For Text</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> [<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 | 11211 | By 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 | 11218 | words, to the end of the next word. |
a0c0a00f CR |
11219 | Word 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. | |
11226 | Word 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 | 11233 | words, to the end of the next word. |
a0c0a00f CR |
11234 | Word 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. | |
11241 | Word 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 | 11248 | The 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 |
11255 | as the word boundaries. |
11256 | The 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 | 11269 | By 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 | 11276 | right 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. | |
11283 | The word boundaries are the same as <code>backward-word</code>. | |
17345e5a | 11284 | By 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. | |
11291 | The word boundaries are the same as <code>forward-word</code>. | |
17345e5a | 11292 | By 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 | |
11305 | the 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> | |
11313 | Next: <a href="#Commands-For-Completion" accesskey="n" rel="next">Commands For Completion</a>, Previous: <a href="#Commands-For-Killing" accesskey="p" rel="prev">Commands For Killing</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> [<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>, … <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 | |
11322 | argument. <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 |
11329 | If this command is followed by one or more digits, optionally with a |
11330 | leading minus sign, those digits define the argument. | |
a0c0a00f | 11331 | If the command is followed by digits, executing <code>universal-argument</code> |
17345e5a JA |
11332 | again ends the numeric argument, but is otherwise ignored. |
11333 | As a special case, if this command is immediately followed by a | |
a0c0a00f | 11334 | character that is neither a digit nor minus sign, the argument count |
17345e5a JA |
11335 | for the next command is multiplied by four. |
11336 | The argument count is initially one, so executing this function the | |
11337 | first time makes the argument count four, a second time makes the | |
11338 | argument count sixteen, and so on. | |
11339 | By 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> | |
11347 | Next: <a href="#Keyboard-Macros" accesskey="n" rel="next">Keyboard Macros</a>, Previous: <a href="#Numeric-Arguments" accesskey="p" rel="prev">Numeric Arguments</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> [<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 |
11357 | The actual completion performed is application-specific. |
11358 | Bash attempts completion treating the text as a variable (if the | |
a0c0a00f CR |
11359 | text begins with ‘<samp>$</samp>’), username (if the text begins with |
11360 | ‘<samp>~</samp>’), hostname (if the text begins with ‘<samp>@</samp>’), or | |
17345e5a JA |
11361 | command (including aliases and functions) in turn. If none |
11362 | of 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 | 11369 | When displaying completions, Readline sets the number of columns used |
a0c0a00f CR |
11370 | for display to the value of <code>completion-display-width</code>, the value of |
11371 | the 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 | |
11378 | been 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 | 11385 | with a single match from the list of possible completions. |
a0c0a00f | 11386 | Repeated execution of <code>menu-complete</code> steps through the list |
17345e5a JA |
11387 | of possible completions, inserting each match in turn. |
11388 | At the end of the list of completions, the bell is rung | |
a0c0a00f | 11389 | (subject to the setting of <code>bell-style</code>) |
17345e5a | 11390 | and the original text is restored. |
a0c0a00f | 11391 | An argument of <var>n</var> moves <var>n</var> positions forward in the list |
17345e5a JA |
11392 | of matches; a negative argument may be used to move backward |
11393 | through the list. | |
a0c0a00f | 11394 | This command is intended to be bound to <tt class="key">TAB</tt>, but is unbound |
17345e5a | 11395 | by 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 | |
11402 | of possible completions, as if <code>menu-complete</code> had been given a | |
0001803f | 11403 | negative 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 | |
11410 | end of the line (like <code>delete-char</code>). | |
17345e5a | 11411 | If at the end of the line, behaves identically to |
a0c0a00f | 11412 | <code>possible-completions</code>. |
17345e5a | 11413 | This 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 | 11426 | treating 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 | 11433 | it 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 | 11440 | treating 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 | 11447 | it 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 | 11454 | treating 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 | 11461 | it 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 | 11468 | treating 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 |
11475 | it as a command name. Command completion attempts to |
11476 | match the text against aliases, reserved words, shell | |
11477 | functions, shell builtins, and finally executable filenames, | |
11478 | in 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 | 11485 | treating 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 |
11492 | the text against lines from the history list for possible |
11493 | completion 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 |
11500 | the text against lines from the history list for possible |
11501 | completion 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 | 11508 | enclosed 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> | |
11518 | Next: <a href="#Miscellaneous-Commands" accesskey="n" rel="next">Miscellaneous Commands</a>, Previous: <a href="#Commands-For-Completion" accesskey="p" rel="prev">Commands For Completion</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> [<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 | 11533 | and 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 | 11540 | in 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> | |
11556 | Previous: <a href="#Keyboard-Macros" accesskey="p" rel="prev">Keyboard Macros</a>, Up: <a href="#Bindable-Readline-Commands" accesskey="u" rel="up">Bindable Readline Commands</a> [<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 | 11565 | any 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 | |
11572 | ring the terminal’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>, …)</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 |
11580 | that is bound to the corresponding metafied lower case character. | |
11581 | The 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 | |
11588 | without a meta key. Typing ‘<samp><span class="key">ESC</span> f</samp>’ 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 | 11602 | command enough times to get back to the beginning. |
a0c0a00f CR |
11603 | </p> |
11604 | </dd> | |
11605 | <dt><code>tilde-expand (M-&)</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 | 11615 | numeric 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 | 11622 | the 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 | 11629 | character. 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 |
11636 | of that character. A negative count searches for subsequent |
11637 | occurrences. | |
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 |
11644 | defined for keys like Home and End. Such sequences begin with a |
11645 | Control Sequence Indicator (CSI), usually ESC-[. If this sequence is | |
a0c0a00f | 11646 | bound to "\e[", keys producing such sequences will have no effect |
0001803f CR |
11647 | unless explicitly bound to a readline command, instead of inserting |
11648 | stray characters into the editing buffer. This is unbound by default, | |
11649 | but 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 |
11656 | variable is inserted at the beginning of the current line. |
11657 | If a numeric argument is supplied, this command acts as a toggle: if | |
11658 | the characters at the beginning of the line do not match the value | |
a0c0a00f CR |
11659 | of <code>comment-begin</code>, the value is inserted, otherwise |
11660 | the characters in <code>comment-begin</code> are deleted from the beginning of | |
17345e5a JA |
11661 | the line. |
11662 | In either case, the line is accepted as if a newline had been typed. | |
a0c0a00f | 11663 | The default value of <code>comment-begin</code> causes this command |
17345e5a JA |
11664 | to make the current line a shell comment. |
11665 | If a numeric argument causes the comment character to be removed, the line | |
11666 | will 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 |
11673 | Readline output stream. If a numeric argument is supplied, |
11674 | the output is formatted in such a way that it can be made part | |
a0c0a00f CR |
11675 | of 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 |
11682 | Readline output stream. If a numeric argument is supplied, |
11683 | the output is formatted in such a way that it can be made part | |
a0c0a00f CR |
11684 | of 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 |
11691 | strings they output. If a numeric argument is supplied, |
11692 | the output is formatted in such a way that it can be made part | |
a0c0a00f CR |
11693 | of 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 |
11700 | with an asterisk implicitly appended. This pattern is used to |
11701 | generate 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 | 11708 | and the list of matching file names is inserted, replacing the word. |
a0c0a00f | 11709 | If a numeric argument is supplied, a ‘<samp>*</samp>’ is appended before |
17345e5a | 11710 | pathname 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. | |
11718 | If a numeric argument is supplied, a ‘<samp>*</samp>’ is appended before | |
17345e5a | 11719 | pathname 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 | 11732 | This performs alias and history expansion as well as all of the shell |
a0c0a00f CR |
11733 | word 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 |
11771 | relative to the current line from the history for editing. |
11772 | A numeric argument, if supplied, specifies the history entry to use instead | |
11773 | of 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 |
11780 | commands. |
11781 | Bash attempts to invoke | |
a0c0a00f | 11782 | <code>$VISUAL</code>, <code>$EDITOR</code>, and <code>emacs</code> |
17345e5a | 11783 | as 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> | |
11794 | Next: <a href="#Programmable-Completion" accesskey="n" rel="next">Programmable Completion</a>, Previous: <a href="#Bindable-Readline-Commands" accesskey="p" rel="prev">Bindable Readline Commands</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> [<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 | 11800 | editing functions, it does contain enough to allow simple editing |
a0c0a00f CR |
11801 | of the line. The Readline <code>vi</code> mode behaves as specified in |
11802 | the <small>POSIX</small> standard. | |
11803 | </p> | |
11804 | <p>In order to switch interactively between <code>emacs</code> and <code>vi</code> | |
11805 | editing modes, use the ‘<samp>set -o emacs</samp>’ and ‘<samp>set -o vi</samp>’ | |
11806 | commands (see <a href="#The-Set-Builtin">The Set Builtin</a>). | |
11807 | The 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 | ‘insertion’ mode, as if you had typed an ‘<samp>i</samp>’. Pressing <tt class="key">ESC</tt> | |
11811 | switches you into ‘command’ mode, where you can edit the text of the | |
11812 | line with the standard <code>vi</code> movement keys, move to previous | |
11813 | history lines with ‘<samp>k</samp>’ and subsequent lines with ‘<samp>j</samp>’, and | |
17345e5a | 11814 | so forth. |
a0c0a00f CR |
11815 | </p> |
11816 | <hr> | |
11817 | <a name="Programmable-Completion"></a> | |
11818 | <div class="header"> | |
11819 | <p> | |
11820 | Next: <a href="#Programmable-Completion-Builtins" accesskey="n" rel="next">Programmable Completion Builtins</a>, Previous: <a href="#Readline-vi-Mode" accesskey="p" rel="prev">Readline vi Mode</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> [<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 | |
11827 | which a completion specification (a <var>compspec</var>) has been defined | |
11828 | using the <code>complete</code> builtin (see <a href="#Programmable-Completion-Builtins">Programmable Completion Builtins</a>), | |
17345e5a | 11829 | the programmable completion facilities are invoked. |
a0c0a00f CR |
11830 | </p> |
11831 | <p>First, the command name is identified. | |
17345e5a JA |
11832 | If a compspec has been defined for that command, the |
11833 | compspec is used to generate the list of possible completions for the word. | |
0001803f CR |
11834 | If the command word is the empty string (completion attempted at the |
11835 | beginning of an empty line), any compspec defined with | |
a0c0a00f | 11836 | the <samp>-E</samp> option to <code>complete</code> is used. |
17345e5a JA |
11837 | If the command word is a full pathname, a compspec for the full |
11838 | pathname is searched for first. | |
11839 | If no compspec is found for the full pathname, an attempt is made to | |
11840 | find a compspec for the portion following the final slash. | |
0001803f | 11841 | If those searches do not result in a compspec, any compspec defined with |
a0c0a00f CR |
11842 | the <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 |
11845 | matching words. |
11846 | If a compspec is not found, the default Bash completion | |
a0c0a00f CR |
11847 | described 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 |
11850 | Only matches which are prefixed by the word being completed are |
11851 | returned. | |
a0c0a00f CR |
11852 | When the <samp>-f</samp> or <samp>-d</samp> option is used for filename or |
11853 | directory name completion, the shell variable <code>FIGNORE</code> is | |
17345e5a | 11854 | used to filter the matches. |
a0c0a00f CR |
11855 | See <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 | 11859 | The words generated by the pattern need not match the word being completed. |
a0c0a00f CR |
11860 | The <code>GLOBIGNORE</code> shell variable is not used to filter the matches, |
11861 | but 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 | 11864 | is considered. |
a0c0a00f | 11865 | The string is first split using the characters in the <code>IFS</code> |
17345e5a | 11866 | special variable as delimiters. |
9a51695b CR |
11867 | Shell quoting is honored within the string, in order to provide a |
11868 | mechanism for the words to contain shell metacharacters or characters | |
11869 | in the value of <code>IFS</code>. | |
17345e5a JA |
11870 | Each word is then expanded using |
11871 | brace expansion, tilde expansion, parameter and variable expansion, | |
11872 | command substitution, and arithmetic expansion, | |
a0c0a00f | 11873 | as described above (see <a href="#Shell-Expansions">Shell Expansions</a>). |
17345e5a | 11874 | The results are split using the rules described above |
a0c0a00f | 11875 | (see <a href="#Word-Splitting">Word Splitting</a>). |
17345e5a JA |
11876 | The results of the expansion are prefix-matched against the word being |
11877 | completed, 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 | |
11880 | specified with the <samp>-F</samp> and <samp>-C</samp> options is invoked. | |
11881 | When 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 | |
11883 | assigned values as described above (see <a href="#Bash-Variables">Bash Variables</a>). | |
11884 | If a shell function is being invoked, the <code>COMP_WORDS</code> and | |
11885 | <code>COMP_CWORD</code> variables are also set. | |
ac50fbac | 11886 | When the function or command is invoked, the first argument ($1) is the |
17345e5a | 11887 | name of the command whose arguments are being completed, the |
ac50fbac CR |
11888 | second 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 | |
11890 | line. | |
17345e5a JA |
11891 | No filtering of the generated completions against the word being completed |
11892 | is performed; the function or command has complete freedom in generating | |
11893 | the matches. | |
a0c0a00f CR |
11894 | </p> |
11895 | <p>Any function specified with <samp>-F</samp> is invoked first. | |
17345e5a | 11896 | The 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. | |
11899 | It must put the possible completions in the <code>COMPREPLY</code> array | |
ac50fbac | 11900 | variable, one per array element. |
a0c0a00f CR |
11901 | </p> |
11902 | <p>Next, any command specified with the <samp>-C</samp> option is invoked | |
17345e5a JA |
11903 | in an environment equivalent to command substitution. |
11904 | It should print a list of completions, one per line, to | |
11905 | the standard output. | |
11906 | Backslash 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 | |
11909 | specified with the <samp>-X</samp> option is applied to the list. | |
11910 | The filter is a pattern as used for pathname expansion; a ‘<samp>&</samp>’ | |
17345e5a | 11911 | in the pattern is replaced with the text of the word being completed. |
a0c0a00f | 11912 | A literal ‘<samp>&</samp>’ may be escaped with a backslash; the backslash |
17345e5a JA |
11913 | is removed before attempting a match. |
11914 | Any completion that matches the pattern will be removed from the list. | |
a0c0a00f | 11915 | A leading ‘<samp>!</samp>’ negates the pattern; in this case any completion |
17345e5a | 11916 | not matching the pattern will be removed. |
a0c0a00f CR |
11917 | If the <code>nocasematch</code> shell option |
11918 | (see the description of <code>shopt</code> in <a href="#The-Shopt-Builtin">The Shopt Builtin</a>) | |
11919 | is enabled, the match is performed without regard to the case | |
11920 | of alphabetic characters. | |
11921 | </p> | |
11922 | <p>Finally, any prefix and suffix specified with the <samp>-P</samp> and <samp>-S</samp> | |
17345e5a JA |
11923 | options are added to each member of the completion list, and the result is |
11924 | returned to the Readline completion code as the list of possible | |
11925 | completions. | |
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 | 11929 | compspec 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 |
11932 | the compspec was defined, directory name completion is attempted and any |
11933 | matches 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 |
11936 | the completion code as the full set of possible completions. |
11937 | The default Bash completions are not attempted, and the Readline default | |
11938 | of filename completion is disabled. | |
a0c0a00f | 11939 | If the <samp>-o bashdefault</samp> option was supplied to <code>complete</code> when |
17345e5a JA |
11940 | the compspec was defined, the default Bash completions are attempted |
11941 | if the compspec generates no matches. | |
a0c0a00f CR |
11942 | If the <samp>-o default</samp> option was supplied to <code>complete</code> when the |
11943 | compspec was defined, Readline’s default completion will be performed | |
17345e5a JA |
11944 | if the compspec (and, if attempted, the default Bash completions) |
11945 | generate no matches. | |
a0c0a00f CR |
11946 | </p> |
11947 | <p>When a compspec indicates that directory name completion is desired, | |
17345e5a JA |
11948 | the programmable completion functions force Readline to append a slash |
11949 | to completed names which are symbolic links to directories, subject to | |
a0c0a00f CR |
11950 | the value of the <var>mark-directories</var> Readline variable, regardless |
11951 | of 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 | 11954 | most useful when used in combination with a default completion specified |
a0c0a00f | 11955 | with <samp>-D</samp>. It’s possible for shell functions executed as completion |
0001803f CR |
11956 | handlers to indicate that completion should be retried by returning an |
11957 | exit status of 124. If a shell function returns 124, and changes | |
11958 | the compspec associated with the command on which completion is being | |
11959 | attempted (supplied as the first argument when the function is executed), | |
11960 | programmable completion restarts from the beginning, with an | |
495aee44 | 11961 | attempt to find a new compspec for that command. This allows a set of |
0001803f CR |
11962 | completions to be built dynamically as completion is attempted, rather than |
11963 | being 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 |
11966 | file corresponding to the name of the command, the following default |
11967 | completion function would load completions dynamically: | |
a0c0a00f CR |
11968 | </p> |
11969 | <div class="example"> | |
11970 | <pre class="example">_completion_loader() | |
0001803f | 11971 | { |
a0c0a00f | 11972 | . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124 |
0001803f | 11973 | } |
ac50fbac | 11974 | complete -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> | |
11981 | Next: <a href="#A-Programmable-Completion-Example" accesskey="n" rel="next">A Programmable Completion Example</a>, Previous: <a href="#Programmable-Completion" accesskey="p" rel="prev">Programmable Completion</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> [<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 |
11988 | facilities: one to specify how the arguments to a particular command are to |
11989 | be 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 | |
11999 | the <var>option</var>s, which may be any option accepted by the | |
12000 | <code>complete</code> | |
12001 | builtin with the exception of <samp>-p</samp> and <samp>-r</samp>, and write | |
17345e5a | 12002 | the matches to the standard output. |
a0c0a00f | 12003 | When using the <samp>-F</samp> or <samp>-C</samp> options, the various shell variables |
17345e5a JA |
12004 | set by the programmable completion facilities, while available, will not |
12005 | have useful values. | |
a0c0a00f CR |
12006 | </p> |
12007 | <p>The matches will be generated in the same way as if the programmable | |
17345e5a JA |
12008 | completion code had generated them directly from a completion specification |
12009 | with the same flags. | |
a0c0a00f | 12010 | If <var>word</var> is specified, only those completions matching <var>word</var> |
17345e5a | 12011 | will be displayed. |
a0c0a00f CR |
12012 | </p> |
12013 | <p>The return value is true unless an invalid option is supplied, or no | |
17345e5a | 12014 | matches 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> …]</code> |
2f5dfe5a | 12023 | <code>complete -pr [-DEI] [<var>name</var> …]</code> |
a0c0a00f CR |
12024 | </pre></div> |
12025 | ||
12026 | <p>Specify how arguments to each <var>name</var> should be completed. | |
12027 | If the <samp>-p</samp> option is supplied, or if no options are supplied, existing | |
17345e5a JA |
12028 | completion specifications are printed in a way that allows them to be |
12029 | reused as input. | |
a0c0a00f CR |
12030 | The <samp>-r</samp> option removes a completion specification for |
12031 | each <var>name</var>, or, if no <var>name</var>s are supplied, all | |
17345e5a | 12032 | completion specifications. |
2f5dfe5a | 12033 | The <samp>-D</samp> option indicates that other supplied options and actions should |
a0c0a00f | 12034 | apply to the “default” command completion; that is, completion attempted |
0001803f | 12035 | on a command for which no completion has previously been defined. |
2f5dfe5a | 12036 | The <samp>-E</samp> option indicates that other supplied options and actions should |
a0c0a00f | 12037 | apply to “empty” command completion; that is, completion attempted on a |
17345e5a | 12038 | blank line. |
2f5dfe5a CR |
12039 | The <samp>-I</samp> option indicates that other supplied options and actions should |
12040 | apply to completion on the inital non-assignment word on the line, or after a | |
12041 | command delimiter such as ‘<samp>;</samp>’ or ‘<samp>|</samp>’, which is usually command | |
12042 | name completion. | |
12043 | If multiple options are supplied, the <samp>-D</samp> option takes precedence | |
12044 | over <samp>-E</samp>, and both take precedence over <samp>-I</samp>. | |
12045 | If 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 | |
12047 | specified by the option. | |
a0c0a00f CR |
12048 | </p> |
12049 | <p>The process of applying these completion specifications when word completion | |
2f5dfe5a | 12050 | is 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. | |
12053 | The 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 | 12055 | should 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’s behavior | |
17345e5a | 12062 | beyond 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 | 12068 | generates no matches. |
a0c0a00f CR |
12069 | </p> |
12070 | </dd> | |
12071 | <dt><code>default</code></dt> | |
12072 | <dd><p>Use Readline’s default filename completion if the compspec generates | |
17345e5a | 12073 | no 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 | 12082 | filename-specific processing (like adding a slash to directory names, |
17345e5a JA |
12083 | quoting special characters, or suppressing trailing spaces). |
12084 | This option is intended to be used with shell functions specified | |
a0c0a00f CR |
12085 | with <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 | 12099 | the 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 |
12104 | directory name completion is attempted and any |
12105 | matches 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 | 12113 | completions: |
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 | 12219 | used 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 | 12224 | environment. |
ac50fbac CR |
12225 | When it is executed, $1 is the name of the command whose arguments are |
12226 | being completed, $2 is the word being completed, and $3 is the word | |
12227 | preceding the word being completed, as described above | |
a0c0a00f | 12228 | (see <a href="#Programmable-Completion">Programmable Completion</a>). |
495aee44 | 12229 | When it finishes, the possible completions are retrieved from the value |
a0c0a00f CR |
12230 | of 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 | 12235 | the 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 | 12240 | after 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 | 12245 | after 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 |
12251 | is expanded. |
12252 | The possible completions are the members of the resultant list which | |
12253 | match 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 |
12258 | It is applied to the list of possible completions generated by the |
12259 | preceding options and arguments, and each completion matching | |
a0c0a00f CR |
12260 | <var>filterpat</var> is removed from the list. |
12261 | A leading ‘<samp>!</samp>’ in <var>filterpat</var> negates the pattern; in this | |
12262 | case, 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 | |
12267 | other than <samp>-p</samp> or <samp>-r</samp> is supplied without a <var>name</var> | |
17345e5a | 12268 | argument, an attempt is made to remove a completion specification for |
a0c0a00f | 12269 | a <var>name</var> for which no specification exists, or |
17345e5a | 12270 | an 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 | 12280 | are supplied. |
a0c0a00f CR |
12281 | If no <var>option</var>s are given, display the completion options for each |
12282 | <var>name</var> or the current completion. | |
12283 | The possible values of <var>option</var> are those valid for the <code>complete</code> | |
17345e5a | 12284 | builtin described above. |
2f5dfe5a | 12285 | The <samp>-D</samp> option indicates that other supplied options should |
a0c0a00f | 12286 | apply to the “default” command completion; that is, completion attempted |
0001803f | 12287 | on a command for which no completion has previously been defined. |
2f5dfe5a | 12288 | The <samp>-E</samp> option indicates that other supplied options should |
a0c0a00f | 12289 | apply to “empty” command completion; that is, completion attempted on a |
0001803f | 12290 | blank line. |
2f5dfe5a CR |
12291 | The <samp>-I</samp> option indicates that other supplied options should |
12292 | apply to completion on the inital non-assignment word on the line, or after a | |
12293 | command delimiter such as ‘<samp>;</samp>’ or ‘<samp>|</samp>’, which is usually command | |
12294 | name completion. | |
a0c0a00f | 12295 | </p> |
2f5dfe5a CR |
12296 | <p>If multiple options are supplied, the <samp>-D</samp> option takes precedence |
12297 | over <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 | |
12300 | is made to modify the options for a <var>name</var> for which no completion | |
ac50fbac | 12301 | specification 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> | |
12310 | Previous: <a href="#Programmable-Completion-Builtins" accesskey="p" rel="prev">Programmable Completion Builtins</a>, Up: <a href="#Command-Line-Editing" accesskey="u" rel="up">Command Line Editing</a> [<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 | |
12316 | the default actions <code>complete</code> and <code>compgen</code> provide is to use | |
12317 | a 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 | 12320 | It is a reasonably good example of what shell functions must do when |
9a51695b | 12321 | used for completion. This function uses the word passed as <code>$2</code> |
ac50fbac | 12322 | to 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 | |
12327 | to do much of the work, adding only the things that the Bash <code>cd</code> | |
ac50fbac | 12328 | does beyond accepting basic directory names: |
a0c0a00f CR |
12329 | tilde expansion (see <a href="#Tilde-Expansion">Tilde Expansion</a>), |
12330 | searching directories in <var>$CDPATH</var>, which is described above | |
12331 | (see <a href="#Bourne-Shell-Builtins">Bourne Shell Builtins</a>), | |
12332 | and 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 | |
12335 | a newline to accommodate file names containing spaces and tabs – | |
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 |
12339 | completion per array element. The programmable completion system retrieves |
12340 | the 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 "$2" in |
12353 | \~*) eval cur="$2" ;; | |
ac50fbac CR |
12354 | *) cur=$2 ;; |
12355 | esac | |
12356 | ||
12357 | # no cdpath or absolute pathname -- straight directory completion | |
a0c0a00f | 12358 | if [[ -z "${CDPATH:-}" ]] || [[ "$cur" == @(./*|../*|/*) ]]; then |
ac50fbac CR |
12359 | # compgen prints paths one per line; could also use while loop |
12360 | IFS=$'\n' | |
a0c0a00f | 12361 | COMPREPLY=( $(compgen -d -- "$cur") ) |
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="${#COMPREPLY[@]}" |
12374 | for j in $( compgen -d -- "$i/$cur" ); do | |
ac50fbac CR |
12375 | COMPREPLY[k++]=${j#$i/} # cut off directory |
12376 | done | |
12377 | done | |
a0c0a00f | 12378 | $_skipdot || COMPREPLY+=( $(compgen -d -- "$cur") ) |
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 && [[ ${#COMPREPLY[@]} -eq 0 ]]; then |
12384 | COMPREPLY=( $(compgen -v -- "$cur") ) | |
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 |
12397 | complete -o filenames -o nospace -o bashdefault -F _comp_cd cd | |
a0c0a00f | 12398 | </pre></div> |
ac50fbac | 12399 | |
a0c0a00f | 12400 | <p>Since we’d like Bash and Readline to take care of some |
ac50fbac | 12401 | of the other details for us, we use several other options to tell Bash |
a0c0a00f | 12402 | and Readline what to do. The <samp>-o filenames</samp> option tells Readline |
ac50fbac CR |
12403 | that the possible completions should be treated as filenames, and quoted |
12404 | appropriately. That option will also cause Readline to append a slash to | |
12405 | filenames it can determine are directories (which is why we might want to | |
a0c0a00f CR |
12406 | extend <code>_comp_cd</code> to append a slash if we’re using directories found |
12407 | via <var>CDPATH</var>: Readline can’t tell those completions are directories). | |
12408 | The <samp>-o nospace</samp> option tells Readline to not append a space | |
ac50fbac | 12409 | character to the directory name, in case we want to append to it. |
a0c0a00f CR |
12410 | The <samp>-o bashdefault</samp> option brings in the rest of the "Bash default" |
12411 | completions – possible completion that Bash adds to the default Readline | |
ac50fbac | 12412 | set. These include things like command name completion, variable completion |
a0c0a00f CR |
12413 | for words beginning with ‘<samp>{</samp>’, completions containing pathname |
12414 | expansion 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 | |
12417 | time we attempt word completion for a <code>cd</code> command. | |
12418 | </p> | |
12419 | <p>Many more examples – an extensive collection of completions for most of | |
12420 | the common GNU, Unix, and Linux commands – are available as part of the | |
ac50fbac CR |
12421 | bash_completion project. This is installed by default on many GNU/Linux |
12422 | distributions. Originally written by Ian Macdonald, the project now lives | |
a0c0a00f | 12423 | at <a href="http://bash-completion.alioth.debian.org/">http://bash-completion.alioth.debian.org/</a>. There are ports for |
ac50fbac | 12424 | other 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 | |
12427 | in 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> | |
12435 | Next: <a href="#Installing-Bash" accesskey="n" rel="next">Installing Bash</a>, Previous: <a href="#Command-Line-Editing" accesskey="p" rel="prev">Command Line Editing</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<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 | |
12442 | interactively, from a user’s standpoint. | |
12443 | It should be considered a user’s guide. | |
12444 | For information on using the <small>GNU</small> History Library in other programs, | |
12445 | see the <small>GNU</small> Readline Library Manual. | |
12446 | </p> | |
12447 | <table class="menu" border="0" cellspacing="0"> | |
12448 | <tr><td align="left" valign="top">• <a href="#Bash-History-Facilities" accesskey="1">Bash History Facilities</a>:</td><td> </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">• <a href="#Bash-History-Builtins" accesskey="2">Bash History Builtins</a>:</td><td> </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">• <a href="#History-Interaction" accesskey="3">History Interaction</a>:</td><td> </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> | |
12462 | Next: <a href="#Bash-History-Builtins" accesskey="n" rel="next">Bash History Builtins</a>, Up: <a href="#Using-History-Interactively" accesskey="u" rel="up">Using History Interactively</a> [<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 | |
12470 | is enabled (see <a href="#The-Set-Builtin">The Set Builtin</a>), | |
12471 | the shell provides access to the <em>command history</em>, | |
17345e5a | 12472 | the list of commands previously typed. |
a0c0a00f | 12473 | The value of the <code>HISTSIZE</code> shell variable is used as the |
17345e5a | 12474 | number of commands to save in a history list. |
a0c0a00f | 12475 | The text of the last <code>$HISTSIZE</code> |
17345e5a JA |
12476 | commands (default 500) is saved. |
12477 | The shell stores each command in the history list prior to | |
12478 | parameter and variable expansion | |
12479 | but after history expansion is performed, subject to the | |
12480 | values 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 | |
12484 | file named by the <code>HISTFILE</code> variable (default <samp>~/.bash_history</samp>). | |
12485 | The file named by the value of <code>HISTFILE</code> is truncated, if | |
17345e5a | 12486 | necessary, to contain no more than the number of lines specified by |
a0c0a00f | 12487 | the value of the <code>HISTFILESIZE</code> variable. |
ac50fbac | 12488 | When a shell with history enabled exits, the last |
a0c0a00f CR |
12489 | <code>$HISTSIZE</code> lines are copied from the history list to the file |
12490 | named by <code>$HISTFILE</code>. | |
12491 | If the <code>histappend</code> shell option is set (see <a href="#Bash-Builtins">Bash Builtins</a>), | |
17345e5a JA |
12492 | the lines are appended to the history file, |
12493 | otherwise the history file is overwritten. | |
a0c0a00f | 12494 | If <code>HISTFILE</code> |
ac50fbac CR |
12495 | is unset, or if the history file is unwritable, the history is not saved. |
12496 | After saving the history, the history file is truncated | |
a0c0a00f CR |
12497 | to contain no more than <code>$HISTFILESIZE</code> lines. |
12498 | If <code>HISTFILESIZE</code> is unset, or set to null, a non-numeric value, or | |
ac50fbac | 12499 | a 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 |
12502 | associated with each history entry is written to the history file, |
12503 | marked with the history comment character. | |
12504 | When the history file is read, lines beginning with the history | |
12505 | comment character followed immediately by a digit are interpreted | |
a0c0a00f CR |
12506 | as 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 | 12509 | a portion of the history list. |
a0c0a00f | 12510 | The <code>history</code> builtin may be used to display or modify the history |
17345e5a JA |
12511 | list and manipulate the history file. |
12512 | When using command-line editing, search commands | |
12513 | are available in each editing mode that provide access to the | |
a0c0a00f CR |
12514 | history 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 | |
12517 | list. The <code>HISTCONTROL</code> and <code>HISTIGNORE</code> | |
17345e5a JA |
12518 | variables may be set to cause the shell to save only a subset of the |
12519 | commands entered. | |
a0c0a00f | 12520 | The <code>cmdhist</code> |
17345e5a JA |
12521 | shell option, if enabled, causes the shell to attempt to save each |
12522 | line of a multi-line command in the same history entry, adding | |
12523 | semicolons where necessary to preserve syntactic correctness. | |
a0c0a00f | 12524 | The <code>lithist</code> |
17345e5a JA |
12525 | shell option causes the shell to save the command with embedded newlines |
12526 | instead of semicolons. | |
a0c0a00f | 12527 | The <code>shopt</code> builtin is used to set these options. |
9a51695b | 12528 | See <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> | |
12534 | Next: <a href="#History-Interaction" accesskey="n" rel="next">History Interaction</a>, Previous: <a href="#Bash-History-Facilities" accesskey="p" rel="prev">Bash History Facilities</a>, Up: <a href="#Using-History-Interactively" accesskey="u" rel="up">Using History Interactively</a> [<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 | 12541 | history 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 | 12553 | them. |
a0c0a00f CR |
12554 | Both <var>first</var> and |
12555 | <var>last</var> may be specified as a string (to locate the most recent | |
17345e5a JA |
12556 | command beginning with that string) or as a number (an index into the |
12557 | history list, where a negative number is used as an offset from the | |
9a51695b CR |
12558 | current 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 |
12560 | command for editing and -16 for listing. If the <samp>-l</samp> flag is |
12561 | given, the commands are listed on standard output. The <samp>-n</samp> flag | |
12562 | suppresses the command numbers when listing. The <samp>-r</samp> flag | |
17345e5a | 12563 | reverses 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 | |
12566 | is used: <code>${FCEDIT:-${EDITOR:-vi}}</code>. This says to use the | |
12567 | value 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 | 12569 | When 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 | |
12572 | of <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 | |
12576 | that typing ‘<samp>r cc</samp>’ runs the last command beginning with <code>cc</code> | |
12577 | and typing ‘<samp>r</samp>’ 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 | 12584 | history -c |
a0c0a00f | 12585 | history -d <var>offset</var> |
9a51695b | 12586 | history -d <var>start</var>-<var>end</var> |
a0c0a00f CR |
12587 | history [-anrw] [<var>filename</var>] |
12588 | history -ps <var>arg</var> | |
12589 | </pre></div> | |
12590 | ||
12591 | <p>With no options, display the history list with line numbers. | |
12592 | Lines prefixed with a ‘<samp>*</samp>’ have been modified. | |
12593 | An argument of <var>n</var> lists only the last <var>n</var> lines. | |
12594 | If the shell variable <code>HISTTIMEFORMAT</code> is set and not null, | |
12595 | it is used as a format string for <var>strftime</var> to display | |
17345e5a JA |
12596 | the time stamp associated with each displayed history entry. |
12597 | No intervening blank is printed between the formatted time stamp | |
12598 | and 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 | 12605 | with 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 |
12610 | If <var>offset</var> is positive, it should be specified as it appears when |
12611 | the history is displayed. | |
12612 | If <var>offset</var> is negative, it is interpreted as relative to one greater | |
12613 | than the last history position, so negative indices count back from the | |
12614 | end of the history, and an index of ‘<samp>-1</samp>’ 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>, | |
12620 | inclusive. Positive and negative values for <var>start</var> and <var>end</var> | |
12621 | are 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. | |
12626 | These are history lines entered since the beginning of the current | |
12627 | Bash 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 |
12632 | to the current history list. These are lines appended to the history |
12633 | file 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 | 12638 | the 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 | 12647 | on 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 | 12652 | the 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 |
12658 | used, if <var>filename</var> | |
17345e5a | 12659 | is given, then it is used as the history file. If not, then |
a0c0a00f CR |
12660 | the 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> | |
12669 | Previous: <a href="#Bash-History-Builtins" accesskey="p" rel="prev">Bash History Builtins</a>, Up: <a href="#Using-History-Interactively" accesskey="u" rel="up">Using History Interactively</a> [<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 | |
12676 | to the history expansion provided by <code>csh</code>. This section | |
17345e5a | 12677 | describes 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 |
12680 | the input stream, making it easy to repeat commands, insert the |
12681 | arguments to a previous command into the current input line, or | |
12682 | fix errors in previous commands quickly. | |
a0c0a00f CR |
12683 | </p> |
12684 | <p>History expansion is performed immediately after a complete line | |
9a51695b | 12685 | is read, before the shell breaks it into words, and is performed |
2f5dfe5a CR |
12686 | on each line individually. Bash attempts to inform the history |
12687 | expansion 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 |
12690 | which line from the history list should be used during substitution. |
12691 | The second is to select portions of that line for inclusion into the | |
12692 | current 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 |
12694 | called <em>words</em>. Various <em>modifiers</em> are available to manipulate | |
17345e5a JA |
12695 | the selected words. The line is broken into words in the same fashion |
12696 | that Bash does, so that several words | |
12697 | surrounded by quotes are considered one word. | |
12698 | History expansions are introduced by the appearance of the | |
a0c0a00f | 12699 | history expansion character, which is ‘<samp>!</samp>’ by default. |
2f5dfe5a CR |
12700 | </p> |
12701 | <p>History expansion implements shell-like quoting conventions: | |
12702 | a backslash can be used to remove the special handling for the next character; | |
12703 | single quotes enclose verbatim sequences of characters, and can be used to | |
12704 | inhibit history expansion; | |
12705 | and characters enclosed within double quotes may be subject to history | |
12706 | expansion, since backslash can escape the history expansion character, | |
12707 | but single quotes may not, since they are not treated specially within | |
12708 | double quotes. | |
12709 | </p> | |
12710 | <p>When using the shell, only ‘<samp>\</samp>’ and ‘<samp>'</samp>’ may be used to escape the | |
12711 | history expansion character, but the history expansion character is | |
a0c0a00f CR |
12712 | also treated as quoted if it immediately precedes the closing double quote |
12713 | in a double-quoted string. | |
12714 | </p> | |
12715 | <p>Several shell options settable with the <code>shopt</code> | |
9a51695b | 12716 | builtin (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>) may be used to tailor |
17345e5a | 12717 | the behavior of history expansion. If the |
a0c0a00f | 12718 | <code>histverify</code> shell option is enabled, and Readline |
17345e5a JA |
12719 | is being used, history substitutions are not immediately passed to |
12720 | the shell parser. | |
12721 | Instead, the expanded line is reloaded into the Readline | |
12722 | editing buffer for further modification. | |
a0c0a00f | 12723 | If Readline is being used, and the <code>histreedit</code> |
17345e5a JA |
12724 | shell option is enabled, a failed history expansion will be |
12725 | reloaded into the Readline editing buffer for correction. | |
a0c0a00f | 12726 | The <samp>-p</samp> option to the <code>history</code> builtin command |
17345e5a | 12727 | may be used to see what a history expansion will do before using it. |
a0c0a00f | 12728 | The <samp>-s</samp> option to the <code>history</code> builtin may be used to |
17345e5a JA |
12729 | add commands to the end of the history list without actually executing |
12730 | them, so that they are available for subsequent recall. | |
12731 | This is most useful in conjunction with Readline. | |
a0c0a00f CR |
12732 | </p> |
12733 | <p>The shell allows control of the various characters used by the | |
12734 | history expansion mechanism with the <code>histchars</code> variable, | |
12735 | as explained above (see <a href="#Bash-Variables">Bash Variables</a>). The shell uses | |
17345e5a JA |
12736 | the history comment character to mark history timestamps when |
12737 | writing the history file. | |
a0c0a00f CR |
12738 | </p> |
12739 | <table class="menu" border="0" cellspacing="0"> | |
12740 | <tr><td align="left" valign="top">• <a href="#Event-Designators" accesskey="1">Event Designators</a>:</td><td> </td><td align="left" valign="top">How to specify which history line to use. | |
12741 | </td></tr> | |
12742 | <tr><td align="left" valign="top">• <a href="#Word-Designators" accesskey="2">Word Designators</a>:</td><td> </td><td align="left" valign="top">Specifying which words are of interest. | |
12743 | </td></tr> | |
12744 | <tr><td align="left" valign="top">• <a href="#Modifiers" accesskey="3">Modifiers</a>:</td><td> </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> | |
12752 | Next: <a href="#Word-Designators" accesskey="n" rel="next">Word Designators</a>, Up: <a href="#History-Interaction" accesskey="u" rel="up">History Interaction</a> [<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 | 12759 | history list. |
495aee44 CR |
12760 | Unless the reference is absolute, events are relative to the current |
12761 | position 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, | |
12767 | the end of the line, ‘<samp>=</samp>’ or ‘<samp>(</samp>’ (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 ‘<samp>!-1</samp>’. | |
12781 | </p> | |
12782 | </dd> | |
12783 | <dt><code>!<var>string</var></code></dt> | |
12784 | <dd><p>Refer to the most recent command | |
495aee44 | 12785 | preceding the current position in the history list |
a0c0a00f CR |
12786 | starting 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 | 12791 | preceding the current position in the history list |
a0c0a00f | 12792 | containing <var>string</var>. |
495aee44 | 12793 | The trailing |
a0c0a00f | 12794 | ‘<samp>?</samp>’ may be omitted if the <var>string</var> is followed immediately by |
17345e5a | 12795 | a 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> | |
12800 | with <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> | |
12814 | Next: <a href="#Modifiers" accesskey="n" rel="next">Modifiers</a>, Previous: <a href="#Event-Designators" accesskey="p" rel="prev">Event Designators</a>, Up: <a href="#History-Interaction" accesskey="u" rel="up">History Interaction</a> [<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. | |
12820 | A ‘<samp>:</samp>’ separates the event specification from the word designator. It | |
12821 | may be omitted if the word designator begins with a ‘<samp>^</samp>’, ‘<samp>$</samp>’, | |
12822 | ‘<samp>*</samp>’, ‘<samp>-</samp>’, or ‘<samp>%</samp>’. Words are numbered from the beginning | |
17345e5a JA |
12823 | of the line, with the first word being denoted by 0 (zero). Words are |
12824 | inserted 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 | 12831 | command 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 | |
12836 | shortened 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 | |
12841 | the 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 ‘<samp>?<var>string</var>?</samp>’ search. | |
12866 | </p> | |
12867 | </dd> | |
12868 | <dt><code><var>x</var>-<var>y</var></code></dt> | |
12869 | <dd><p>A range of words; ‘<samp>-<var>y</var></samp>’ abbreviates ‘<samp>0-<var>y</var></samp>’. | |
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 ‘<samp>1-$</samp>’. | |
12874 | It is not an error to use ‘<samp>*</samp>’ if there is just one word in the event; | |
17345e5a | 12875 | the 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 ‘<samp><var>x</var>-$</samp>’ | |
12880 | </p> | |
12881 | </dd> | |
12882 | <dt><code><var>x</var>-</code></dt> | |
12883 | <dd><p>Abbreviates ‘<samp><var>x</var>-$</samp>’ like ‘<samp><var>x</var>*</samp>’, 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 | 12889 | previous command is used as the event. |
a0c0a00f CR |
12890 | </p> |
12891 | <hr> | |
12892 | <a name="Modifiers"></a> | |
12893 | <div class="header"> | |
12894 | <p> | |
12895 | Previous: <a href="#Word-Designators" accesskey="p" rel="prev">Word Designators</a>, Up: <a href="#History-Interaction" accesskey="u" rel="up">History Interaction</a> [<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 | |
12901 | of the following modifiers, each preceded by a ‘<samp>:</samp>’. | |
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 ‘<samp>.<var>suffix</var></samp>’, leaving | |
17345e5a | 12914 | the 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 ‘<samp>q</samp>’, | |
17345e5a | 12931 | but 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 | |
12936 | event line. Any delimiter may be used in place of ‘<samp>/</samp>’. | |
12937 | The delimiter may be quoted in <var>old</var> and <var>new</var> | |
12938 | with a single backslash. If ‘<samp>&</samp>’ appears in <var>new</var>, | |
12939 | it is replaced by <var>old</var>. A single backslash will quote | |
12940 | the ‘<samp>&</samp>’. The final delimiter is optional if it is the last | |
17345e5a | 12941 | character on the input line. |
a0c0a00f CR |
12942 | </p> |
12943 | </dd> | |
12944 | <dt><code>&</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 | |
12951 | conjunction with ‘<samp>s</samp>’, as in <code>gs/<var>old</var>/<var>new</var>/</code>, | |
12952 | or with ‘<samp>&</samp>’. | |
12953 | </p> | |
12954 | </dd> | |
12955 | <dt><code>G</code></dt> | |
12956 | <dd><p>Apply the following ‘<samp>s</samp>’ 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> | |
12965 | Next: <a href="#Reporting-Bugs" accesskey="n" rel="next">Reporting Bugs</a>, Previous: <a href="#Using-History-Interactively" accesskey="p" rel="prev">Using History Interactively</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<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 | 12971 | the various supported platforms. The distribution supports the |
a0c0a00f | 12972 | <small>GNU</small> operating systems, nearly every version of Unix, and several |
17345e5a JA |
12973 | non-Unix systems such as BeOS and Interix. |
12974 | Other 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">• <a href="#Basic-Installation" accesskey="1">Basic Installation</a>:</td><td> </td><td align="left" valign="top">Installation instructions. | |
12979 | </td></tr> | |
12980 | <tr><td align="left" valign="top">• <a href="#Compilers-and-Options" accesskey="2">Compilers and Options</a>:</td><td> </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">• <a href="#Compiling-For-Multiple-Architectures" accesskey="3">Compiling For Multiple Architectures</a>:</td><td> </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">• <a href="#Installation-Names" accesskey="4">Installation Names</a>:</td><td> </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">• <a href="#Specifying-the-System-Type" accesskey="5">Specifying the System Type</a>:</td><td> </td><td align="left" valign="top">How to configure Bash for a particular system. | |
12990 | </td></tr> | |
12991 | <tr><td align="left" valign="top">• <a href="#Sharing-Defaults" accesskey="6">Sharing Defaults</a>:</td><td> </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">• <a href="#Operation-Controls" accesskey="7">Operation Controls</a>:</td><td> </td><td align="left" valign="top">Options recognized by the configuration program. | |
12995 | </td></tr> | |
12996 | <tr><td align="left" valign="top">• <a href="#Optional-Features" accesskey="8">Optional Features</a>:</td><td> </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> | |
13005 | Next: <a href="#Compilers-and-Options" accesskey="n" rel="next">Compilers and Options</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> [<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 | ‘<samp>./configure</samp>’ to configure Bash for your system. If you’re | |
13021 | using <code>csh</code> on an old version of System V, you might need to | |
13022 | type ‘<samp>sh ./configure</samp>’ instead to prevent <code>csh</code> from trying | |
13023 | to execute <code>configure</code> itself. | |
13024 | ||
13025 | <p>Running <code>configure</code> takes some time. | |
17345e5a JA |
13026 | While running, it prints messages telling which features it is |
13027 | checking for. | |
a0c0a00f CR |
13028 | </p> |
13029 | </li><li> Type ‘<samp>make</samp>’ to compile Bash and build the <code>bashbug</code> bug | |
17345e5a | 13030 | reporting script. |
17345e5a | 13031 | |
a0c0a00f | 13032 | </li><li> Optionally, type ‘<samp>make tests</samp>’ to run the Bash test suite. |
17345e5a | 13033 | |
a0c0a00f | 13034 | </li><li> Type ‘<samp>make install</samp>’ to install <code>bash</code> and <code>bashbug</code>. |
17345e5a | 13035 | This 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 | 13040 | values for various system-dependent variables used during |
a0c0a00f | 13041 | compilation. It uses those values to create a <samp>Makefile</samp> in |
17345e5a | 13042 | each directory of the package (the top directory, the |
a0c0a00f CR |
13043 | <samp>builtins</samp>, <samp>doc</samp>, and <samp>support</samp> directories, |
13044 | each directory under <samp>lib</samp>, and several others). It also creates a | |
13045 | <samp>config.h</samp> file containing system-dependent definitions. | |
13046 | Finally, it creates a shell script named <code>config.status</code> that you | |
17345e5a | 13047 | can run in the future to recreate the current configuration, a |
a0c0a00f CR |
13048 | file <samp>config.cache</samp> that saves the results of its tests to |
13049 | speed up reconfiguring, and a file <samp>config.log</samp> containing | |
13050 | compiler output (useful mainly for debugging <code>configure</code>). | |
17345e5a | 13051 | If at some point |
a0c0a00f | 13052 | <samp>config.cache</samp> contains results you don’t want to keep, you |
17345e5a | 13053 | may 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 |
13065 | directory – to build for multiple architectures, for example – | |
13066 | just use the full path to the configure script. The following commands | |
13067 | will build bash in a directory under <samp>/usr/local/build</samp> from | |
13068 | the 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 | |
13072 | cd /usr/local/build/bash-4.4 | |
13073 | bash /usr/local/src/bash-4.4/configure | |
13074 | make | |
13075 | </pre></div> | |
13076 | ||
13077 | <p>See <a href="#Compiling-For-Multiple-Architectures">Compiling For Multiple Architectures</a> for more information | |
13078 | about 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 |
13081 | try to figure out how <code>configure</code> could check whether or not | |
17345e5a | 13082 | to 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 | 13084 | considered for the next release. |
a0c0a00f CR |
13085 | </p> |
13086 | <p>The file <samp>configure.ac</samp> is used to create <code>configure</code> | |
17345e5a | 13087 | by 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 |
13090 | you do this, make sure you are using Autoconf version 2.50 or |
13091 | newer. | |
a0c0a00f CR |
13092 | </p> |
13093 | <p>You can remove the program binaries and object files from the | |
13094 | source code directory by typing ‘<samp>make clean</samp>’. To also remove the | |
13095 | files that <code>configure</code> created (so you can compile Bash for | |
13096 | a different kind of computer), type ‘<samp>make distclean</samp>’. | |
13097 | </p> | |
13098 | <hr> | |
13099 | <a name="Compilers-and-Options"></a> | |
13100 | <div class="header"> | |
13101 | <p> | |
13102 | Next: <a href="#Compiling-For-Multiple-Architectures" accesskey="n" rel="next">Compiling For Multiple Architectures</a>, Previous: <a href="#Basic-Installation" accesskey="p" rel="prev">Basic Installation</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> [<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 | |
13108 | that the <code>configure</code> script does not know about. You can | |
13109 | give <code>configure</code> initial values for variables by setting | |
17345e5a JA |
13110 | them in the environment. Using a Bourne-compatible shell, you |
13111 | can 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 | 13124 | is available. |
a0c0a00f CR |
13125 | </p> |
13126 | <hr> | |
13127 | <a name="Compiling-For-Multiple-Architectures"></a> | |
13128 | <div class="header"> | |
13129 | <p> | |
13130 | Next: <a href="#Installation-Names" accesskey="n" rel="next">Installation Names</a>, Previous: <a href="#Compilers-and-Options" accesskey="p" rel="prev">Compilers and Options</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> [<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 | 13136 | same time, by placing the object files for each architecture in their |
a0c0a00f CR |
13137 | own directory. To do this, you must use a version of <code>make</code> that |
13138 | supports the <code>VPATH</code> variable, such as GNU <code>make</code>. | |
13139 | <code>cd</code> to the | |
17345e5a | 13140 | directory where you want the object files and executables to go and run |
9a51695b CR |
13141 | the <code>configure</code> script from the source directory |
13142 | (see <a href="#Basic-Installation">Basic Installation</a>). | |
13143 | You may need to | |
a0c0a00f CR |
13144 | supply the <samp>--srcdir=PATH</samp> argument to tell <code>configure</code> where the |
13145 | source files are. <code>configure</code> automatically checks for the | |
13146 | source code in the directory that <code>configure</code> is in and in ‘..’. | |
13147 | </p> | |
13148 | <p>If you have to use a <code>make</code> that does not supports the <code>VPATH</code> | |
17345e5a JA |
13149 | variable, you can compile Bash for one architecture at a |
13150 | time in the source code directory. After you have installed | |
a0c0a00f | 13151 | Bash for one architecture, use ‘<samp>make distclean</samp>’ before |
17345e5a | 13152 | reconfiguring 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 | |
13156 | symbolic links back to each file in the source directory. Here’s an | |
17345e5a | 13157 | example that creates a build directory in the current directory from a |
a0c0a00f CR |
13158 | source 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 |
13165 | Bash for at least one architecture before you can create build |
13166 | directories for other architectures. | |
a0c0a00f CR |
13167 | </p> |
13168 | <hr> | |
13169 | <a name="Installation-Names"></a> | |
13170 | <div class="header"> | |
13171 | <p> | |
13172 | Next: <a href="#Specifying-the-System-Type" accesskey="n" rel="next">Specifying the System Type</a>, Previous: <a href="#Compiling-For-Multiple-Architectures" accesskey="p" rel="prev">Compiling For Multiple Architectures</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> [<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, ‘<samp>make install</samp>’ will install into | |
13178 | <samp>/usr/local/bin</samp>, <samp>/usr/local/man</samp>, etc. You can | |
13179 | specify an installation prefix other than <samp>/usr/local</samp> by | |
13180 | giving <code>configure</code> the option <samp>--prefix=<var>PATH</var></samp>, | |
13181 | or by specifying a value for the <code>DESTDIR</code> ‘<samp>make</samp>’ | |
13182 | variable when running ‘<samp>make install</samp>’. | |
13183 | </p> | |
13184 | <p>You can specify separate installation prefixes for | |
17345e5a | 13185 | architecture-specific files and architecture-independent files. |
a0c0a00f CR |
13186 | If you give <code>configure</code> the option |
13187 | <samp>--exec-prefix=<var>PATH</var></samp>, ‘<samp>make install</samp>’ will use | |
13188 | <var>PATH</var> as the prefix for installing programs and libraries. | |
17345e5a | 13189 | Documentation 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> | |
13195 | Next: <a href="#Sharing-Defaults" accesskey="n" rel="next">Sharing Defaults</a>, Previous: <a href="#Installation-Names" accesskey="p" rel="prev">Installation Names</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> [<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 | 13201 | automatically, but need to determine by the type of host Bash |
a0c0a00f | 13202 | will run on. Usually <code>configure</code> can figure that |
17345e5a | 13203 | out, but if it prints a message saying it can not guess the host |
a0c0a00f CR |
13204 | type, give it the <samp>--host=TYPE</samp> option. ‘<samp>TYPE</samp>’ can |
13205 | either be a short name for the system type, such as ‘<samp>sun4</samp>’, | |
13206 | or a canonical name with three fields: ‘<samp>CPU-COMPANY-SYSTEM</samp>’ | |
13207 | (e.g., ‘<samp>i386-unknown-freebsd4.2</samp>’). | |
13208 | </p> | |
13209 | <p>See the file <samp>support/config.sub</samp> for the possible | |
17345e5a | 13210 | values of each field. |
a0c0a00f CR |
13211 | </p> |
13212 | <hr> | |
13213 | <a name="Sharing-Defaults"></a> | |
13214 | <div class="header"> | |
13215 | <p> | |
13216 | Next: <a href="#Operation-Controls" accesskey="n" rel="next">Operation Controls</a>, Previous: <a href="#Specifying-the-System-Type" accesskey="p" rel="prev">Specifying the System Type</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> [<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 | 13222 | share, 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> | |
13225 | looks 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 | |
13228 | script. A warning: the Bash <code>configure</code> looks for a site script, | |
13229 | but not all <code>configure</code> scripts do. | |
13230 | </p> | |
13231 | <hr> | |
13232 | <a name="Operation-Controls"></a> | |
13233 | <div class="header"> | |
13234 | <p> | |
13235 | Next: <a href="#Optional-Features" accesskey="n" rel="next">Optional Features</a>, Previous: <a href="#Sharing-Defaults" accesskey="p" rel="prev">Sharing Defaults</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> [<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 | 13241 | operates. |
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 | 13268 | script, and exit. |
a0c0a00f CR |
13269 | </p></dd> |
13270 | </dl> | |
13271 | ||
13272 | <p><code>configure</code> also accepts some other, not widely used, boilerplate | |
13273 | options. ‘<samp>configure --help</samp>’ prints the complete list. | |
13274 | </p> | |
13275 | <hr> | |
13276 | <a name="Optional-Features"></a> | |
13277 | <div class="header"> | |
13278 | <p> | |
13279 | Previous: <a href="#Operation-Controls" accesskey="p" rel="prev">Operation Controls</a>, Up: <a href="#Installing-Bash" accesskey="u" rel="up">Installing Bash</a> [<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> | |
13285 | options, where <var>feature</var> indicates an optional part of Bash. | |
13286 | There are also several <samp>--with-<var>package</var></samp> options, | |
13287 | where <var>package</var> is something like ‘<samp>bash-malloc</samp>’ or ‘<samp>purify</samp>’. | |
17345e5a | 13288 | To turn off the default use of a package, use |
a0c0a00f CR |
13289 | <samp>--without-<var>package</var></samp>. To configure Bash without a feature |
13290 | that 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 | |
13304 | originally derived from the 4.2 <small>BSD</small> <code>malloc</code>. This <code>malloc</code> | |
17345e5a JA |
13305 | is very fast, but wastes some space on each allocation. |
13306 | This option is enabled by default. | |
a0c0a00f CR |
13307 | The <samp>NOTES</samp> file contains a list of systems for |
13308 | which this should be turned off, and <code>configure</code> disables this | |
17345e5a | 13309 | option 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 |
13314 | be supplied if your system has an inadequate or incomplete termcap |
13315 | database. | |
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 | |
13324 | rather than the version in <samp>lib/readline</samp>. This works only with | |
13325 | Readline 5.0 and later versions. If <var>PREFIX</var> is <code>yes</code> or not | |
13326 | supplied, <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 |
13328 | by default, to find the installed version of Readline if it is not in |
13329 | the standard system include and library directories. | |
a0c0a00f CR |
13330 | If <var>PREFIX</var> is <code>no</code>, Bash links with the version in |
13331 | <samp>lib/readline</samp>. | |
13332 | If <var>PREFIX</var> is set to any other value, <code>configure</code> treats it as | |
17345e5a JA |
13333 | a directory pathname and looks for |
13334 | the 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 | 13341 | Software. |
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 | 13346 | Bourne 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 | 13351 | compiled 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 |
13356 | to build programs which can access large files. This is enabled by |
13357 | default, 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 | |
13362 | processed 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. | |
13367 | This could be used to build a version to use as root’s shell. | |
13368 | </p></dd> | |
13369 | </dl> | |
13370 | ||
13371 | <p>The ‘<samp>minimal-config</samp>’ option can be used to disable all of | |
17345e5a | 13372 | the following options, but it is processed first, so individual |
a0c0a00f CR |
13373 | options may be enabled using ‘<samp>enable-<var>feature</var></samp>’. |
13374 | </p> | |
13375 | <p>All of the following options except for ‘<samp>disabled-builtins</samp>’, | |
13376 | ‘<samp>direxpand-default</samp>’, and | |
13377 | ‘<samp>xpg-echo-default</samp>’ are | |
17345e5a JA |
13378 | enabled by default, unless the operating system does not provide the |
13379 | necessary 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> | |
13384 | builtins (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 | |
13389 | that 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> → <code>bac bbc</code> ). | |
13406 | See <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 | |
13411 | and assignment statements. Variables with the <var>uppercase</var> attribute, | |
17345e5a | 13412 | for 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 | |
13421 | displaying timing statistics for the pipeline following <code>time</code> | |
13422 | (see <a href="#Pipelines">Pipelines</a>). | |
17345e5a | 13423 | This 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 | ‘<samp>=~</samp>’ 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 | |
13448 | calling <code>fstat</code> on file descriptor <var>N</var>, supply this option to | |
13449 | enable a workaround. | |
13450 | This 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 |
13455 | to be enabled by default when the shell starts. |
13456 | It 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 ‘<samp>builtin xxx</samp>’ | |
13467 | even after <code>xxx</code> has been disabled using ‘<samp>enable -n xxx</samp>’. | |
13468 | See <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>((…))</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 | |
13479 | above 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 | |
13484 | above 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 | |
13489 | instance of the shell from the environment. This option is enabled by | |
13490 | default. | |
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 | |
13495 | above under <a href="#The-Shopt-Builtin">The Shopt Builtin</a> to be enabled. | |
ac50fbac CR |
13496 | This controls the behavior of character ranges when used in pattern matching |
13497 | bracket 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 | |
13502 | variables (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> | |
13507 | builtin 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 | 13512 | if 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 | 13517 | system 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> | |
13524 | when 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 | 13529 | the 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 | 13535 | If 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 | 13540 | in the <code>$PS0</code>, <code>$PS1</code>, <code>$PS2</code>, and <code>$PS4</code> prompt |
a0c0a00f | 13541 | strings. See <a href="#Controlling-the-Prompt">Controlling the Prompt</a>, for a complete list of prompt |
17345e5a | 13542 | string 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 | |
13547 | version 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, | |
13552 | when 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 | |
13558 | simple 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 | 13563 | instead 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 |
13568 | each help topic. This aids in translating the text to different languages. |
13569 | You may need to disable this if your compiler cannot handle very long string | |
13570 | literals. | |
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, | |
13583 | without requiring the <samp>-e</samp> option. | |
13584 | This sets the default value of the <code>xpg_echo</code> shell option to <code>on</code>, | |
13585 | which makes the Bash <code>echo</code> behave more like the version specified in | |
17345e5a | 13586 | the Single Unix Specification, version 3. |
a0c0a00f CR |
13587 | See <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 | ‘<samp>#define</samp>’ statements for options which are not settable from | |
13594 | <code>configure</code>. | |
17345e5a JA |
13595 | Some of these are not meant to be changed; beware of the consequences if |
13596 | you do. | |
13597 | Read the comments associated with each definition for more | |
13598 | information about its effect. | |
a0c0a00f CR |
13599 | </p> |
13600 | <hr> | |
13601 | <a name="Reporting-Bugs"></a> | |
13602 | <div class="header"> | |
13603 | <p> | |
13604 | Next: <a href="#Major-Differences-From-The-Bourne-Shell" accesskey="n" rel="next">Major Differences From The Bourne Shell</a>, Previous: <a href="#Installing-Bash" accesskey="p" rel="prev">Installing Bash</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<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 |
13610 | But first, you should |
13611 | make sure that it really is a bug, and that it appears in the latest | |
13612 | version of Bash. | |
13613 | The 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 | 13618 | If you have a fix, you are encouraged to mail that as well! |
a0c0a00f CR |
13619 | Suggestions and ‘philosophical’ bug reports may be mailed |
13620 | to <a href="mailto:bug-bash@gnu.org">bug-bash@gnu.org</a> or posted to the Usenet | |
13621 | newsgroup <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 ‘recipe’ which exercises the bug and may be used | |
17345e5a | 13630 | to reproduce it. |
a0c0a00f | 13631 | </li></ul> |
17345e5a | 13632 | |
a0c0a00f | 13633 | <p><code>bashbug</code> inserts the first three items automatically into |
17345e5a | 13634 | the 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> | |
13643 | Next: <a href="#GNU-Free-Documentation-License" accesskey="n" rel="next">GNU Free Documentation License</a>, Previous: <a href="#Reporting-Bugs" accesskey="p" rel="prev">Reporting Bugs</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<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 | 13649 | variable expansion, redirection, and quoting as the Bourne Shell. |
a0c0a00f | 13650 | Bash uses the <small>POSIX</small> standard as the specification of |
17345e5a JA |
13651 | how these features are to be implemented. There are some |
13652 | differences between the traditional Bourne shell and Bash; this | |
13653 | section quickly details the differences of significance. A | |
13654 | number of these differences are explained in greater depth in | |
13655 | previous sections. | |
a0c0a00f | 13656 | This section uses the version of <code>sh</code> included in SVR4.2 (the |
17345e5a | 13657 | last 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 | |
13661 | differs 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 |
13666 | the <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 | 13671 | manipulate 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 | 13675 | The Bash history list maintains timestamp information and uses the |
a0c0a00f | 13676 | value 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 |
13682 | appropriate variable expansions and assignment syntax to use them. |
13683 | Several of the Bash builtins take options to act on arrays. | |
13684 | Bash provides a number of built-in array variables. | |
17345e5a | 13685 | |
a0c0a00f | 13686 | </li><li> The <code>$'…'</code> quoting syntax, which expands ANSI-C |
17345e5a | 13687 | backslash-escaped characters in the text between the single quotes, |
a0c0a00f | 13688 | is supported (see <a href="#ANSI_002dC-Quoting">ANSI-C Quoting</a>). |
17345e5a | 13689 | |
a0c0a00f | 13690 | </li><li> Bash supports the <code>$"…"</code> quoting syntax to do |
17345e5a | 13691 | locale-specific translation of the characters between the double |
a0c0a00f | 13692 | quotes. The <samp>-D</samp>, <samp>--dump-strings</samp>, and <samp>--dump-po-strings</samp> |
17345e5a | 13693 | invocation 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 | |
13697 | a pipeline (see <a href="#Pipelines">Pipelines</a>). | |
13698 | Very useful when an <code>if</code> statement needs to act only if a test fails. | |
13699 | The Bash ‘<samp>-o pipefail</samp>’ option to <code>set</code> will cause a pipeline to | |
17345e5a | 13700 | return 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 | 13703 | The 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> | |
13707 | arithmetic 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 | |
13710 | generation 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 | |
13713 | testing part of the shell grammar (see <a href="#Conditional-Constructs">Conditional Constructs</a>), including | |
17345e5a | 13714 | optional 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 | |
13720 | expansion (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> | |
13723 | builtins (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>), | |
13727 | and arithmetic expansion (see <a href="#Shell-Arithmetic">Shell Arithmetic</a>). | |
13728 | ||
13729 | </li><li> Variables present in the shell’s initial environment are automatically | |
17345e5a | 13730 | exported to child processes. The Bourne shell does not normally do |
a0c0a00f | 13731 | this unless the variables are explicitly marked using the <code>export</code> |
17345e5a | 13732 | command. |
17345e5a | 13733 | |
a0c0a00f | 13734 | </li><li> Bash supports the ‘<samp>+=</samp>’ assignment operator, which appends to the value |
17345e5a | 13735 | of the variable named on the left hand side. |
a0c0a00f CR |
13736 | |
13737 | </li><li> Bash includes the <small>POSIX</small> pattern removal ‘<samp>%</samp>’, ‘<samp>#</samp>’, ‘<samp>%%</samp>’ | |
13738 | and ‘<samp>##</samp>’ expansions to remove leading or trailing substrings from | |
13739 | variable 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>, | |
13742 | is 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>, | |
13745 | which expands to the substring of <code>var</code>’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>, | |
13751 | which matches <var>pattern</var> and replaces it with <var>replacement</var> in | |
13752 | the 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 | |
13755 | the names of all shell variables whose names begin with <var>prefix</var>, | |
13756 | is 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 | |
13765 | is implemented (see <a href="#Command-Substitution">Command Substitution</a>), | |
13766 | and preferred to the Bourne shell’s <code>``</code> (which | |
17345e5a | 13767 | is 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 | |
13772 | current 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>), | |
13774 | and 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 | 13776 | for details. |
17345e5a | 13777 | |
a0c0a00f CR |
13778 | </li><li> The <code>IFS</code> variable is used to split only the results of expansion, |
13779 | not all words (see <a href="#Word-Splitting">Word Splitting</a>). | |
17345e5a | 13780 | This closes a longstanding shell security hole. |
17345e5a | 13781 | |
a0c0a00f | 13782 | </li><li> The filename expansion bracket expression code uses ‘<samp>!</samp>’ and ‘<samp>^</samp>’ |
ac50fbac | 13783 | to negate the set of characters between the brackets. |
a0c0a00f CR |
13784 | The Bourne shell uses only ‘<samp>!</samp>’. |
13785 | ||
13786 | </li><li> Bash implements the full set of <small>POSIX</small> filename expansion operators, | |
13787 | including <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> | |
13791 | shell 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 | |
13801 | builtins and functions (see <a href="#Environment">Environment</a>). | |
13802 | In <code>sh</code>, all variable assignments | |
17345e5a JA |
13803 | preceding commands are global unless the command is executed from the |
13804 | file system. | |
17345e5a | 13805 | |
a0c0a00f CR |
13806 | </li><li> Bash performs filename expansion on filenames specified as operands |
13807 | to input and output redirection operators (see <a href="#Redirections">Redirections</a>). | |
17345e5a | 13808 | |
a0c0a00f CR |
13809 | </li><li> Bash contains the ‘<samp><></samp>’ redirection operator, allowing a file to be |
13810 | opened for both reading and writing, and the ‘<samp>&></samp>’ redirection | |
17345e5a | 13811 | operator, for directing standard output and standard error to the same |
a0c0a00f | 13812 | file (see <a href="#Redirections">Redirections</a>). |
17345e5a | 13813 | |
a0c0a00f | 13814 | </li><li> Bash includes the ‘<samp><<<</samp>’ redirection operator, allowing a string to |
17345e5a | 13815 | be used as the standard input to a command. |
17345e5a | 13816 | |
a0c0a00f | 13817 | </li><li> Bash implements the ‘<samp>[n]<&<var>word</var></samp>’ and ‘<samp>[n]>&<var>word</var></samp>’ |
17345e5a | 13818 | redirection operators, which move one file descriptor to another. |
a0c0a00f CR |
13819 | |
13820 | </li><li> Bash treats a number of filenames specially when they are | |
13821 | used in redirection operators (see <a href="#Redirections">Redirections</a>). | |
13822 | ||
13823 | </li><li> Bash can open network connections to arbitrary machines and services | |
13824 | with the redirection operators (see <a href="#Redirections">Redirections</a>). | |
13825 | ||
13826 | </li><li> The <code>noclobber</code> option is available to avoid overwriting existing | |
13827 | files with output redirection (see <a href="#The-Set-Builtin">The Set Builtin</a>). | |
13828 | The ‘<samp>>|</samp>’ 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>) | |
13831 | each take <samp>-L</samp> and <samp>-P</samp> options to switch between logical and | |
17345e5a | 13832 | physical modes. |
a0c0a00f CR |
13833 | |
13834 | </li><li> Bash allows a function to override a builtin with the same name, and provides | |
13835 | access to that builtin’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 | |
13839 | when 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> | |
13842 | builtin (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 |
13845 | to control the contents of the environment passed to the executed |
13846 | command, 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 |
13850 | using <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 |
13853 | take a <samp>-f</samp> option to act on shell functions, a <samp>-p</samp> option to | |
17345e5a | 13854 | display variables with various attributes set in a format that can be |
a0c0a00f CR |
13855 | used as shell input, a <samp>-n</samp> option to remove various variable |
13856 | attributes, and ‘<samp>name=value</samp>’ arguments to set variable attributes | |
17345e5a | 13857 | and values simultaneously. |
17345e5a | 13858 | |
a0c0a00f | 13859 | </li><li> The Bash <code>hash</code> builtin allows a name to be associated with |
17345e5a | 13860 | an arbitrary filename, even when that filename cannot be found by |
a0c0a00f CR |
13861 | searching the <code>$PATH</code>, using ‘<samp>hash -p</samp>’ |
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 | |
13865 | facilities (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>) | |
13871 | will read a line ending in ‘<samp>\</samp>’ with | |
13872 | the <samp>-r</samp> option, and will use the <code>REPLY</code> variable as a | |
17345e5a | 13873 | default if no non-option arguments are supplied. |
a0c0a00f CR |
13874 | The Bash <code>read</code> builtin |
13875 | also accepts a prompt string with the <samp>-p</samp> option and will use | |
13876 | Readline to obtain the line when given the <samp>-e</samp> option. | |
13877 | The <code>read</code> builtin also has additional options to control input: | |
13878 | the <samp>-s</samp> option will turn off echoing of input characters as | |
13879 | they are read, the <samp>-t</samp> option will allow <code>read</code> to time out | |
17345e5a | 13880 | if 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 |
13882 | characters rather than a full line, and the <samp>-d</samp> option will read | |
17345e5a | 13883 | until 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 | |
13886 | executed 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 | |
13890 | optional capabilities (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>), and allows these options | |
13891 | to 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> | |
13894 | builtin (see <a href="#The-Set-Builtin">The Set Builtin</a>). | |
13895 | ||
13896 | </li><li> The ‘<samp>-x</samp>’ (<samp>xtrace</samp>) option displays commands other than | |
17345e5a | 13897 | simple 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>) |
13901 | is slightly different, as it implements the <small>POSIX</small> algorithm, | |
17345e5a | 13902 | which 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 | 13905 | any active subroutine call (a shell function or a script executed with |
a0c0a00f | 13906 | the <code>.</code> or <code>source</code> builtins). This supports the bash |
17345e5a | 13907 | debugger. |
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>. | |
13911 | Commands specified with a <code>DEBUG</code> trap are executed before every | |
13912 | simple command, <code>for</code> command, <code>case</code> command, | |
13913 | <code>select</code> command, every arithmetic <code>for</code> command, and before | |
17345e5a | 13914 | the first command executes in a shell function. |
a0c0a00f CR |
13915 | The <code>DEBUG</code> trap is not inherited by shell functions unless the |
13916 | function has been given the <code>trace</code> attribute or the | |
13917 | <code>functrace</code> option has been enabled using the <code>shopt</code> builtin. | |
13918 | The <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>. | |
13923 | Commands specified with an <code>ERR</code> trap are executed after a simple | |
17345e5a | 13924 | command fails, with a few exceptions. |
a0c0a00f CR |
13925 | The <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>. | |
13931 | Commands specified with an <code>RETURN</code> trap are executed before | |
17345e5a | 13932 | execution resumes after a shell function or a shell script executed with |
a0c0a00f CR |
13933 | <code>.</code> or <code>source</code> returns. |
13934 | The <code>RETURN</code> trap is not inherited by shell functions unless the | |
13935 | function 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 | |
13939 | about 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 | |
13942 | the output to be displayed in the form of a <code>umask</code> command | |
13943 | that 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 | 13948 | Bash 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 |
13952 | strings 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 | 13955 | the 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 |
13958 | job table (see <a href="#Job-Control-Builtins">Job Control Builtins</a>) or suppress the sending | |
13959 | of <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 | 13963 | shell 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 | |
13984 | many 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 | |
13988 | a shell control structure such as an <code>if</code> or <code>while</code> | |
17345e5a | 13989 | statement. |
17345e5a | 13990 | |
a0c0a00f CR |
13991 | </li><li> Bash does not allow unbalanced quotes. The SVR4.2 shell will silently |
13992 | insert a needed closing quote at <code>EOF</code> under certain circumstances. | |
17345e5a | 13993 | This 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 |
13996 | trapping <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 | 13998 | function call), it misbehaves badly. |
17345e5a | 13999 | |
a0c0a00f CR |
14000 | </li><li> In a questionable attempt at security, the SVR4.2 shell, |
14001 | when invoked without the <samp>-p</samp> option, will alter its real | |
14002 | and effective <small>UID</small> and <small>GID</small> if they are less than some | |
17345e5a JA |
14003 | magic threshold value, commonly 100. |
14004 | This 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 ‘<samp>^</samp>’ as the undocumented equivalent of | |
14013 | ‘<samp>|</samp>’. | |
14014 | ||
14015 | </li><li> Bash allows multiple option arguments when it is invoked (<code>-x -v</code>); | |
14016 | the SVR4.2 shell allows only one option argument (<code>-xv</code>). In | |
17345e5a | 14017 | fact, some versions of the shell dump core if the second argument begins |
a0c0a00f | 14018 | with a ‘<samp>-</samp>’. |
17345e5a | 14019 | |
a0c0a00f CR |
14020 | </li><li> The SVR4.2 shell exits a script if any builtin fails; Bash exits |
14021 | a script only if one of the <small>POSIX</small> special builtins fails, and | |
14022 | only 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> | |
14032 | Next: <a href="#Indexes" accesskey="n" rel="next">Indexes</a>, Previous: <a href="#Major-Differences-From-The-Bourne-Shell" accesskey="p" rel="prev">Major Differences From The Bourne Shell</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<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 © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. | |
14042 | <a href="http://fsf.org/">http://fsf.org/</a> | |
17345e5a JA |
14043 | |
14044 | Everyone is permitted to copy and distribute verbatim copies | |
14045 | of 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 |
14052 | functional and useful document <em>free</em> in the sense of freedom: to | |
17345e5a JA |
14053 | assure everyone the effective freedom to copy and redistribute it, |
14054 | with or without modifying it, either commercially or noncommercially. | |
14055 | Secondarily, this License preserves for the author and publisher a way | |
14056 | to get credit for their work, while not being considered responsible | |
14057 | for modifications made by others. | |
a0c0a00f CR |
14058 | </p> |
14059 | <p>This License is a kind of “copyleft”, which means that derivative | |
17345e5a JA |
14060 | works of the document must themselves be free in the same sense. It |
14061 | complements the GNU General Public License, which is a copyleft | |
14062 | license 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 |
14065 | software, because free software needs free documentation: a free |
14066 | program should come with manuals providing the same freedoms that the | |
14067 | software does. But this License is not limited to software manuals; | |
14068 | it can be used for any textual work, regardless of subject matter or | |
14069 | whether it is published as a printed book. We recommend this License | |
14070 | principally 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 |
14075 | contains a notice placed by the copyright holder saying it can be |
14076 | distributed under the terms of this License. Such a notice grants a | |
14077 | world-wide, royalty-free license, unlimited in duration, to use that | |
a0c0a00f | 14078 | work under the conditions stated herein. The “Document”, below, |
17345e5a | 14079 | refers to any such manual or work. Any member of the public is a |
a0c0a00f | 14080 | licensee, and is addressed as “you”. You accept the license if you |
17345e5a JA |
14081 | copy, modify or distribute the work in a way requiring permission |
14082 | under copyright law. | |
a0c0a00f CR |
14083 | </p> |
14084 | <p>A “Modified Version” of the Document means any work containing the | |
17345e5a JA |
14085 | Document or a portion of it, either copied verbatim, or with |
14086 | modifications and/or translated into another language. | |
a0c0a00f CR |
14087 | </p> |
14088 | <p>A “Secondary Section” is a named appendix or a front-matter section | |
17345e5a | 14089 | of the Document that deals exclusively with the relationship of the |
a0c0a00f | 14090 | publishers or authors of the Document to the Document’s overall |
17345e5a JA |
14091 | subject (or to related matters) and contains nothing that could fall |
14092 | directly within that overall subject. (Thus, if the Document is in | |
14093 | part a textbook of mathematics, a Secondary Section may not explain | |
14094 | any mathematics.) The relationship could be a matter of historical | |
14095 | connection with the subject or with related matters, or of legal, | |
14096 | commercial, philosophical, ethical or political position regarding | |
14097 | them. | |
a0c0a00f CR |
14098 | </p> |
14099 | <p>The “Invariant Sections” are certain Secondary Sections whose titles | |
17345e5a JA |
14100 | are designated, as being those of Invariant Sections, in the notice |
14101 | that says that the Document is released under this License. If a | |
14102 | section does not fit the above definition of Secondary then it is not | |
14103 | allowed to be designated as Invariant. The Document may contain zero | |
14104 | Invariant Sections. If the Document does not identify any Invariant | |
14105 | Sections then there are none. | |
a0c0a00f CR |
14106 | </p> |
14107 | <p>The “Cover Texts” are certain short passages of text that are listed, | |
17345e5a JA |
14108 | as Front-Cover Texts or Back-Cover Texts, in the notice that says that |
14109 | the Document is released under this License. A Front-Cover Text may | |
14110 | be at most 5 words, and a Back-Cover Text may be at most 25 words. | |
a0c0a00f CR |
14111 | </p> |
14112 | <p>A “Transparent” copy of the Document means a machine-readable copy, | |
17345e5a JA |
14113 | represented in a format whose specification is available to the |
14114 | general public, that is suitable for revising the document | |
14115 | straightforwardly with generic text editors or (for images composed of | |
14116 | pixels) generic paint programs or (for drawings) some widely available | |
14117 | drawing editor, and that is suitable for input to text formatters or | |
14118 | for automatic translation to a variety of formats suitable for input | |
14119 | to text formatters. A copy made in an otherwise Transparent file | |
14120 | format whose markup, or absence of markup, has been arranged to thwart | |
14121 | or discourage subsequent modification by readers is not Transparent. | |
14122 | An image format is not Transparent if used for any substantial amount | |
a0c0a00f CR |
14123 | of text. A copy that is not “Transparent” is called “Opaque”. |
14124 | </p> | |
14125 | <p>Examples of suitable formats for Transparent copies include plain | |
14126 | <small>ASCII</small> without markup, Texinfo input format, LaTeX input | |
14127 | format, <acronym>SGML</acronym> or <acronym>XML</acronym> using a publicly available | |
14128 | <acronym>DTD</acronym>, and standard-conforming simple <acronym>HTML</acronym>, | |
14129 | PostScript or <acronym>PDF</acronym> designed for human modification. Examples | |
14130 | of transparent image formats include <acronym>PNG</acronym>, <acronym>XCF</acronym> and | |
14131 | <acronym>JPG</acronym>. Opaque formats include proprietary formats that can be | |
14132 | read 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 | |
14134 | not generally available, and the machine-generated <acronym>HTML</acronym>, | |
14135 | PostScript or <acronym>PDF</acronym> produced by some word processors for | |
17345e5a | 14136 | output purposes only. |
a0c0a00f CR |
14137 | </p> |
14138 | <p>The “Title Page” means, for a printed book, the title page itself, | |
17345e5a JA |
14139 | plus such following pages as are needed to hold, legibly, the material |
14140 | this License requires to appear in the title page. For works in | |
a0c0a00f CR |
14141 | formats which do not have any title page as such, “Title Page” means |
14142 | the text near the most prominent appearance of the work’s title, | |
17345e5a | 14143 | preceding the beginning of the body of the text. |
a0c0a00f CR |
14144 | </p> |
14145 | <p>The “publisher” means any person or entity that distributes copies | |
0001803f | 14146 | of the Document to the public. |
a0c0a00f CR |
14147 | </p> |
14148 | <p>A section “Entitled XYZ” means a named subunit of the Document whose | |
17345e5a JA |
14149 | title either is precisely XYZ or contains XYZ in parentheses following |
14150 | text that translates XYZ in another language. (Here XYZ stands for a | |
a0c0a00f CR |
14151 | specific section name mentioned below, such as “Acknowledgements”, |
14152 | “Dedications”, “Endorsements”, or “History”.) To “Preserve the Title” | |
17345e5a | 14153 | of such a section when you modify the Document means that it remains a |
a0c0a00f CR |
14154 | section “Entitled XYZ” according to this definition. |
14155 | </p> | |
14156 | <p>The Document may include Warranty Disclaimers next to the notice which | |
17345e5a JA |
14157 | states that this License applies to the Document. These Warranty |
14158 | Disclaimers are considered to be included by reference in this | |
14159 | License, but only as regards disclaiming warranties: any other | |
14160 | implication that these Warranty Disclaimers may have is void and has | |
14161 | no 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 |
14166 | commercially or noncommercially, provided that this License, the |
14167 | copyright notices, and the license notice saying this License applies | |
14168 | to the Document are reproduced in all copies, and that you add no other | |
14169 | conditions whatsoever to those of this License. You may not use | |
14170 | technical measures to obstruct or control the reading or further | |
14171 | copying of the copies you make or distribute. However, you may accept | |
14172 | compensation in exchange for copies. If you distribute a large enough | |
14173 | number 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 | 14176 | you 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 | 14181 | printed covers) of the Document, numbering more than 100, and the |
a0c0a00f | 14182 | Document’s license notice requires Cover Texts, you must enclose the |
17345e5a JA |
14183 | copies in covers that carry, clearly and legibly, all these Cover |
14184 | Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on | |
14185 | the back cover. Both covers must also clearly and legibly identify | |
14186 | you as the publisher of these copies. The front cover must present | |
14187 | the full title with all words of the title equally prominent and | |
14188 | visible. You may add other material on the covers in addition. | |
14189 | Copying with changes limited to the covers, as long as they preserve | |
14190 | the title of the Document and satisfy these conditions, can be treated | |
14191 | as 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 |
14194 | legibly, you should put the first ones listed (as many as fit |
14195 | reasonably) on the actual cover, and continue the rest onto adjacent | |
14196 | pages. | |
a0c0a00f CR |
14197 | </p> |
14198 | <p>If you publish or distribute Opaque copies of the Document numbering | |
17345e5a JA |
14199 | more than 100, you must either include a machine-readable Transparent |
14200 | copy along with each Opaque copy, or state in or with each Opaque copy | |
14201 | a computer-network location from which the general network-using | |
14202 | public has access to download using public-standard network protocols | |
14203 | a complete Transparent copy of the Document, free of added material. | |
14204 | If you use the latter option, you must take reasonably prudent steps, | |
14205 | when you begin distribution of Opaque copies in quantity, to ensure | |
14206 | that this Transparent copy will remain thus accessible at the stated | |
14207 | location until at least one year after the last time you distribute an | |
14208 | Opaque copy (directly or through your agents or retailers) of that | |
14209 | edition to the public. | |
a0c0a00f CR |
14210 | </p> |
14211 | <p>It is requested, but not required, that you contact the authors of the | |
17345e5a JA |
14212 | Document well before redistributing any large number of copies, to give |
14213 | them 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 |
14218 | the conditions of sections 2 and 3 above, provided that you release |
14219 | the Modified Version under precisely this License, with the Modified | |
14220 | Version filling the role of the Document, thus licensing distribution | |
14221 | and modification of the Modified Version to whoever possesses a copy | |
14222 | of 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 |
14226 | from that of the Document, and from those of previous versions |
14227 | (which should, if there were any, be listed in the History section | |
14228 | of the Document). You may use the same title as a previous version | |
14229 | if 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 |
14232 | responsible for authorship of the modifications in the Modified |
14233 | Version, together with at least five of the principal authors of the | |
14234 | Document (all of its principal authors, if it has fewer than five), | |
14235 | unless 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 | 14238 | Modified 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 | 14243 | adjacent to the other copyright notices. |
17345e5a | 14244 | |
a0c0a00f | 14245 | </li><li> Include, immediately after the copyright notices, a license notice |
17345e5a JA |
14246 | giving the public permission to use the Modified Version under the |
14247 | terms 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 |
14250 | and required Cover Texts given in the Document’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 “History”, Preserve its Title, and add |
17345e5a JA |
14255 | to it an item stating at least the title, year, new authors, and |
14256 | publisher of the Modified Version as given on the Title Page. If | |
a0c0a00f | 14257 | there is no section Entitled “History” in the Document, create one |
17345e5a JA |
14258 | stating the title, year, authors, and publisher of the Document as |
14259 | given on its Title Page, then add an item describing the Modified | |
14260 | Version 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 |
14263 | public access to a Transparent copy of the Document, and likewise |
14264 | the network locations given in the Document for previous versions | |
a0c0a00f | 14265 | it was based on. These may be placed in the “History” section. |
17345e5a JA |
14266 | You may omit a network location for a work that was published at |
14267 | least four years before the Document itself, or if the original | |
14268 | publisher of the version it refers to gives permission. | |
17345e5a | 14269 | |
a0c0a00f | 14270 | </li><li> For any section Entitled “Acknowledgements” or “Dedications”, Preserve |
17345e5a JA |
14271 | the Title of the section, and preserve in the section all the |
14272 | substance and tone of each of the contributor acknowledgements and/or | |
14273 | dedications given therein. | |
17345e5a | 14274 | |
a0c0a00f | 14275 | </li><li> Preserve all the Invariant Sections of the Document, |
17345e5a JA |
14276 | unaltered in their text and in their titles. Section numbers |
14277 | or the equivalent are not considered part of the section titles. | |
17345e5a | 14278 | |
a0c0a00f | 14279 | </li><li> Delete any section Entitled “Endorsements”. Such a section |
17345e5a | 14280 | may not be included in the Modified Version. |
17345e5a | 14281 | |
a0c0a00f | 14282 | </li><li> Do not retitle any existing section to be Entitled “Endorsements” or |
17345e5a | 14283 | to 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 |
14289 | appendices that qualify as Secondary Sections and contain no material |
14290 | copied from the Document, you may at your option designate some or all | |
14291 | of these sections as invariant. To do this, add their titles to the | |
a0c0a00f | 14292 | list of Invariant Sections in the Modified Version’s license notice. |
17345e5a | 14293 | These titles must be distinct from any other section titles. |
a0c0a00f CR |
14294 | </p> |
14295 | <p>You may add a section Entitled “Endorsements”, provided it contains | |
17345e5a | 14296 | nothing but endorsements of your Modified Version by various |
a0c0a00f | 14297 | parties—for example, statements of peer review or that the text has |
17345e5a JA |
14298 | been approved by an organization as the authoritative definition of a |
14299 | standard. | |
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 |
14302 | passage of up to 25 words as a Back-Cover Text, to the end of the list |
14303 | of Cover Texts in the Modified Version. Only one passage of | |
14304 | Front-Cover Text and one of Back-Cover Text may be added by (or | |
14305 | through arrangements made by) any one entity. If the Document already | |
14306 | includes a cover text for the same cover, previously added by you or | |
14307 | by arrangement made by the same entity you are acting on behalf of, | |
14308 | you may not add another; but you may replace the old one, on explicit | |
14309 | permission 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 |
14312 | give permission to use their names for publicity for or to assert or |
14313 | imply 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 |
14318 | License, under the terms defined in section 4 above for modified |
14319 | versions, provided that you include in the combination all of the | |
14320 | Invariant Sections of all of the original documents, unmodified, and | |
14321 | list them all as Invariant Sections of your combined work in its | |
14322 | license 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 |
14325 | multiple identical Invariant Sections may be replaced with a single |
14326 | copy. If there are multiple Invariant Sections with the same name but | |
14327 | different contents, make the title of each such section unique by | |
14328 | adding at the end of it, in parentheses, the name of the original | |
14329 | author or publisher of that section if known, or else a unique number. | |
14330 | Make the same adjustment to the section titles in the list of | |
14331 | Invariant Sections in the license notice of the combined work. | |
a0c0a00f CR |
14332 | </p> |
14333 | <p>In the combination, you must combine any sections Entitled “History” | |
17345e5a | 14334 | in the various original documents, forming one section Entitled |
a0c0a00f CR |
14335 | “History”; likewise combine any sections Entitled “Acknowledgements”, |
14336 | and any sections Entitled “Dedications”. You must delete all | |
14337 | sections Entitled “Endorsements.” | |
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 |
14342 | released under this License, and replace the individual copies of this |
14343 | License in the various documents with a single copy that is included in | |
14344 | the collection, provided that you follow the rules of this License for | |
14345 | verbatim 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 |
14348 | it individually under this License, provided you insert a copy of this |
14349 | License into the extracted document, and follow this License in all | |
14350 | other 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 | 14355 | and independent documents or works, in or on a volume of a storage or |
a0c0a00f | 14356 | distribution medium, is called an “aggregate” if the copyright |
17345e5a | 14357 | resulting from the compilation is not used to limit the legal rights |
a0c0a00f | 14358 | of the compilation’s users beyond what the individual works permit. |
17345e5a JA |
14359 | When the Document is included in an aggregate, this License does not |
14360 | apply to the other works in the aggregate which are not themselves | |
14361 | derivative works of the Document. | |
a0c0a00f CR |
14362 | </p> |
14363 | <p>If the Cover Text requirement of section 3 is applicable to these | |
17345e5a | 14364 | copies of the Document, then if the Document is less than one half of |
a0c0a00f | 14365 | the entire aggregate, the Document’s Cover Texts may be placed on |
17345e5a JA |
14366 | covers that bracket the Document within the aggregate, or the |
14367 | electronic equivalent of covers if the Document is in electronic form. | |
14368 | Otherwise they must appear on printed covers that bracket the whole | |
14369 | aggregate. | |
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 |
14374 | distribute translations of the Document under the terms of section 4. |
14375 | Replacing Invariant Sections with translations requires special | |
14376 | permission from their copyright holders, but you may include | |
14377 | translations of some or all Invariant Sections in addition to the | |
14378 | original versions of these Invariant Sections. You may include a | |
14379 | translation of this License, and all the license notices in the | |
14380 | Document, and any Warranty Disclaimers, provided that you also include | |
14381 | the original English version of this License and the original versions | |
14382 | of those notices and disclaimers. In case of a disagreement between | |
14383 | the translation and the original version of this License or a notice | |
14384 | or disclaimer, the original version will prevail. | |
a0c0a00f CR |
14385 | </p> |
14386 | <p>If a section in the Document is Entitled “Acknowledgements”, | |
14387 | “Dedications”, or “History”, the requirement (section 4) to Preserve | |
17345e5a JA |
14388 | its Title (section 1) will typically require changing the actual |
14389 | title. | |
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 |
14394 | except as expressly provided under this License. Any attempt |
14395 | otherwise to copy, modify, sublicense, or distribute it is void, and | |
14396 | will 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 |
14399 | from a particular copyright holder is reinstated (a) provisionally, |
14400 | unless and until the copyright holder explicitly and finally | |
14401 | terminates your license, and (b) permanently, if the copyright holder | |
14402 | fails to notify you of the violation by some reasonable means prior to | |
14403 | 60 days after the cessation. | |
a0c0a00f CR |
14404 | </p> |
14405 | <p>Moreover, your license from a particular copyright holder is | |
0001803f CR |
14406 | reinstated permanently if the copyright holder notifies you of the |
14407 | violation by some reasonable means, this is the first time you have | |
14408 | received notice of violation of this License (for any work) from that | |
14409 | copyright holder, and you cure the violation prior to 30 days after | |
14410 | your receipt of the notice. | |
a0c0a00f CR |
14411 | </p> |
14412 | <p>Termination of your rights under this section does not terminate the | |
0001803f CR |
14413 | licenses of parties who have received copies or rights from you under |
14414 | this License. If your rights have been terminated and not permanently | |
14415 | reinstated, receipt of a copy of some or all of the same material does | |
14416 | not 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 |
14421 | of the GNU Free Documentation License from time to time. Such new |
14422 | versions will be similar in spirit to the present version, but may | |
14423 | differ 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 | 14427 | If the Document specifies that a particular numbered version of this |
a0c0a00f | 14428 | License “or any later version” applies to it, you have the option of |
17345e5a JA |
14429 | following the terms and conditions either of that specified version or |
14430 | of any later version that has been published (not as a draft) by the | |
14431 | Free Software Foundation. If the Document does not specify a version | |
14432 | number of this License, you may choose any version ever published (not | |
0001803f CR |
14433 | as a draft) by the Free Software Foundation. If the Document |
14434 | specifies that a proxy can decide which future versions of this | |
a0c0a00f | 14435 | License can be used, that proxy’s public statement of acceptance of a |
0001803f CR |
14436 | version permanently authorizes you to choose that version for the |
14437 | Document. | |
a0c0a00f CR |
14438 | </p> |
14439 | </li><li> RELICENSING | |
0001803f | 14440 | |
a0c0a00f | 14441 | <p>“Massive Multiauthor Collaboration Site” (or “MMC Site”) means any |
0001803f CR |
14442 | World Wide Web server that publishes copyrightable works and also |
14443 | provides prominent facilities for anybody to edit those works. A | |
14444 | public wiki that anybody can edit is an example of such a server. A | |
a0c0a00f | 14445 | “Massive Multiauthor Collaboration” (or “MMC”) contained in the |
0001803f CR |
14446 | site means any set of copyrightable works thus published on the MMC |
14447 | site. | |
a0c0a00f CR |
14448 | </p> |
14449 | <p>“CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0 | |
0001803f CR |
14450 | license published by Creative Commons Corporation, a not-for-profit |
14451 | corporation with a principal place of business in San Francisco, | |
14452 | California, as well as future copyleft versions of that license | |
14453 | published by that same organization. | |
a0c0a00f CR |
14454 | </p> |
14455 | <p>“Incorporate” means to publish or republish a Document, in whole or | |
0001803f | 14456 | in part, as part of another Document. |
a0c0a00f CR |
14457 | </p> |
14458 | <p>An MMC is “eligible for relicensing” if it is licensed under this | |
0001803f CR |
14459 | License, and if all works that were first published under this License |
14460 | somewhere other than this MMC, and subsequently incorporated in whole | |
14461 | or in part into the MMC, (1) had no cover texts or invariant sections, | |
14462 | and (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 |
14465 | under CC-BY-SA on the same site at any time before August 1, 2009, |
14466 | provided 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 |
14474 | the License in the document and put the following copyright and |
14475 | license 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, | |
14488 | replace the “with…Texts.” 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 |
14497 | combination of the three, merge those two alternatives to suit the |
14498 | situation. | |
a0c0a00f CR |
14499 | </p> |
14500 | <p>If your document contains nontrivial examples of program code, we | |
17345e5a JA |
14501 | recommend releasing these examples in parallel under your choice of |
14502 | free software license, such as the GNU General Public License, | |
14503 | to 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> | |
14511 | Previous: <a href="#GNU-Free-Documentation-License" accesskey="p" rel="prev">GNU Free Documentation License</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<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">• <a href="#Builtin-Index" accesskey="1">Builtin Index</a>:</td><td> </td><td align="left" valign="top">Index of Bash builtin commands. | |
14518 | </td></tr> | |
14519 | <tr><td align="left" valign="top">• <a href="#Reserved-Word-Index" accesskey="2">Reserved Word Index</a>:</td><td> </td><td align="left" valign="top">Index of Bash reserved words. | |
14520 | </td></tr> | |
14521 | <tr><td align="left" valign="top">• <a href="#Variable-Index" accesskey="3">Variable Index</a>:</td><td> </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">• <a href="#Function-Index" accesskey="4">Function Index</a>:</td><td> </td><td align="left" valign="top">Index of bindable Readline functions. | |
14525 | </td></tr> | |
14526 | <tr><td align="left" valign="top">• <a href="#Concept-Index" accesskey="5">Concept Index</a>:</td><td> </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> | |
14535 | Next: <a href="#Reserved-Word-Index" accesskey="n" rel="next">Reserved Word Index</a>, Up: <a href="#Indexes" accesskey="u" rel="up">Indexes</a> [<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: </th><td><a class="summary-letter" href="#Builtin-Index_bt_symbol-1"><b>.</b></a> | |
14540 | | |
14541 | <a class="summary-letter" href="#Builtin-Index_bt_symbol-2"><b>:</b></a> | |
14542 | | |
14543 | <a class="summary-letter" href="#Builtin-Index_bt_symbol-3"><b>[</b></a> | |
17345e5a | 14544 | |
a0c0a00f CR |
14545 | <br> |
14546 | <a class="summary-letter" href="#Builtin-Index_bt_letter-A"><b>A</b></a> | |
14547 | | |
14548 | <a class="summary-letter" href="#Builtin-Index_bt_letter-B"><b>B</b></a> | |
14549 | | |
14550 | <a class="summary-letter" href="#Builtin-Index_bt_letter-C"><b>C</b></a> | |
14551 | | |
14552 | <a class="summary-letter" href="#Builtin-Index_bt_letter-D"><b>D</b></a> | |
14553 | | |
14554 | <a class="summary-letter" href="#Builtin-Index_bt_letter-E"><b>E</b></a> | |
14555 | | |
14556 | <a class="summary-letter" href="#Builtin-Index_bt_letter-F"><b>F</b></a> | |
14557 | | |
14558 | <a class="summary-letter" href="#Builtin-Index_bt_letter-G"><b>G</b></a> | |
14559 | | |
14560 | <a class="summary-letter" href="#Builtin-Index_bt_letter-H"><b>H</b></a> | |
14561 | | |
14562 | <a class="summary-letter" href="#Builtin-Index_bt_letter-J"><b>J</b></a> | |
14563 | | |
14564 | <a class="summary-letter" href="#Builtin-Index_bt_letter-K"><b>K</b></a> | |
14565 | | |
14566 | <a class="summary-letter" href="#Builtin-Index_bt_letter-L"><b>L</b></a> | |
14567 | | |
14568 | <a class="summary-letter" href="#Builtin-Index_bt_letter-M"><b>M</b></a> | |
14569 | | |
14570 | <a class="summary-letter" href="#Builtin-Index_bt_letter-P"><b>P</b></a> | |
14571 | | |
14572 | <a class="summary-letter" href="#Builtin-Index_bt_letter-R"><b>R</b></a> | |
14573 | | |
14574 | <a class="summary-letter" href="#Builtin-Index_bt_letter-S"><b>S</b></a> | |
14575 | | |
14576 | <a class="summary-letter" href="#Builtin-Index_bt_letter-T"><b>T</b></a> | |
14577 | | |
14578 | <a class="summary-letter" href="#Builtin-Index_bt_letter-U"><b>U</b></a> | |
14579 | | |
14580 | <a class="summary-letter" href="#Builtin-Index_bt_letter-W"><b>W</b></a> | |
14581 | | |
14582 | </td></tr></table> | |
14583 | <table class="index-bt" border="0"> | |
14584 | <tr><td></td><th align="left">Index Entry</th><td> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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: </th><td><a class="summary-letter" href="#Builtin-Index_bt_symbol-1"><b>.</b></a> | |
14689 | | |
14690 | <a class="summary-letter" href="#Builtin-Index_bt_symbol-2"><b>:</b></a> | |
14691 | | |
14692 | <a class="summary-letter" href="#Builtin-Index_bt_symbol-3"><b>[</b></a> | |
17345e5a | 14693 | |
a0c0a00f CR |
14694 | <br> |
14695 | <a class="summary-letter" href="#Builtin-Index_bt_letter-A"><b>A</b></a> | |
17345e5a | 14696 | |
a0c0a00f | 14697 | <a class="summary-letter" href="#Builtin-Index_bt_letter-B"><b>B</b></a> |
17345e5a | 14698 | |
a0c0a00f | 14699 | <a class="summary-letter" href="#Builtin-Index_bt_letter-C"><b>C</b></a> |
17345e5a | 14700 | |
a0c0a00f | 14701 | <a class="summary-letter" href="#Builtin-Index_bt_letter-D"><b>D</b></a> |
17345e5a | 14702 | |
a0c0a00f | 14703 | <a class="summary-letter" href="#Builtin-Index_bt_letter-E"><b>E</b></a> |
17345e5a | 14704 | |
a0c0a00f | 14705 | <a class="summary-letter" href="#Builtin-Index_bt_letter-F"><b>F</b></a> |
17345e5a | 14706 | |
a0c0a00f | 14707 | <a class="summary-letter" href="#Builtin-Index_bt_letter-G"><b>G</b></a> |
17345e5a | 14708 | |
a0c0a00f | 14709 | <a class="summary-letter" href="#Builtin-Index_bt_letter-H"><b>H</b></a> |
17345e5a | 14710 | |
a0c0a00f | 14711 | <a class="summary-letter" href="#Builtin-Index_bt_letter-J"><b>J</b></a> |
17345e5a | 14712 | |
a0c0a00f | 14713 | <a class="summary-letter" href="#Builtin-Index_bt_letter-K"><b>K</b></a> |
17345e5a | 14714 | |
a0c0a00f | 14715 | <a class="summary-letter" href="#Builtin-Index_bt_letter-L"><b>L</b></a> |
17345e5a | 14716 | |
a0c0a00f | 14717 | <a class="summary-letter" href="#Builtin-Index_bt_letter-M"><b>M</b></a> |
17345e5a | 14718 | |
a0c0a00f | 14719 | <a class="summary-letter" href="#Builtin-Index_bt_letter-P"><b>P</b></a> |
17345e5a | 14720 | |
a0c0a00f | 14721 | <a class="summary-letter" href="#Builtin-Index_bt_letter-R"><b>R</b></a> |
17345e5a | 14722 | |
a0c0a00f | 14723 | <a class="summary-letter" href="#Builtin-Index_bt_letter-S"><b>S</b></a> |
17345e5a | 14724 | |
a0c0a00f | 14725 | <a class="summary-letter" href="#Builtin-Index_bt_letter-T"><b>T</b></a> |
17345e5a | 14726 | |
a0c0a00f | 14727 | <a class="summary-letter" href="#Builtin-Index_bt_letter-U"><b>U</b></a> |
17345e5a | 14728 | |
a0c0a00f | 14729 | <a class="summary-letter" href="#Builtin-Index_bt_letter-W"><b>W</b></a> |
17345e5a | 14730 | |
a0c0a00f CR |
14731 | </td></tr></table> |
14732 | ||
14733 | <hr> | |
14734 | <a name="Reserved-Word-Index"></a> | |
14735 | <div class="header"> | |
14736 | <p> | |
14737 | Next: <a href="#Variable-Index" accesskey="n" rel="next">Variable Index</a>, Previous: <a href="#Builtin-Index" accesskey="p" rel="prev">Builtin Index</a>, Up: <a href="#Indexes" accesskey="u" rel="up">Indexes</a> [<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: </th><td><a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-1"><b>!</b></a> | |
17345e5a | 14742 | |
a0c0a00f | 14743 | <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-2"><b>[</b></a> |
17345e5a | 14744 | |
a0c0a00f | 14745 | <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-3"><b>]</b></a> |
17345e5a | 14746 | |
a0c0a00f | 14747 | <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-4"><b>{</b></a> |
17345e5a | 14748 | |
a0c0a00f | 14749 | <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-5"><b>}</b></a> |
17345e5a | 14750 | |
a0c0a00f CR |
14751 | <br> |
14752 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-C"><b>C</b></a> | |
14753 | | |
14754 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-D"><b>D</b></a> | |
14755 | | |
14756 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-E"><b>E</b></a> | |
14757 | | |
14758 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-F"><b>F</b></a> | |
14759 | | |
14760 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-I"><b>I</b></a> | |
14761 | | |
14762 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-S"><b>S</b></a> | |
14763 | | |
14764 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-T"><b>T</b></a> | |
14765 | | |
14766 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-U"><b>U</b></a> | |
14767 | | |
14768 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-W"><b>W</b></a> | |
14769 | | |
14770 | </td></tr></table> | |
14771 | <table class="index-rw" border="0"> | |
14772 | <tr><td></td><th align="left">Index Entry</th><td> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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: </th><td><a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-1"><b>!</b></a> | |
14825 | | |
14826 | <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-2"><b>[</b></a> | |
14827 | | |
14828 | <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-3"><b>]</b></a> | |
14829 | | |
14830 | <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-4"><b>{</b></a> | |
14831 | | |
14832 | <a class="summary-letter" href="#Reserved-Word-Index_rw_symbol-5"><b>}</b></a> | |
17345e5a | 14833 | |
a0c0a00f CR |
14834 | <br> |
14835 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-C"><b>C</b></a> | |
17345e5a | 14836 | |
a0c0a00f | 14837 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-D"><b>D</b></a> |
17345e5a | 14838 | |
a0c0a00f | 14839 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-E"><b>E</b></a> |
17345e5a | 14840 | |
a0c0a00f | 14841 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-F"><b>F</b></a> |
17345e5a | 14842 | |
a0c0a00f | 14843 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-I"><b>I</b></a> |
17345e5a | 14844 | |
a0c0a00f | 14845 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-S"><b>S</b></a> |
17345e5a | 14846 | |
a0c0a00f | 14847 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-T"><b>T</b></a> |
17345e5a | 14848 | |
a0c0a00f | 14849 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-U"><b>U</b></a> |
17345e5a | 14850 | |
a0c0a00f | 14851 | <a class="summary-letter" href="#Reserved-Word-Index_rw_letter-W"><b>W</b></a> |
17345e5a | 14852 | |
a0c0a00f CR |
14853 | </td></tr></table> |
14854 | ||
14855 | <hr> | |
14856 | <a name="Variable-Index"></a> | |
14857 | <div class="header"> | |
14858 | <p> | |
14859 | Next: <a href="#Function-Index" accesskey="n" rel="next">Function Index</a>, Previous: <a href="#Reserved-Word-Index" accesskey="p" rel="prev">Reserved Word Index</a>, Up: <a href="#Indexes" accesskey="u" rel="up">Indexes</a> [<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: </th><td><a class="summary-letter" href="#Variable-Index_vr_symbol-1"><b>!</b></a> | |
17345e5a | 14864 | |
a0c0a00f | 14865 | <a class="summary-letter" href="#Variable-Index_vr_symbol-2"><b>#</b></a> |
17345e5a | 14866 | |
a0c0a00f | 14867 | <a class="summary-letter" href="#Variable-Index_vr_symbol-3"><b>$</b></a> |
17345e5a | 14868 | |
a0c0a00f | 14869 | <a class="summary-letter" href="#Variable-Index_vr_symbol-4"><b>*</b></a> |
17345e5a | 14870 | |
a0c0a00f | 14871 | <a class="summary-letter" href="#Variable-Index_vr_symbol-5"><b>-</b></a> |
17345e5a | 14872 | |
a0c0a00f | 14873 | <a class="summary-letter" href="#Variable-Index_vr_symbol-6"><b>0</b></a> |
17345e5a | 14874 | |
a0c0a00f | 14875 | <a class="summary-letter" href="#Variable-Index_vr_symbol-7"><b>?</b></a> |
17345e5a | 14876 | |
a0c0a00f | 14877 | <a class="summary-letter" href="#Variable-Index_vr_symbol-8"><b>@</b></a> |
17345e5a | 14878 | |
a0c0a00f | 14879 | <a class="summary-letter" href="#Variable-Index_vr_symbol-9"><b>_</b></a> |
17345e5a | 14880 | |
a0c0a00f CR |
14881 | <br> |
14882 | <a class="summary-letter" href="#Variable-Index_vr_letter-A"><b>A</b></a> | |
14883 | | |
14884 | <a class="summary-letter" href="#Variable-Index_vr_letter-B"><b>B</b></a> | |
14885 | | |
14886 | <a class="summary-letter" href="#Variable-Index_vr_letter-C"><b>C</b></a> | |
14887 | | |
14888 | <a class="summary-letter" href="#Variable-Index_vr_letter-D"><b>D</b></a> | |
14889 | | |
14890 | <a class="summary-letter" href="#Variable-Index_vr_letter-E"><b>E</b></a> | |
14891 | | |
14892 | <a class="summary-letter" href="#Variable-Index_vr_letter-F"><b>F</b></a> | |
14893 | | |
14894 | <a class="summary-letter" href="#Variable-Index_vr_letter-G"><b>G</b></a> | |
14895 | | |
14896 | <a class="summary-letter" href="#Variable-Index_vr_letter-H"><b>H</b></a> | |
14897 | | |
14898 | <a class="summary-letter" href="#Variable-Index_vr_letter-I"><b>I</b></a> | |
14899 | | |
14900 | <a class="summary-letter" href="#Variable-Index_vr_letter-K"><b>K</b></a> | |
14901 | | |
14902 | <a class="summary-letter" href="#Variable-Index_vr_letter-L"><b>L</b></a> | |
14903 | | |
14904 | <a class="summary-letter" href="#Variable-Index_vr_letter-M"><b>M</b></a> | |
14905 | | |
14906 | <a class="summary-letter" href="#Variable-Index_vr_letter-O"><b>O</b></a> | |
14907 | | |
14908 | <a class="summary-letter" href="#Variable-Index_vr_letter-P"><b>P</b></a> | |
14909 | | |
14910 | <a class="summary-letter" href="#Variable-Index_vr_letter-R"><b>R</b></a> | |
14911 | | |
14912 | <a class="summary-letter" href="#Variable-Index_vr_letter-S"><b>S</b></a> | |
14913 | | |
14914 | <a class="summary-letter" href="#Variable-Index_vr_letter-T"><b>T</b></a> | |
14915 | | |
14916 | <a class="summary-letter" href="#Variable-Index_vr_letter-U"><b>U</b></a> | |
14917 | | |
14918 | <a class="summary-letter" href="#Variable-Index_vr_letter-V"><b>V</b></a> | |
14919 | | |
14920 | </td></tr></table> | |
14921 | <table class="index-vr" border="0"> | |
14922 | <tr><td></td><th align="left">Index Entry</th><td> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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: </th><td><a class="summary-letter" href="#Variable-Index_vr_symbol-1"><b>!</b></a> | |
15148 | | |
15149 | <a class="summary-letter" href="#Variable-Index_vr_symbol-2"><b>#</b></a> | |
15150 | | |
15151 | <a class="summary-letter" href="#Variable-Index_vr_symbol-3"><b>$</b></a> | |
15152 | | |
15153 | <a class="summary-letter" href="#Variable-Index_vr_symbol-4"><b>*</b></a> | |
15154 | | |
15155 | <a class="summary-letter" href="#Variable-Index_vr_symbol-5"><b>-</b></a> | |
15156 | | |
15157 | <a class="summary-letter" href="#Variable-Index_vr_symbol-6"><b>0</b></a> | |
15158 | | |
15159 | <a class="summary-letter" href="#Variable-Index_vr_symbol-7"><b>?</b></a> | |
15160 | | |
15161 | <a class="summary-letter" href="#Variable-Index_vr_symbol-8"><b>@</b></a> | |
15162 | | |
15163 | <a class="summary-letter" href="#Variable-Index_vr_symbol-9"><b>_</b></a> | |
17345e5a | 15164 | |
a0c0a00f CR |
15165 | <br> |
15166 | <a class="summary-letter" href="#Variable-Index_vr_letter-A"><b>A</b></a> | |
17345e5a | 15167 | |
a0c0a00f | 15168 | <a class="summary-letter" href="#Variable-Index_vr_letter-B"><b>B</b></a> |
17345e5a | 15169 | |
a0c0a00f | 15170 | <a class="summary-letter" href="#Variable-Index_vr_letter-C"><b>C</b></a> |
17345e5a | 15171 | |
a0c0a00f | 15172 | <a class="summary-letter" href="#Variable-Index_vr_letter-D"><b>D</b></a> |
17345e5a | 15173 | |
a0c0a00f | 15174 | <a class="summary-letter" href="#Variable-Index_vr_letter-E"><b>E</b></a> |
17345e5a | 15175 | |
a0c0a00f | 15176 | <a class="summary-letter" href="#Variable-Index_vr_letter-F"><b>F</b></a> |
17345e5a | 15177 | |
a0c0a00f | 15178 | <a class="summary-letter" href="#Variable-Index_vr_letter-G"><b>G</b></a> |
17345e5a | 15179 | |
a0c0a00f | 15180 | <a class="summary-letter" href="#Variable-Index_vr_letter-H"><b>H</b></a> |
17345e5a | 15181 | |
a0c0a00f | 15182 | <a class="summary-letter" href="#Variable-Index_vr_letter-I"><b>I</b></a> |
17345e5a | 15183 | |
a0c0a00f | 15184 | <a class="summary-letter" href="#Variable-Index_vr_letter-K"><b>K</b></a> |
17345e5a | 15185 | |
a0c0a00f | 15186 | <a class="summary-letter" href="#Variable-Index_vr_letter-L"><b>L</b></a> |
17345e5a | 15187 | |
a0c0a00f | 15188 | <a class="summary-letter" href="#Variable-Index_vr_letter-M"><b>M</b></a> |
17345e5a | 15189 | |
a0c0a00f | 15190 | <a class="summary-letter" href="#Variable-Index_vr_letter-O"><b>O</b></a> |
17345e5a | 15191 | |
a0c0a00f | 15192 | <a class="summary-letter" href="#Variable-Index_vr_letter-P"><b>P</b></a> |
17345e5a | 15193 | |
a0c0a00f | 15194 | <a class="summary-letter" href="#Variable-Index_vr_letter-R"><b>R</b></a> |
17345e5a | 15195 | |
a0c0a00f | 15196 | <a class="summary-letter" href="#Variable-Index_vr_letter-S"><b>S</b></a> |
17345e5a | 15197 | |
a0c0a00f | 15198 | <a class="summary-letter" href="#Variable-Index_vr_letter-T"><b>T</b></a> |
17345e5a | 15199 | |
a0c0a00f | 15200 | <a class="summary-letter" href="#Variable-Index_vr_letter-U"><b>U</b></a> |
17345e5a | 15201 | |
a0c0a00f | 15202 | <a class="summary-letter" href="#Variable-Index_vr_letter-V"><b>V</b></a> |
17345e5a | 15203 | |
a0c0a00f CR |
15204 | </td></tr></table> |
15205 | ||
15206 | <hr> | |
15207 | <a name="Function-Index"></a> | |
15208 | <div class="header"> | |
15209 | <p> | |
15210 | Next: <a href="#Concept-Index" accesskey="n" rel="next">Concept Index</a>, Previous: <a href="#Variable-Index" accesskey="p" rel="prev">Variable Index</a>, Up: <a href="#Indexes" accesskey="u" rel="up">Indexes</a> [<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: </th><td><a class="summary-letter" href="#Function-Index_fn_letter-A"><b>A</b></a> | |
17345e5a | 15215 | |
a0c0a00f | 15216 | <a class="summary-letter" href="#Function-Index_fn_letter-B"><b>B</b></a> |
17345e5a | 15217 | |
a0c0a00f | 15218 | <a class="summary-letter" href="#Function-Index_fn_letter-C"><b>C</b></a> |
17345e5a | 15219 | |
a0c0a00f | 15220 | <a class="summary-letter" href="#Function-Index_fn_letter-D"><b>D</b></a> |
17345e5a | 15221 | |
a0c0a00f | 15222 | <a class="summary-letter" href="#Function-Index_fn_letter-E"><b>E</b></a> |
17345e5a | 15223 | |
a0c0a00f | 15224 | <a class="summary-letter" href="#Function-Index_fn_letter-F"><b>F</b></a> |
17345e5a | 15225 | |
a0c0a00f | 15226 | <a class="summary-letter" href="#Function-Index_fn_letter-G"><b>G</b></a> |
17345e5a | 15227 | |
a0c0a00f CR |
15228 | <a class="summary-letter" href="#Function-Index_fn_letter-H"><b>H</b></a> |
15229 | | |
15230 | <a class="summary-letter" href="#Function-Index_fn_letter-I"><b>I</b></a> | |
15231 | | |
15232 | <a class="summary-letter" href="#Function-Index_fn_letter-K"><b>K</b></a> | |
15233 | | |
15234 | <a class="summary-letter" href="#Function-Index_fn_letter-M"><b>M</b></a> | |
15235 | | |
15236 | <a class="summary-letter" href="#Function-Index_fn_letter-N"><b>N</b></a> | |
15237 | | |
15238 | <a class="summary-letter" href="#Function-Index_fn_letter-O"><b>O</b></a> | |
15239 | | |
15240 | <a class="summary-letter" href="#Function-Index_fn_letter-P"><b>P</b></a> | |
15241 | | |
15242 | <a class="summary-letter" href="#Function-Index_fn_letter-Q"><b>Q</b></a> | |
15243 | | |
15244 | <a class="summary-letter" href="#Function-Index_fn_letter-R"><b>R</b></a> | |
15245 | | |
15246 | <a class="summary-letter" href="#Function-Index_fn_letter-S"><b>S</b></a> | |
15247 | | |
15248 | <a class="summary-letter" href="#Function-Index_fn_letter-T"><b>T</b></a> | |
15249 | | |
15250 | <a class="summary-letter" href="#Function-Index_fn_letter-U"><b>U</b></a> | |
15251 | | |
15252 | <a class="summary-letter" href="#Function-Index_fn_letter-Y"><b>Y</b></a> | |
15253 | | |
15254 | </td></tr></table> | |
15255 | <table class="index-fn" border="0"> | |
15256 | <tr><td></td><th align="left">Index Entry</th><td> </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> </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> </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> </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> </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> </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> </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> </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> </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-<)</code></a>:</td><td> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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>, … <kbd>M--</kbd>)</code></a>:</td><td> </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> </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>, …)</code></a>:</td><td> </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> </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> </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> </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> </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> </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> </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> </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> </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->)</code></a>:</td><td> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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, !, …)</code></a>:</td><td> </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> </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> </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> </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> </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> </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> </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> </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> </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-&)</code></a>:</td><td> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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: </th><td><a class="summary-letter" href="#Function-Index_fn_letter-A"><b>A</b></a> | |
15410 | | |
15411 | <a class="summary-letter" href="#Function-Index_fn_letter-B"><b>B</b></a> | |
15412 | | |
15413 | <a class="summary-letter" href="#Function-Index_fn_letter-C"><b>C</b></a> | |
15414 | | |
15415 | <a class="summary-letter" href="#Function-Index_fn_letter-D"><b>D</b></a> | |
15416 | | |
15417 | <a class="summary-letter" href="#Function-Index_fn_letter-E"><b>E</b></a> | |
15418 | | |
15419 | <a class="summary-letter" href="#Function-Index_fn_letter-F"><b>F</b></a> | |
15420 | | |
15421 | <a class="summary-letter" href="#Function-Index_fn_letter-G"><b>G</b></a> | |
15422 | | |
15423 | <a class="summary-letter" href="#Function-Index_fn_letter-H"><b>H</b></a> | |
15424 | | |
15425 | <a class="summary-letter" href="#Function-Index_fn_letter-I"><b>I</b></a> | |
15426 | | |
15427 | <a class="summary-letter" href="#Function-Index_fn_letter-K"><b>K</b></a> | |
15428 | | |
15429 | <a class="summary-letter" href="#Function-Index_fn_letter-M"><b>M</b></a> | |
15430 | | |
15431 | <a class="summary-letter" href="#Function-Index_fn_letter-N"><b>N</b></a> | |
15432 | | |
15433 | <a class="summary-letter" href="#Function-Index_fn_letter-O"><b>O</b></a> | |
15434 | | |
15435 | <a class="summary-letter" href="#Function-Index_fn_letter-P"><b>P</b></a> | |
15436 | | |
15437 | <a class="summary-letter" href="#Function-Index_fn_letter-Q"><b>Q</b></a> | |
15438 | | |
15439 | <a class="summary-letter" href="#Function-Index_fn_letter-R"><b>R</b></a> | |
15440 | | |
15441 | <a class="summary-letter" href="#Function-Index_fn_letter-S"><b>S</b></a> | |
15442 | | |
15443 | <a class="summary-letter" href="#Function-Index_fn_letter-T"><b>T</b></a> | |
15444 | | |
15445 | <a class="summary-letter" href="#Function-Index_fn_letter-U"><b>U</b></a> | |
15446 | | |
15447 | <a class="summary-letter" href="#Function-Index_fn_letter-Y"><b>Y</b></a> | |
15448 | | |
15449 | </td></tr></table> | |
15450 | ||
15451 | <hr> | |
15452 | <a name="Concept-Index"></a> | |
15453 | <div class="header"> | |
15454 | <p> | |
15455 | Previous: <a href="#Function-Index" accesskey="p" rel="prev">Function Index</a>, Up: <a href="#Indexes" accesskey="u" rel="up">Indexes</a> [<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: </th><td><a class="summary-letter" href="#Concept-Index_cp_letter-A"><b>A</b></a> | |
15460 | | |
15461 | <a class="summary-letter" href="#Concept-Index_cp_letter-B"><b>B</b></a> | |
15462 | | |
15463 | <a class="summary-letter" href="#Concept-Index_cp_letter-C"><b>C</b></a> | |
15464 | | |
15465 | <a class="summary-letter" href="#Concept-Index_cp_letter-D"><b>D</b></a> | |
15466 | | |
15467 | <a class="summary-letter" href="#Concept-Index_cp_letter-E"><b>E</b></a> | |
15468 | | |
15469 | <a class="summary-letter" href="#Concept-Index_cp_letter-F"><b>F</b></a> | |
15470 | | |
15471 | <a class="summary-letter" href="#Concept-Index_cp_letter-H"><b>H</b></a> | |
15472 | | |
15473 | <a class="summary-letter" href="#Concept-Index_cp_letter-I"><b>I</b></a> | |
15474 | | |
15475 | <a class="summary-letter" href="#Concept-Index_cp_letter-J"><b>J</b></a> | |
15476 | | |
15477 | <a class="summary-letter" href="#Concept-Index_cp_letter-K"><b>K</b></a> | |
15478 | | |
15479 | <a class="summary-letter" href="#Concept-Index_cp_letter-L"><b>L</b></a> | |
15480 | | |
15481 | <a class="summary-letter" href="#Concept-Index_cp_letter-M"><b>M</b></a> | |
15482 | | |
15483 | <a class="summary-letter" href="#Concept-Index_cp_letter-N"><b>N</b></a> | |
15484 | | |
15485 | <a class="summary-letter" href="#Concept-Index_cp_letter-O"><b>O</b></a> | |
15486 | | |
15487 | <a class="summary-letter" href="#Concept-Index_cp_letter-P"><b>P</b></a> | |
15488 | | |
15489 | <a class="summary-letter" href="#Concept-Index_cp_letter-Q"><b>Q</b></a> | |
15490 | | |
15491 | <a class="summary-letter" href="#Concept-Index_cp_letter-R"><b>R</b></a> | |
15492 | | |
15493 | <a class="summary-letter" href="#Concept-Index_cp_letter-S"><b>S</b></a> | |
15494 | | |
15495 | <a class="summary-letter" href="#Concept-Index_cp_letter-T"><b>T</b></a> | |
15496 | | |
15497 | <a class="summary-letter" href="#Concept-Index_cp_letter-V"><b>V</b></a> | |
15498 | | |
15499 | <a class="summary-letter" href="#Concept-Index_cp_letter-W"><b>W</b></a> | |
15500 | | |
15501 | <a class="summary-letter" href="#Concept-Index_cp_letter-Y"><b>Y</b></a> | |
15502 | | |
15503 | </td></tr></table> | |
15504 | <table class="index-cp" border="0"> | |
15505 | <tr><td></td><th align="left">Index Entry</th><td> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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: </th><td><a class="summary-letter" href="#Concept-Index_cp_letter-A"><b>A</b></a> | |
15671 | | |
15672 | <a class="summary-letter" href="#Concept-Index_cp_letter-B"><b>B</b></a> | |
15673 | | |
15674 | <a class="summary-letter" href="#Concept-Index_cp_letter-C"><b>C</b></a> | |
15675 | | |
15676 | <a class="summary-letter" href="#Concept-Index_cp_letter-D"><b>D</b></a> | |
15677 | | |
15678 | <a class="summary-letter" href="#Concept-Index_cp_letter-E"><b>E</b></a> | |
15679 | | |
15680 | <a class="summary-letter" href="#Concept-Index_cp_letter-F"><b>F</b></a> | |
15681 | | |
15682 | <a class="summary-letter" href="#Concept-Index_cp_letter-H"><b>H</b></a> | |
15683 | | |
15684 | <a class="summary-letter" href="#Concept-Index_cp_letter-I"><b>I</b></a> | |
15685 | | |
15686 | <a class="summary-letter" href="#Concept-Index_cp_letter-J"><b>J</b></a> | |
15687 | | |
15688 | <a class="summary-letter" href="#Concept-Index_cp_letter-K"><b>K</b></a> | |
15689 | | |
15690 | <a class="summary-letter" href="#Concept-Index_cp_letter-L"><b>L</b></a> | |
15691 | | |
15692 | <a class="summary-letter" href="#Concept-Index_cp_letter-M"><b>M</b></a> | |
15693 | | |
15694 | <a class="summary-letter" href="#Concept-Index_cp_letter-N"><b>N</b></a> | |
15695 | | |
15696 | <a class="summary-letter" href="#Concept-Index_cp_letter-O"><b>O</b></a> | |
15697 | | |
15698 | <a class="summary-letter" href="#Concept-Index_cp_letter-P"><b>P</b></a> | |
15699 | | |
15700 | <a class="summary-letter" href="#Concept-Index_cp_letter-Q"><b>Q</b></a> | |
15701 | | |
15702 | <a class="summary-letter" href="#Concept-Index_cp_letter-R"><b>R</b></a> | |
15703 | | |
15704 | <a class="summary-letter" href="#Concept-Index_cp_letter-S"><b>S</b></a> | |
15705 | | |
15706 | <a class="summary-letter" href="#Concept-Index_cp_letter-T"><b>T</b></a> | |
15707 | | |
15708 | <a class="summary-letter" href="#Concept-Index_cp_letter-V"><b>V</b></a> | |
15709 | | |
15710 | <a class="summary-letter" href="#Concept-Index_cp_letter-W"><b>W</b></a> | |
15711 | | |
15712 | <a class="summary-letter" href="#Concept-Index_cp_letter-Y"><b>Y</b></a> | |
15713 | | |
15714 | </td></tr></table> | |
15715 | ||
15716 | <hr> | |
15717 | ||
15718 | ||
15719 | ||
15720 | </body> | |
15721 | </html> |