-This is the Bash FAQ, version 2.13, for Bash version 2.02.
+This is the Bash FAQ, version 3.0, for Bash version 2.03.
This document contains a set of frequently-asked questions concerning
Bash, the GNU Bourne-Again Shell. Bash is a freely-available command
Section A: The Basics
-1) What is it?
-2) What's the latest version?
-3) Where can I get it?
-4) On what machines will bash run?
-5) Will bash run on operating systems other than Unix?
-6) How can I build bash with gcc?
-7) How can I make bash my login shell?
-8) I just changed my login shell to bash, and now I can't FTP into my
- machine. Why not?
-9) What's the `POSIX 1003.2 standard'?
-10) What is the bash `posix mode'?
+A1) What is it?
+A2) What's the latest version?
+A3) Where can I get it?
+A4) On what machines will bash run?
+A5) Will bash run on operating systems other than Unix?
+A6) How can I build bash with gcc?
+A7) How can I make bash my login shell?
+A8) I just changed my login shell to bash, and now I can't FTP into my
+ machine. Why not?
+A9) What's the `POSIX 1003.2 standard'?
+A10) What is the bash `posix mode'?
Section B: The latest version
-11) What's new in version 2.02?
-12) Are there any user-visible incompatibilities between bash-2.02 and
+B1) What's new in version 2.03?
+B2) Are there any user-visible incompatibilities between bash-2.03 and
bash-1.14.7?
Section C: Differences from other Unix shells
-13) How does bash differ from sh, the Bourne shell?
-14) How does bash differ from the Korn shell, version ksh88?
-15) Which new features in ksh-93 are not in bash, and which are?
+C1) How does bash differ from sh, the Bourne shell?
+C2) How does bash differ from the Korn shell, version ksh88?
+C3) Which new features in ksh-93 are not in bash, and which are?
Section D: Why does bash do some things differently than other Unix shells?
-16) Why does bash run a different version of `command' than
+D1) Why does bash run a different version of `command' than
`which command' says it will?
-17) Why doesn't bash treat brace expansions exactly like csh?
-18) Why doesn't bash have csh variable modifiers?
-19) How can I make my csh aliases work when I convert to bash?
-20) How can I pipe standard output and standard error from one command to
+D2) Why doesn't bash treat brace expansions exactly like csh?
+D3) Why doesn't bash have csh variable modifiers?
+D4) How can I make my csh aliases work when I convert to bash?
+D5) How can I pipe standard output and standard error from one command to
another, like csh does with `|&'?
-21) Now that I've converted from ksh to bash, are there equivalents to
+D6) Now that I've converted from ksh to bash, are there equivalents to
ksh features like autoloaded functions and the `whence' command?
Section E: How can I get bash to do certain things, and why does bash do
things the way it does?
-22) Why is the bash builtin `test' slightly different from /bin/test?
-23) Why does bash sometimes say `Broken pipe'?
-24) How can I get bash to read and display eight-bit characters?
-25) How do I write a function `x' to replace builtin command `x', but
+E1) Why is the bash builtin `test' slightly different from /bin/test?
+E2) Why does bash sometimes say `Broken pipe'?
+E3) How can I get bash to read and display eight-bit characters?
+E4) How do I write a function `x' to replace builtin command `x', but
still invoke the command from within the function?
-26) When I have terminal escape sequences in my prompt, why does bash
+E5) When I have terminal escape sequences in my prompt, why does bash
wrap lines at the wrong column?
-27) How can I find the value of a shell variable whose name is the value
+E6) How can I find the value of a shell variable whose name is the value
of another shell variable?
-28) If I pipe the output of a command into `read variable', why doesn't
+E7) If I pipe the output of a command into `read variable', why doesn't
the output show up in $variable when the read command finishes?
-29) I have a bunch of shell scripts that use backslash-escaped characters
+E8) I have a bunch of shell scripts that use backslash-escaped characters
in arguments to `echo'. Bash doesn't interpret these characters. Why
not, and how can I make it understand them?
-30) Why doesn't a while or for loop get suspended when I type ^Z?
-31) How can I make the bash `time' reserved word print timing output that
- looks like the output from my system's /usr/bin/time?
+E9) Why doesn't a while or for loop get suspended when I type ^Z?
+E10) How can I make the bash `time' reserved word print timing output that
+ looks like the output from my system's /usr/bin/time?
Section F: Things to watch out for on certain Unix versions
-32) Why can't I use command line editing in my `cmdtool'?
-33) I built bash on Solaris 2. Why do globbing expansions and filename
+F1) Why can't I use command line editing in my `cmdtool'?
+F2) I built bash on Solaris 2. Why do globbing expansions and filename
completion chop off the first few characters of each filename?
-34) Why does bash dump core after I interrupt username completion or
+F3) Why does bash dump core after I interrupt username completion or
`~user' tilde expansion on a machine running NIS?
-35) I'm running SVR4.2. Why is the line erased every time I type `@'?
-36) Why does bash report syntax errors when my C News scripts use a
+F4) I'm running SVR4.2. Why is the line erased every time I type `@'?
+F5) Why does bash report syntax errors when my C News scripts use a
redirection before a subshell command?
Section G: Where do I go from here?
-37) How do I report bugs in bash, and where should I look for fixes and
+G1) How do I report bugs in bash, and where should I look for fixes and
advice?
-38) What kind of bash documentation is there?
-39) What's coming in future versions?
-40) What's on the bash `wish list'?
-41) When will the next release appear?
+G2) What kind of bash documentation is there?
+G3) What's coming in future versions?
+G4) What's on the bash `wish list'?
+G5) When will the next release appear?
----------
Section A: The Basics
-1) What is it?
+A1) What is it?
Bash is a Unix command interpreter (shell). It is an implementation of
the Posix 1003.2 shell standard, and resembles the Korn and System V
Foundation. The current developer and maintainer is Chet Ramey
of Case Western Reserve University.
-2) What's the latest version?
+A2) What's the latest version?
-The latest version is 2.02, first made available on Monday, 20 April, 1998.
+The latest version is 2.03, first made available on Friday, 19 Feburary 1999.
-3) Where can I get it?
+A3) Where can I get it?
Bash is the GNU project's shell, and so is available from the
-master GNU archive site, prep.ai.mit.edu, and its mirrors. The
+master GNU archive site, ftp.gnu.org, and its mirrors. The
latest version is also available for FTP from ftp.cwru.edu.
-The following URLs tell how to get version 2.02:
+The following URLs tell how to get version 2.03:
-ftp://prep.ai.mit.edu/pub/gnu/bash-2.02.tar.gz
-ftp://ftp.cwru.edu/pub/bash/bash-2.02.tar.gz
+ftp://ftp.gnu.org/pub/gnu/bash-2.03.tar.gz
+ftp://ftp.cwru.edu/pub/bash/bash-2.03.tar.gz
Formatted versions of the documentation are available with the URLs:
-ftp://prep.ai.mit.edu/pub/gnu/bash-doc-2.02.tar.gz
-ftp://ftp.cwru.edu/pub/bash/bash-doc-2.02.tar.gz
+ftp://ftp.gnu.org/pub/gnu/bash-doc-2.03.tar.gz
+ftp://ftp.cwru.edu/pub/bash/bash-doc-2.03.tar.gz
-4) On what machines will bash run?
+A4) On what machines will bash run?
Bash has been ported to nearly every version of UNIX. All you
should have to do to build it on a machine for which a port
More information appears in the file `INSTALL' in the distribution.
-5) Will bash run on operating systems other than Unix?
+A5) Will bash run on operating systems other than Unix?
Configuration specifics for Unix-like systems such as QNX and
-LynxOS are included in the distribution. Bash-2.02 should
+LynxOS are included in the distribution. Bash-2.03 should
compile and run on Minix 2.0 (patches were contributed), but I
don't believe anyone has built bash-2.x on earlier Minix versions
yet.
http://www.cygnus.com/misc/gnu-win32
-Cygnus has ported bash-1.14.7, and their port is part of the current
-gnu-win32 release. Cygnus has also done a port of bash-2.01 to the
-GNU-Win32 environment, and it should be available as part of their next
-release.
+Cygnus originally ported bash-1.14.7, and that port was part of their
+early GNU-Win32 releases. Cygnus has also done a port of bash-2.01 to the
+GNU-Win32 environment, and it is available as part of their current
+release. (They may have upgraded by now.)
-Bash-2.02 should require no local Cygnus changes to build and run under
+Bash-2.03 should require no local Cygnus changes to build and run under
GNU-WIN32.
The Cygnus port works only on Intel machines. There is a port of bash
ftp://ftp.gnustep.org//pub/win32/bash-alpha-nt-1.01.tar.gz
-Softway Systems has ported bash-2.01.1 to their Interix (nee OpenNT)
+Softway Systems has ported bash-2.01 to their Interix (nee OpenNT)
system, a Unix subsystem for NT that replaces the Microsoft POSIX
subsystem. Check out http://www.interix.com for more information.
+Some support for Interix has been incorporated into bash, beginning
+with Bash-2.03. It should be easier to build bash on Interix now,
+but Interix users should fetch
+
+ftp://ftp.interix.com/pub/tw/unsup/bash.diffs.tar.gz
+
+and read the README.OpenNT file in that archive. It will detail the
+arguments configure needs to build on Interix. A configure cache
+file for Interix is in the bash distribution in cross-build/opennt.cache;
+copy that to `config.cache' before starting configure.
D. J. Delorie has ported bash-1.14.7 to run under MS-DOS, as part of
the DJGPP project. For more information on the project, see
I haven't looked at either, but the second appears to be a binary-only
distribution. Beware.
-6) How can I build bash with gcc?
+A6) How can I build bash with gcc?
Bash configures to use gcc by default if it is available. Read the
file INSTALL in the distribution for more information.
-7) How can I make bash my login shell?
+A7) How can I make bash my login shell?
Some machines let you use `chsh' to change your login shell. Other
systems use `passwd -s' or `passwd -e'. If one of these works for
a login shell. Once you have this working, you can copy your initialization
code from ~/.profile to ~/.bash_profile.
-8) I just changed my login shell to bash, and now I can't FTP into my
+A8) I just changed my login shell to bash, and now I can't FTP into my
machine. Why not?
You must add the full pathname to bash to the file /etc/shells. As
Most versions of ftpd use this file to prohibit `special' users
such as `uucp' and `news' from using FTP.
-9) What's the `POSIX 1003.2 standard'?
+A9) What's the `POSIX 1003.2 standard'?
POSIX is a name originally coined by Richard Stallman for a
family of open system standards based on UNIX. There are a
standardized; emacs editing commands were left out due to
objections.
-10) What is the bash `posix mode'?
+A10) What is the bash `posix mode'?
Although bash is an implementation of the POSIX.2 shell
specification, there are areas where the bash default behavior
Section B: The latest version
-11) What's new in version 2.02?
+B1) What's new in version 2.03?
+
+Bash-2.03 has a very few new features, in keeping with the convention
+that odd-numbered releases provide mainly bug fixes. A number of new
+features were added to Readline, mostly at the request of the Cygnus
+folks.
-Bash-2.02 has a number of new features. Here's a short list:
+a new shopt option, `restricted_shell', so that startup files can test
+ whether or not the shell was started in restricted mode
+filename generation is now performed on the words between ( and ) in
+ compound array assignments (this is really a bug fix)
+OLDPWD is now auto-exported, as POSIX.2 requires
+ENV and BASH_ENV are read-only variables in a restricted shell
+Bash may now be linked against an already-installed Readline library,
+ as long as the Readline library is version 4 or newer
+All shells begun with the `--login' option will source the login shell
+ startup files, even if the shell is not interactive
+
+There are lots of changes to the version of the Readline library released
+along with Bash-2.03. For a complete list of the changes, read the file
+CHANGES in the Bash-2.03 distribution.
+
+Bash-2.02 contained the following new features:
a new version of malloc (based on the old GNU malloc code in previous
bash versions) that is more page-oriented, more conservative
lots of code now smaller and faster
test suite greatly expanded
-12) Are there any user-visible incompatibilities between bash-2.02 and
+B2) Are there any user-visible incompatibilities between bash-2.03 and
bash-1.14.7?
-There are a few incompatibilities between version 1.14.7 and version 2.02.
-They are detailed in the file COMPAT in the bash-2.02 distribution.
+There are a few incompatibilities between version 1.14.7 and version 2.03.
+They are detailed in the file COMPAT in the bash-2.03 distribution.
Section C: Differences from other Unix shells
-13) How does bash differ from sh, the Bourne shell?
+C1) How does bash differ from sh, the Bourne shell?
This is a non-comprehensive list of features that differentiate bash
from the SVR4.2 shell. The bash manual page explains these more
bash allows multiple option arguments when invoked (e.g. -x -v);
sh allows only a single option argument (`sh -x -v' attempts
to open a file named `-v', and, on SunOS 4.1.4, dumps core.
- On Solaris 2, sh goes into an infinite loop.)
+ On Solaris 2.4 and earlier versions, sh goes into an infinite
+ loop.)
sh exits a script if any builtin fails; bash exits only if one of
the POSIX.2 `special' builtins fails
-14) How does bash differ from the Korn shell, version ksh88?
+C2) How does bash differ from the Korn shell, version ksh88?
Things bash has or uses that ksh88 does not:
long invocation options
bash has exported functions
bash command search finds functions before builtins
-15) Which new features in ksh-93 are not in bash, and which are?
+C3) Which new features in ksh-93 are not in bash, and which are?
-New things in ksh-93 not in bash-2.02:
+New things in ksh-93 not in bash-2.03:
associative arrays
floating point arithmetic
++, --, comma arithmetic operators
read -t/-d
`.' can execute shell functions
-New things in ksh-93 present in bash-2.02:
+New things in ksh-93 present in bash-2.03:
?: arithmetic operator
expansions: ${!param}, ${param:offset[:len]}, ${param/pat[/str]}
compound array assignment
Section D: Why does bash do some things differently than other Unix shells?
-16) Why does bash run a different version of `command' than
+D1) Why does bash run a different version of `command' than
`which command' says it will?
-`which' is actually a csh script that assumes you're running csh.
-It reads the csh startup files from your home directory and uses
-those to determine which `command' will be invoked. Since bash
-doesn't use any of those startup files, there's a good chance
-that your bash environment differs from your csh environment.
+On many systems, `which' is actually a csh script that assumes
+you're running csh. In tcsh, `which' and its cousin `where'
+are builtins. On other Unix systems, `which' is a perl script
+that uses the PATH environment variable.
+
+The csh script version reads the csh startup files from your
+home directory and uses those to determine which `command' will
+be invoked. Since bash doesn't use any of those startup files,
+there's a good chance that your bash environment differs from
+your csh environment. The bash `type' builtin does everything
+`which' does, and will report correct results for the running
+shell. If you're really wedded to the name `which', try adding
+the following function definition to your .bashrc:
+
+ which()
+ {
+ builtin type -p "$@"
+ }
+
+If you're moving from tcsh and would like to bring `where' along
+as well, use this function:
+
+ where()
+ {
+ builtin type -a "$@"
+ }
-17) Why doesn't bash treat brace expansions exactly like csh?
+D2) Why doesn't bash treat brace expansions exactly like csh?
The only difference between bash and csh brace expansion is that
bash requires a brace expression to contain at least one unquoted
Bash, ksh, zsh, and pd-ksh all implement brace expansion this way.
-18) Why doesn't bash have csh variable modifiers?
+D3) Why doesn't bash have csh variable modifiers?
Posix has specified a more powerful, albeit somewhat more cryptic,
mechanism cribbed from ksh, and bash implements it.
$b:e ${b##*.} xxx
-19) How can I make my csh aliases work when I convert to bash?
+D4) How can I make my csh aliases work when I convert to bash?
Bash uses a different syntax to support aliases than csh does.
The details can be found in the documentation. We have provided
environment, or as `cshtobash ~/.login' to convert your login
environment.
-20) How can I pipe standard output and standard error from one command to
+D5) How can I pipe standard output and standard error from one command to
another, like csh does with `|&'?
Use
file descriptor 1 points to the pipe when it is duplicated onto file
descriptor 2.
-21) Now that I've converted from ksh to bash, are there equivalents to
+D6) Now that I've converted from ksh to bash, are there equivalents to
ksh features like autoloaded functions and the `whence' command?
There are features in ksh-88 that do not have direct bash equivalents.
Section E: How can I get bash to do certain things, and why does bash do
things the way it does?
-22) Why is the bash builtin `test' slightly different from /bin/test?
+E1) Why is the bash builtin `test' slightly different from /bin/test?
The specific example used here is [ ! x -o x ], which is false.
As you can see, the test becomes (not (x or x)), which is false.
-23) Why does bash sometimes say `Broken pipe'?
+E2) Why does bash sometimes say `Broken pipe'?
If a sequence of commands appears in a pipeline, and one of the
reading commands finishes before the writer has finished, the
will print `Broken pipe' to stderr when ps is killed by a
SIGPIPE.
-24) How can I get bash to read and display eight-bit characters?
+You can build a version of bash that will not report SIGPIPE errors
+by uncommenting the definition of DONT_REPORT_SIGPIPE in the file
+config-top.h.
+
+E3) How can I get bash to read and display eight-bit characters?
This is a process requiring several steps.
The `set' commands between the single quotes may also be placed
in ~/.inputrc.
-25) How do I write a function `x' to replace builtin command `x', but
+E4) How do I write a function `x' to replace builtin command `x', but
still invoke the command from within the function?
This is why the `command' and `builtin' builtins exist. The
This could also be written using `command' instead of `builtin';
the version above is marginally more efficient.
-26) When I have terminal escape sequences in my prompt, why does bash
+E5) When I have terminal escape sequences in my prompt, why does bash
wrap lines at the wrong column?
Readline, the line editing library that bash uses, does not know
Use the \[ escape to begin a sequence of non-printing characters,
and the \] escape to signal the end of such a sequence.
-27) How can I find the value of a shell variable whose name is the value
+E6) How can I find the value of a shell variable whose name is the value
of another shell variable?
-Bash-2.02 supports this directly. You can use
+Versions of Bash newer than Bash-2.0 support this directly. You can use
${!var}
The expansion of the quoted portions of this expression will be
deferred until `eval' runs, while the `$#' will be expanded
-before `eval' is executed. In bash-2.02,
+before `eval' is executed. In versions of bash later than bash-2.0,
echo ${!#}
does the same thing.
-28) If I pipe the output of a command into `read variable', why doesn't
+E7) If I pipe the output of a command into `read variable', why doesn't
the output show up in $variable when the read command finishes?
This has to do with the parent-child relationship between Unix
This is the general approach -- in most cases you will not need to
set $IFS to a different value.
-29) I have a bunch of shell scripts that use backslash-escaped characters
+E8) I have a bunch of shell scripts that use backslash-escaped characters
in arguments to `echo'. Bash doesn't interpret these characters. Why
not, and how can I make it understand them?
on. Be aware that this will cause some of the tests run when you
type `make tests' to fail.
-30) Why doesn't a while or for loop get suspended when I type ^Z?
+E9) Why doesn't a while or for loop get suspended when I type ^Z?
This is a consequence of how job control works on Unix. The only
thing that can be suspended is the process group. This is a single
within parentheses, which will force the loop into a subshell that
may be stopped (and subsequently restarted) as a single unit.
-31) How can I make the bash `time' reserved word print timing output that
- looks like the output from my system's /usr/bin/time?
+E10) How can I make the bash `time' reserved word print timing output that
+ looks like the output from my system's /usr/bin/time?
The bash command timing code looks for a variable `TIMEFORMAT' and
uses its value as a format string to decide how to display the
Section F: Things to watch out for on certain Unix versions
-32) Why can't I use command line editing in my `cmdtool'?
+F1) Why can't I use command line editing in my `cmdtool'?
The problem is `cmdtool' and bash fighting over the input. When
scrolling is enabled in a cmdtool window, cmdtool puts the tty in
cmdtool. If this works, you can put the assignment to TERMCAP
in your bashrc file.
-33) I built bash on Solaris 2. Why do globbing expansions and filename
+F2) I built bash on Solaris 2. Why do globbing expansions and filename
completion chop off the first few characters of each filename?
This is the consequence of building bash on SunOS 5 and linking
put /usr/ccs/bin and /opt/SUNWspro/bin into your $PATH before
/usr/ucb.
-34) Why does bash dump core after I interrupt username completion or
+F3) Why does bash dump core after I interrupt username completion or
`~user' tilde expansion on a machine running NIS?
This is a famous and long-standing bug in the SunOS YP (sorry, NIS)
run configure with the `--without-gnu-malloc' option to use
the C library malloc and avoid the problem.
-35) I'm running SVR4.2. Why is the line erased every time I type `@'?
+F4) I'm running SVR4.2. Why is the line erased every time I type `@'?
The `@' character is the default `line kill' character in most
versions of System V, including SVR4.2. You can change this
where the `^' and `U' can be two separate characters.
-36) Why does bash report syntax errors when my C News scripts use a
+F5) Why does bash report syntax errors when my C News scripts use a
redirection before a subshell command?
The actual command in question is something like
commands'. A subshell construct such as the above is one of the shell's
`compound commands'. A redirection may only follow a compound command.
-The file CWRU/sh-redir-hack in the bash-2.02 distribution is an
+The file CWRU/sh-redir-hack in the bash-2.03 distribution is an
(unofficial) patch to parse.y that will modify the grammar to
support this construct. It will not apply with `patch'; you must
modify parse.y by hand. Note that if you apply this, you must
Section G: Where do I go from here?
-37) How do I report bugs in bash, and where should I look for fixes and
+G1) How do I report bugs in bash, and where should I look for fixes and
advice?
Use the `bashbug' script to report bugs. It is built and
template for reporting a problem and automatically includes
information about your configuration and build environment.
-`bashbug' sends its reports to bug-bash@prep.ai.mit.edu, which
+`bashbug' sends its reports to bug-bash@gnu.org, which
is a large mailing list gatewayed to the usenet newsgroup gnu.bash.bug.
Bug fixes, answers to questions, and announcements of new releases
and problems also take place there.
To reach the bash maintainers directly, send mail to
-bash-maintainers@prep.ai.mit.edu.
+bash-maintainers@gnu.org.
-38) What kind of bash documentation is there?
+G2) What kind of bash documentation is there?
First, look in the doc directory in the bash distribution. It should
contain at least the following files:
bash.1 an extensive, thorough Unix-style manual page
builtins.1 a manual page covering just bash builtin commands
-bashref.texi a reference manual in GNU info format
-bash.html an HTML version of the manual page
-bashref.html an HTML version of the reference manual
+bashref.texi a reference manual in GNU tex`info format
+bashref.info an info version of the reference manual
FAQ this file
article.ms text of an article written for The Linux Journal
readline.3 a man page describing readline
-Postscript files created from the above source are available in
-the documentation distribution.
+Postscript, HTML, and ASCII files created from the above source are
+available in the documentation distribution.
There is additional documentation available for anonymous FTP from host
ftp.cwru.edu in the `pub/bash' directory.
The ISBN number is 1-56592-347-2. Look for it in the same fine bookstores
or on the web.
-39) What's coming in future versions?
+G3) What's coming in future versions?
These are features I plan to include in a future version of bash.
a bash debugger (a minimally-tested version is included with bash-2.02)
-Programmable completion a la zsh
+Programmable completion a la zsh/tcsh
-40) What's on the bash `wish list' for future versions?
+G4) What's on the bash `wish list' for future versions?
These are features that may or may not appear in a future version of bash.
the ksh-93 ${!prefix*} and ${!prefix@} operators
arithmetic ++ and -- prefix and postfix operators
date-stamped command history
+a way to bind readline editing key sequences to shell commands
+a mechanism to open network connections and assign them to file descriptors
+ using redirection (like ksh /dev/{tcp,udp})
-41) When will the next release appear?
+G5) When will the next release appear?
-The next version will appear sometime in 1998. Never make
+The next version will appear sometime in 1999. Never make
predictions.
-This document is Copyright 1995, 1996, 1998 by Chester Ramey.
+This document is Copyright 1995-1999 by Chester Ramey.
Permission is hereby granted, without written agreement and
without license or royalty fees, to use, copy, and distribute