1
BASH - The Bourne-Again Shell
3
Bash is the shell, or command language interpreter, that will appear
4
in the GNU operating system. Bash is an sh-compatible shell that
5
incorporates useful features from the Korn shell (ksh) and C shell
6
(csh). It is intended to conform to the IEEE POSIX P1003.2/ISO 9945.2
7
Shell and Tools standard. It offers functional improvements over sh
8
for both programming and interactive use. In addition, most sh scripts
9
can be run by Bash without modification.
11
Bash is quite portable. It uses a configuration system that discovers
12
characteristics of the compilation platform at build time, and may
13
therefore be built on nearly every version of UNIX. Ports to
14
UNIX-like systems such as QNX and Minix and to non-UNIX systems such
15
as OS/2, Windows 95, and Windows NT are available.
17
Bash includes the following features:
19
Editing and Completion
21
Bash offers a command-line editing facility which permits users to
22
edit command lines using familiar emacs or vi-style editing commands.
23
Editing allows corrections to be made without having to erase back
24
to the point of error or start the command line anew. The editing
25
facilities include a feature that allows users to complete command and
28
The Bash line editing library is fully customizable. Users may define
29
their own key bindings -- the action taken when a key is pressed. A
30
number of variables to fine-tune editing behavior are also available.
32
History and Command Re-entry
34
The Bash history feature remembers commands entered to the shell and
35
allows them to be recalled and re-executed. The history list may be
36
of unlimited size. Bash allows users to search for previous commands
37
and reuse portions of those commands when composing new ones. The
38
history list may be saved across shell sessions.
40
Bash allows users to control which commands are saved on the history
45
On systems that support it, Bash provides an interface to the
46
operating system's job control facilities, which allow processes
47
to be suspended and restarted, and moved between the foreground
48
and background. Bash allows users to selectively `forget' about
51
Shell Functions and Aliases
53
These mechanisms are available to bind a user-selected identifier to a
54
list of commands that will be executed when the identifier is used as
55
a command name. Functions allow local variables and recursion, and
56
have access to the environment of the calling shell. Aliases may be
57
used to create a mnemonic for a command name, expand a single word to
58
a complex command, or ensure that a command is called with a basic set
63
Bash-2.0 supports indexed arrays of unlimited size. The subscript for
64
an array is an arithmetic expression. Arrays may be assigned to with
65
a new compound assignment syntax, and several builtins have options to
66
operate on array variables. Bash includes a number of built-in array
71
Bash allows users to perform integer arithmetic in any base from two
72
to sixty-four. Nearly all of the C language arithmetic operators are
73
available with the same syntax and precedence as in C. Arithmetic
74
expansion allows an arithmetic expression to be evaluated and the
75
result substituted into the command line. Shell variables can be used
76
as operands, and the value of an expression may be assigned to a
79
An arithmetic expression may be used as a command; the exit status of
80
the command is the value of the expression.
84
There is a new quoting syntax that allows backslash-escaped characters
85
in strings to be expanded according to the ANSI C standard.
89
Users' home directories may be expanded using this feature. Words
90
beginning with a tilde may also be expanded to the current or previous
95
Brace expansion is a convenient way to generate a list of strings that
96
share a common prefix or suffix.
98
Substring Capabilities
100
Bash allows new strings to be created by removing leading or trailing
101
substrings from existing variable values, or by specifying a starting
102
offset and length. Portions of variable values may be matched against
103
shell patterns and the matching portion removed or a new value
106
Indirect Variable Expansion
108
Bash makes it easy to find the value of a shell variable whose name is
109
the value of another variable.
111
Expanded I/O Capabilities
113
Bash provides several input and output features not available in sh,
114
including the ability to:
116
o specify a file or file descriptor for both input and output
117
o read from or write to asynchronous processes using named pipes
118
o read lines ending in backslash
119
o display a prompt on the terminal before a read
120
o format menus and interpret responses to them
121
o echo lines exactly as input without escape processing
123
Control of Builtin Commands
125
Bash implements several builtin commands to give users more control
126
over which commands are executed. The enable builtin allows other
127
builtin commands to be selectively enabled or disabled. The command
128
and builtin builtins change the order in which the shell searches for
131
On systems that provide dynamic loading, new builtins may be loaded
132
into a running shell from a shared object file. These new builtins
133
have access to all of the shell facilities.
137
Bash includes a built-in help facility.
139
Shell Optional Behavior
141
There is a great deal of customizable shell behavior. The shopt
142
builtin command provides a unified interface that allows users to
143
alter shell defaults.
147
Bash allows the primary and secondary prompts to be customized by
148
interpreting a number of backslash-escaped special characters.
149
Parameter and variable expansion is also performed on the values of
150
the primary and secondary prompt strings before they are displayed.
154
Bash provides a restricted shell environment. It is also possible to
155
control the execution of setuid/setgid scripts.
159
Bash provides a `directory stack', to which directories may be added
160
and removed. The current directory may be changed to any directory in
161
the stack. It is easy to toggle between two directories in the stack.
162
The directory stack may be saved and restored across different shell
167
Bash is nearly completely conformant to POSIX.2. POSIX mode changes
168
those few areas where the Bash default behavior differs from the
169
standard to match the standard. In POSIX mode, Bash is POSIX.2
174
Bash provides a new quoting syntax that allows strings to be
175
translated according to the current locale. The locale in which the
176
shell itself runs may also be changed, so that the shell messages
177
themselves may be language-specific.
179
The command-line editing facilities allow the input of eight-bit
180
characters, so most of the ISO-8859 family of character sets are
185
Bash allows external commands, shell builtin commands and shell functions
186
to be timed. The format used to display the timing information may be