]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - doc/FAQ
Imported from ../bash-3.0.tar.gz.
[thirdparty/bash.git] / doc / FAQ
diff --git a/doc/FAQ b/doc/FAQ
index b81d339a899dfdb71e64cf75e7d0b90d981cbdc8..c0e902f11c436865bd2b409500e1818f66db7507 100644 (file)
--- a/doc/FAQ
+++ b/doc/FAQ
@@ -1,4 +1,4 @@
-This is the Bash FAQ, version 3.20, for Bash version 2.05b.
+This is the Bash FAQ, version 3.27, for Bash version 3.0.
 
 This document contains a set of frequently-asked questions concerning
 Bash, the GNU Bourne-Again Shell.  Bash is a freely-available command
@@ -31,13 +31,13 @@ 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'?
+A9) What's the `POSIX Shell and Utilities standard'?
 A10) What is the bash `posix mode'?
 
 Section B:  The latest version
 
-B1) What's new in version 2.05b?
-B2) Are there any user-visible incompatibilities between bash-2.05b and
+B1) What's new in version 3.0?
+B2) Are there any user-visible incompatibilities between bash-3.0 and
     bash-1.14.7?
 
 Section C:  Differences from other Unix shells
@@ -75,6 +75,9 @@ E8) Why does the arithmetic evaluation code complain about `08'?
 E9) Why does the pattern matching expression [A-Z]* match files beginning
     with every letter except `z'?
 E10) Why does `cd //' leave $PWD as `//'?
+E11) If I resize my xterm while another program is running, why doesn't bash
+     notice the change?
+E12) Why don't negative offsets in substring expansion work like I expect?
 
 Section F:  Things to watch out for on certain Unix versions
 
@@ -137,30 +140,29 @@ of Case Western Reserve University.
 
 A2)  What's the latest version?
 
-The latest version is 2.05b, first made available on Wednesday, 17
-July, 2002.
+The latest version is 3.0, first made available on 27 July, 2004.
 
 A3)  Where can I get it?
 
 Bash is the GNU project's shell, and so is available from 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.05b:
+The following URLs tell how to get version 3.0:
 
-ftp://ftp.gnu.org/pub/gnu/bash/bash-2.05b.tar.gz
-ftp://ftp.cwru.edu/pub/bash/bash-2.05b.tar.gz
+ftp://ftp.gnu.org/pub/gnu/bash/bash-3.0.tar.gz
+ftp://ftp.cwru.edu/pub/bash/bash-3.0.tar.gz
 
 Formatted versions of the documentation are available with the URLs:
 
-ftp://ftp.gnu.org/pub/gnu/bash/bash-doc-2.05b.tar.gz
-ftp://ftp.cwru.edu/pub/bash/bash-doc-2.05b.tar.gz
+ftp://ftp.gnu.org/pub/gnu/bash/bash-doc-3.0.tar.gz
+ftp://ftp.cwru.edu/pub/bash/bash-doc-3.0.tar.gz
 
 A4)  On what machines will bash run?
 
-Bash has been ported to nearly every version of UNIX.  All you
+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
 exists is to type `configure' and then `make'.  The build process
-will attempt to discover the version of UNIX you have and tailor
+will attempt to discover the version of Unix you have and tailor
 itself accordingly, using a script created by GNU autoconf.
 
 More information appears in the file `INSTALL' in the distribution.
@@ -190,13 +192,8 @@ early GNU-Win32 (the original name) releases.  Cygnus has also done a
 port of bash-2.05 to the CYGWIN environment, and it is available as
 part of their current release.
 
-Bash-2.05b should require no local Cygnus changes to build and run under
-CYGWIN.
-
-The Cygnus port works only on Intel machines.  There is a port of bash
-(I don't know which version) to the alpha/NT environment available from
-
-ftp://ftp.gnustep.org//pub/win32/bash-alpha-nt-1.01.tar.gz
+Bash-2.05b and later versions should require no local Cygnus changes to
+build and run under CYGWIN.
 
 DJ Delorie has a port of bash-2.x which runs under MS-DOS, as part
 of the DJGPP project.  For more information on the project, see
@@ -212,19 +209,10 @@ ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh204b.zip    binary
 ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh204d.zip documentation
 ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh204s.zip source
 
-Mark has begun to work with bash-2.05, but I don't know the status.
-
-Ports of bash-1.12 and bash-2.0 are available for OS/2 from
-
-ftp://hobbes.nmsu.edu/pub/os2/util/shell/bash_112.zip
-ftp://hobbes.nmsu.edu/pub/os2/util/shell/bash-2.0(253).zip
-
-I haven't looked at either, but the second appears to be a binary-only
-distribution.  Beware.
+Mark began to work with bash-2.05, but I don't know the current status.
 
-I have received word that Bash (I'm not sure which version, but I
-believe that it's at least bash-2.02.1) is the standard shell on
-BeOS.
+Bash-3.0 compiles and runs with no modifications under Microsoft's Services
+for Unix (SFU), once known as Interix.
 
 A6) How can I build bash with gcc? 
 
@@ -271,7 +259,8 @@ it is invoked as a login shell.
 
 Next, add a line similar to the above to ~/.profile:
 
-        [ -f /usr/gnu/bin/bash ] && exec /usr/gnu/bin/bash --login
+       [ -f /usr/gnu/bin/bash ] && [ -x /usr/gnu/bin/bash ] && \
+               exec /usr/gnu/bin/bash --login
 
 This will cause login shells to replace themselves with bash running as
 a login shell.  Once you have this working, you can copy your initialization
@@ -325,7 +314,7 @@ this before you can make bash your login shell.
 Most versions of ftpd use this file to prohibit `special' users
 such as `uucp' and `news' from using FTP. 
 
-A9)  What's the `POSIX 1003.2 standard'?
+A9)  What's the `POSIX Shell and Utilities standard'?
 
 POSIX is a name originally coined by Richard Stallman for a
 family of open system standards based on UNIX.  There are a
@@ -335,44 +324,49 @@ call and C library level to applications and tools to system
 administration and management.  Each area of standardization is
 assigned to a working group in the 1003 series. 
 
-The POSIX Shell and Utilities standard has been developed by IEEE
-Working Group 1003.2 (POSIX.2).  It concentrates on the command
+The POSIX Shell and Utilities standard was originally developed by
+IEEE Working Group 1003.2 (POSIX.2).  Today it has been merged with
+the original 1003.1 Working Group and is maintained by the Austin
+Group (a joint working group of the IEEE, The Open Group and
+ISO/IEC SC22/WG15).  Today the Shell and Utilities are a volume
+within the set of documents that make up IEEE Std 1003.1-2001, and
+thus now the former POSIX.2 (from 1992) is now part of the current
+POSIX.1 standard (POSIX 1003.1-2001). 
+
+The Shell and Utilities volume concentrates on the command
 interpreter interface and utility programs commonly executed from
-the command line or by other programs.  An initial version of the
-standard has been approved and published by the IEEE, and work is
-currently underway to update it. 
+the command line or by other programs.  The standard is freely
+available on the web at http://www.UNIX-systems.org/version3/ . 
+Work continues at the Austin Group on maintenance issues; see
+http://www.opengroup.org/austin/ to join the discussions. 
 
-Bash is concerned with the aspects of the shell's behavior
-defined by POSIX.2.  The shell command language has of course
-been standardized, including the basic flow control and program
-execution constructs, I/O redirection and pipelining, argument
-handling, variable expansion, and quoting. 
+Bash is concerned with the aspects of the shell's behavior defined
+by the POSIX Shell and Utilities volume.  The shell command
+language has of course been standardized, including the basic flow
+control and program execution constructs, I/O redirection and
+pipelining, argument handling, variable expansion, and quoting. 
 
 The `special' builtins, which must be implemented as part of the
 shell to provide the desired functionality, are specified as
 being part of the shell; examples of these are `eval' and
-`export'.  Other utilities appear in the sections of POSIX.2 not
+`export'.  Other utilities appear in the sections of POSIX not
 devoted to the shell which are commonly (and in some cases must
 be) implemented as builtin commands, such as `read' and `test'. 
-POSIX.2 also specifies aspects of the shell's interactive
+POSIX also specifies aspects of the shell's interactive
 behavior as part of the UPE, including job control and command
 line editing.  Only vi-style line editing commands have been
 standardized; emacs editing commands were left out due to
 objections.
 
-The Open Group has made an older version of its Single Unix
-Specification (version 2), which is very similar to POSIX.2,
-available on the web at
-
-http://www.opengroup.org/onlinepubs/007908799/
-
-The Single Unix Specification, version 3, is available on the web at
+The latest version of the POSIX Shell and Utilities standard is
+available (now updated to the 2004 Edition) as part of the Single
+UNIX Specification Version 3 at
 
-http://www.opengroup.org/onlinepubs/007904975/
+http://www.UNIX-systems.org/version3/
 
 A10)  What is the bash `posix mode'?
 
-Although bash is an implementation of the POSIX.2 shell
+Although bash is an implementation of the POSIX shell
 specification, there are areas where the bash default behavior
 differs from that spec.  The bash `posix mode' changes the bash
 behavior in these areas so that it obeys the spec more closely. 
@@ -387,18 +381,48 @@ They are also listed in a section in the Bash Reference Manual
 
 Section B:  The latest version
 
-B1) What's new in version 2.05b?
+B1) What's new in version 3.0?
 
-The raison d'etre for bash-2.05b is to make a second intermediate
-release containing the first of the new features to be available
-in bash-3.0 and get feedback on those features before proceeding.
-The major new feature is multibyte character support in both Bash
-and Readline.
+Bash-3.0 is the third major release of bash.  The features introduced
+in the intermediate releases following bash-2.05 have been completed.
+Support for the bash debugger (a separate project) has been integrated.
 
-Bash-2.05b contains the following new features (see the manual page for
-complete descriptions and the CHANGES and NEWS files in the bash-2.05b
+Bash-3.0 contains the following new features (see the manual page for
+complete descriptions and the CHANGES and NEWS files in the bash-3.0
 distribution):
 
+o Features to support the bash debugger have been implemented, and there
+  is a new `extdebug' option to turn the non-default options on
+
+o HISTCONTROL is now a colon-separated list of options and has been
+  extended with a new `erasedups' option that will result in only one
+  copy of a command being kept in the history list
+
+o Brace expansion has been extended with a new {x..y} form, producing
+  sequences of digits or characters
+
+o Timestamps are now kept with history entries, with an option to save
+  and restore them from the history file; there is a new HISTTIMEFORMAT
+  variable describing how to display the timestamps when listing history
+  entries
+
+o The `[[' command can now perform extended regular expression (egrep-like)
+  matching, with matched subexpressions placed in the BASH_REMATCH array
+  variable
+
+o A new `pipefail' option causes a pipeline to return a failure status if
+  any command in it fails
+
+o The `jobs', `kill', and `wait' builtins now accept job control notation
+  in their arguments even if job control is not enabled
+
+o The `gettext' package and libintl have been integrated, and the shell
+  messages may be translated into other languages
+
+A short feature history dating from Bash-2.0:
+
+Bash-2.05b introduced the following new features:
+
 o support for multibyte characters has been added to both bash and readline
 
 o the DEBUG trap is now run *before* simple commands, ((...)) commands,
@@ -427,9 +451,6 @@ o the expansion of $LINENO inside a shell function is only relative to the
   script, $LINENO expands to the line number in the script.  This is as
   POSIX-2001 requires
 
-
-A short feature history dating from Bash-2.0:
-
 Bash-2.05a introduced the following new features:
 
 o The `printf' builtin has undergone major work
@@ -607,10 +628,10 @@ grammar tighter and smaller (66 reduce-reduce conflicts gone)
 lots of code now smaller and faster
 test suite greatly expanded
 
-B2) Are there any user-visible incompatibilities between bash-2.05b and
+B2) Are there any user-visible incompatibilities between bash-3.0 and
     bash-1.14.7?
 
-There are a few incompatibilities between version 1.14.7 and version 2.05b.
+There are a few incompatibilities between version 1.14.7 and version 3.0.
 They are detailed in the file COMPAT in the bash distribution.  That file
 is not meant to be all-encompassing; send mail to bash-maintainers@gnu.org
 if if you find something that's not mentioned there.
@@ -696,6 +717,9 @@ Things bash has that sh does not:
        posix mode
        redirection to /dev/fd/N, /dev/stdin, /dev/stdout, /dev/stderr,
                /dev/tcp/host/port, /dev/udp/host/port
+       debugger support, including `caller' builtin and new variables
+       RETURN trap
+
 
 Things sh has that bash does not:
        uses variable SHACCT to do shell accounting
@@ -768,6 +792,10 @@ Things bash has or uses that ksh88 does not:
        redirection to /dev/fd/N, /dev/stdin, /dev/stdout, /dev/stderr
        arrays of unlimited size
        TMOUT is default timeout for `read' and `select'
+       debugger support, including the `caller' builtin
+       RETURN trap
+       Timestamps in history entries
+       {x..y} brace expansion
 
 Things ksh88 has or uses that bash does not:
        tracked aliases (alias -t)
@@ -776,9 +804,9 @@ Things ksh88 has or uses that bash does not:
        weirdly-scoped functions
        typeset +f to list all function names without definitions
        text of command history kept in a file, not memory
-       builtins: alias -x, cd old new, fc -e -, newgrp, print,
+       builtins: alias -x, cd old new, newgrp, print,
                  read -p/-s/var?prompt, set -A/-o gmacs/
-                 -o bgnice/-o markdirs/-o nolog/-o trackall/-o viraw/-s,
+                 -o bgnice/-o markdirs/-o trackall/-o viraw/-s,
                  typeset -H/-L/-R/-Z/-A/-ft/-fu/-fx/-l/-u/-t, whence
        using environment to pass attributes of exported variables
        arithmetic evaluation done on arguments to some builtins
@@ -795,7 +823,7 @@ Implementation differences:
 
 C3)  Which new features in ksh-93 are not in bash, and which are?
 
-New things in ksh-93 not in bash-2.05b:
+New things in ksh-93 not in bash-3.0:
        associative arrays
        floating point arithmetic and variables
        math library functions
@@ -814,15 +842,15 @@ New things in ksh-93 not in bash-2.05b:
        `fc' has been renamed to `hist'
        `.' can execute shell functions
        exit statuses between 0 and 255
-       set -o pipefail
        `+=' variable assignment operator
        FPATH and PATH mixing
        getopts -a
        -I invocation option
-       DEBUG trap now executed before each simple command, instead of after
        printf %H, %P, %T, %Z modifiers, output base for %d
+       lexical scoping for local variables in `ksh' functions
+       no scoping for local variables in `POSIX' functions
 
-New things in ksh-93 present in bash-2.05b:
+New things in ksh-93 present in bash-3.0:
        [n]<&word- and [n]>&word- redirections (combination dup and close)
         for (( expr1; expr2; expr3 )) ; do list; done - arithmetic for command
         ?:, ++, --, `expr1 , expr2' arithmetic operators
@@ -847,6 +875,7 @@ New things in ksh-93 present in bash-2.05b:
        command and arithmetic substitution performed on PS1, PS4, and ENV
        command name completion
        ENV processed only for interactive shells
+       set -o pipefail
 
 Section D:  Why does bash do some things differently than other Unix shells?
 
@@ -1235,9 +1264,9 @@ subdirs-clean:
                ( cd $$d && ${MAKE} ${MFLAGS} clean ) \
        done
 
-The latest drafts of the updated POSIX standard have changed this:  the
-word list is no longer required.  Bash versions 2.05a and later accept
-the new syntax.
+The latest updated POSIX standard has changed this:  the word list
+is no longer required.  Bash versions 2.05a and later accept the
+new syntax.
 
 E8) Why does the arithmetic evaluation code complain about `08'?
 
@@ -1305,6 +1334,49 @@ This is, I presume, for historical compatibility.  Certain versions of
 Unix, and early network file systems, used paths of the form
 //hostname/path to access `path' on server `hostname'.
 
+E11) If I resize my xterm while another program is running, why doesn't bash
+     notice the change?
+
+This is another issue that deals with job control.
+
+The kernel maintains a notion of a current terminal process group.  Members
+of this process group (processes whose process group ID is equal to the
+current terminal process group ID) receive terminal-generated signals like
+SIGWINCH.  (For more details, see the JOB CONTROL section of the bash
+man page.)
+
+If a terminal is resized, the kernel sends SIGWINCH to each member of
+the terminal's current process group (the `foreground' process group).
+
+When bash is running with job control enabled, each pipeline (which may be
+a single command) is run in its own process group, different from bash's
+process group.  This foreground process group receives the SIGWINCH; bash
+does not.  Bash has no way of knowing that the terminal has been resized.
+
+There is a `checkwinsize' option, settable with the `shopt' builtin, that
+will cause bash to check the window size and adjust its idea of the
+terminal's dimensions each time a process stops or exits and returns control
+of the terminal to bash.  Enable it with `shopt -s checkwinsize'.
+
+E12) Why don't negative offsets in substring expansion work like I expect?
+
+When substring expansion of the form ${param:offset[:length} is used,
+an `offset' that evaluates to a number less than zero counts back from
+the end of the expanded value of $param.
+
+When a negative `offset' begins with a minus sign, however, unexpected things
+can happen.  Consider
+
+       a=12345678
+       echo ${a:-4}
+
+intending to print the last four characters of $a.  The problem is that
+${param:-word} already has a well-defined meaning: expand to word if the
+expanded value of param is unset or null, and $param otherwise.
+
+To use negative offsets that begin with a minus sign, separate the
+minus sign and the colon with a space.
+
 Section F:  Things to watch out for on certain Unix versions
 
 F1) Why can't I use command line editing in my `cmdtool'?
@@ -1410,7 +1482,7 @@ comp.unix.shell).  While most commands of the form
 can be converted to `< file command', shell control structures such as
 loops and subshells require `command < file'.
 
-The file CWRU/sh-redir-hack in the bash-2.05a distribution is an
+The file CWRU/sh-redir-hack in the bash 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
@@ -1671,11 +1743,17 @@ A second edition of this book is available, published in January, 1998.
 The ISBN number is 1-56592-347-2.  Look for it in the same fine bookstores
 or on the web.
 
+The GNU Bash Reference Manual has been published as a printed book by
+Network Theory Ltd (Paperback, ISBN: 0-9541617-7-7, Feb 2003).  It covers
+bash-2.0 and is available from most online bookstores (see
+http://www.network-theory.co.uk/bash/manual/ for details).  The publisher
+will donate $1 to the Free Software Foundation for each copy sold. 
+
 H3) What's coming in future versions?
 
 These are features I hope to include in a future version of bash.
 
-a better bash debugger (a minimally-tested version is included with bash-2.05b)
+Rocky Bernstein's bash debugger (support is included with bash-3.0)
 associative arrays
 co-processes, but with a new-style syntax that looks like function declaration
 
@@ -1685,7 +1763,6 @@ These are features that may or may not appear in a future version of bash.
 
 breaking some of the shell functionality into embeddable libraries
 a module system like zsh's, using dynamic loading like builtins
-better internationalization using GNU `gettext'
 date-stamped command history
 a bash programmer's guide with a chapter on creating loadable builtins
 a better loadable interface to perl with access to the shell builtins and
@@ -1698,10 +1775,9 @@ Some of the new ksh93 pattern matching operators, like backreferencing
 
 H5) When will the next release appear?
 
-The next version will appear sometime in 2002.  Never make predictions. 
-
+The next version will appear sometime in 2005.  Never make predictions. 
 
-This document is Copyright 1995-2002 by Chester Ramey.
+This document is Copyright 1995-2004 by Chester Ramey.
 
 Permission is hereby granted, without written agreement and
 without license or royalty fees, to use, copy, and distribute