Next Previous Contents

1. The Basics

1.1 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 shells.

Bash contains a number of enhancements over those shells, both for interactive use and shell programming. Features geared toward interactive use include command line editing, command history, job control, aliases, and prompt expansion. Programming features include additional variable expansions, shell arithmetic, and a number of variables and options to control shell behavior.

Bash was originally written by Brian Fox of the Free Software Foundation. The current developer and maintainer is Chet Ramey of Case Western Reserve University.

1.2 What's the latest version?

The latest version is 2.04, first made available on Friday, 17 March 2000.

1.3 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.04:

ftp://ftp.gnu.org/pub/gnu/bash/bash-2.04.tar.gz ftp://ftp.cwru.edu/pub/bash/bash-2.04.tar.gz

Formatted versions of the documentation are available with the URLs:

ftp://ftp.gnu.org/pub/gnu/bash/bash-doc-2.04.tar.gz ftp://ftp.cwru.edu/pub/bash/bash-doc-2.04.tar.gz

1.4 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 exists is to type `configure' and then `make'. The build process 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.

1.5 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.04 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.

Bash has been ported to versions of Windows implementing the Win32 programming interface. This includes Windows 95 and Windows NT. The port was done by Cygnus Solutions as part of their CYGWIN project. For more information about the project, look at the URL

http:/sourceware.cygnus.com/cygwin

Cygnus originally ported bash-1.14.7, and that port was part of their early GNU-Win32 (the original name) releases. Cygnus has also done a port of bash-2.02.1 to the CYGWIN environment, and it is available as part of their current release. (They may have upgraded by now.)

Bash-2.04 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

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

http://www.delorie.com/djgpp/

I picked up a binary of bash-1.14.7 that is purported to work with the DJGPP V2 environment from

ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh1147b.zip

The corresponding source is

ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh1147s.zip

Mark Elbrecht < nowball3@bigfoot.com> has sent me notice that bash-2.03 has become available for DJGPP V2. The files are available as:

ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh203b.zip binary ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh203d.zip documentation ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh203s.zip source

Mark has begun to work with bash-2.04.

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.

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.

1.6 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.

1.7 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 you, that's all you need. Note that many systems require the full pathname to a shell to appear in /etc/shells before you can make it your login shell. For this, you may need the assistance of your friendly local system administrator.

If you cannot do this, you can still use bash as your login shell, but you need to perform some tricks. The basic idea is to add a command to your login shell's startup file to replace your login shell with bash.

For example, if your login shell is csh or tcsh, and you have installed bash in /usr/gnu/bin/bash, add the following line to  /.login:


        if ( -f /usr/gnu/bin/bash ) exec /usr/gnu/bin/bash --login

(the `--login' tells bash that it is a login shell).

It's not a good idea to put this command into  /.cshrc, because every csh you run without the `-f' option, even ones started to run csh scripts, reads that file. If you must put the command in  /.cshrc, use something like


        if ( $?prompt ) exec /usr/gnu/bin/bash --login

to ensure that bash is exec'd only when the csh is interactive.

If your login shell is sh or ksh, you have to do two things.

First, create an empty file in your home directory named `.bash_profile'. The existence of this file will prevent the exec'd bash from trying to read  /.profile, and re-execing itself over and over again.  /.bash_profile is the first file bash tries to read initialization commands from when 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

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 code from  /.profile to  /.bash_profile.

I have received word that the recipe supplied above is insufficient for machines running CDE. CDE has a maze of twisty little startup files, all slightly different.

If you cannot change your login shell in the password file to bash, you will have to (apparently) live with CDE using the shell in the password file to run its startup scripts. If you have changed your shell to bash, there is code in the CDE startup files (on Solaris, at least) to do the right thing.

`dtterm' claims to use $SHELL as the default program to start, so if you can change $SHELL in the CDE startup files, you should be able to use bash in your terminal windows.

Setting DTSOURCEPROFILE in  /.dtprofile will cause the `Xsession' program to read your login shell's startup files. You may be able to use bash for the rest of the CDE programs by setting SHELL to bash in  /.dtprofile as well, but I have not tried this.

You can use the above `exec' recipe to start bash when not logging in with CDE by testing the value of the DT variable:


        if [ -n "$DT" ]; then
                [ -f /usr/gnu/bin/bash ] && exec /usr/gnu/bin/bash --login
        fi

1.8 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 noted in the answer to the previous question, many systems require 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.

1.9 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 number of aspects of UNIX under consideration for standardization, from the basic system services at the system 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 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.

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.

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 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 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.

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 differs from that spec. The bash `posix mode' changes the bash behavior in these areas so that it obeys the spec more closely.

Posix mode is entered by starting bash with the --posix option or executing `set -o posix' after bash is running.

The specific aspects of bash which change when posix mode is active are listed in the file CWRU/POSIX.NOTES in the bash distribution. They are also listed in a section in the Bash Reference Manual.


Next Previous Contents