- 论坛徽章:
- 0
|
----------
Section A: The Basics
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
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.
A2) What's the latest version?
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 3.0:
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-3.0.tar.gz
ftp://ftp.cwru.edu/pub/bash/bash-doc-3.0.tar.gz
Any patches for the current version are available with the URL:
ftp://ftp.cwru.edu/pub/bash/bash-3.0-patches/
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
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.
The Bash web page (http://cnswww.cns.cwru.edu/~chet/bash/bashtop.html)
explains how to obtain binary versions of bash for most of the major
commercial Unix systems.
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.05 and later
versions 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 (now part of Red Hat) as part
of their CYGWIN project. For more information about the project, see
http://www.cygwin.com/.
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.05b to the CYGWIN environment, and it is available as
part of their current release. Bash-3.0 is currently being tested and
should be available soon.
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
http://www.delorie.com/djgpp/
I have been told that the original DJGPP port was done by Daisuke Aoyama.
Mark Elbrecht <snowball3@bigfoot.com> has sent me notice that bash-2.04
is available for DJGPP V2. The files are available as:
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 began to work with bash-2.05, but I don't know the current status.
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?
Bash configures to use gcc by default if it is available. Read the
file INSTALL in the distribution for more information.
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
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 ] && [ -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
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) that attempts
to do the right thing. It is, however, often broken, and may require that
you use the $BASH_ENV trick described below.
`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
If CDE starts its shells non-interactively during login, the login shell
startup files (~/.profile, ~/.bash_profile) will not be sourced at login.
To get around this problem, append a line similar to the following to your
~/.dtprofile:
BASH_ENV=${HOME}/.bash_profile ; export BASH_ENV
and add the following line to the beginning of ~/.bash_profile:
unset BASH_ENV
A 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. |
|