Commit dc36b72c authored by Daniel Kahn Gillmor's avatar Daniel Kahn Gillmor

Import Upstream version 2.05a

parent 2ddf5302
......@@ -153,8 +153,8 @@ lib/doc-support/getopt.c Roland McGrath
lib/doc-support/getopt1.c Roland McGrath
lib/glob/ChangeLog Brian Fox, Chet Ramey
lib/glob/Makefile.in Brian Fox, Chet Ramey
lib/glob/fnmatch.c Roland McGrath, Brian Fox, Chet Ramey
lib/glob/fnmatch.h Roland McGrath, Brian Fox, Chet Ramey
lib/glob/strmatch.c Roland McGrath, Brian Fox, Chet Ramey
lib/glob/strmatch.h Roland McGrath, Brian Fox, Chet Ramey
lib/glob/glob.c Richard Stallman, Roland McGrath, Brian Fox, Chet Ramey
lib/glob/glob.h Chet Ramey
lib/glob/ndir.h Doug Gwyn, Richard Stallman
......
This diff is collapsed.
This document details the incompatibilites between this version of bash,
bash-2.03, and the previous widely-available version, bash-1.14 (which
bash-2.05a, and the previous widely-available version, bash-1.14 (which
is still the `standard' version for many Linux distributions). These
were discovered by users of bash-2.x, so this list is not comprehensive.
Some of these incompatibilities occur between the current version and
versions 2.0 and above.
1. Bash now uses a new quoting syntax, $"...", to do locale-specific
string translation. Users who have relied on the (undocumented)
......@@ -124,3 +126,80 @@ were discovered by users of bash-2.x, so this list is not comprehensive.
when in POSIX mode. The bash-1.14 behavior may be obtained with
<>filename 1>&0
12. The `alias' builtin now checks for invalid options and takes a `-p'
option to display output in POSIX mode. If you have old aliases beginning
with `-' or `+', you will have to add the `--' to the alias command
that declares them:
alias -x='chmod a-x' --> alias -- -x='chmod a-x'
13. The behavior of range specificiers within bracket matching expressions
in the pattern matcher (e.g., [A-Z]) depends on the current locale,
specifically the value of the LC_COLLATE environment variable. Setting
this variable to C or POSIX will result in the traditional ASCII behavior
for range comparisons. If the locale is set to something else, e.g.,
en_US (specified by the LANG or LC_ALL variables), collation order is
locale-dependent. For example, the en_US locale sorts the upper and
lower case letters like this:
AaBb...Zz
so a range specification like [A-Z] will match every letter except `z'.
The portable way to specify upper case letters is [:upper:] instead of
A-Z; lower case may be specified as [:lower:] instead of a-z.
Look at the manual pages for setlocale(3), strcoll(3), and, if it is
present, locale(1).
You can find your current locale information by running locale(1):
caleb.ins.cwru.edu(2)$ locale
LANG=en_US
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE="en_US"
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_ALL=en_US
My advice is to put
export LC_COLLATE=C
into /etc/profile and inspect any shell scripts run from cron for
constructs like [A-Z]. This will prevent things like
rm [A-Z]*
from removing every file in the current directory except those beginning
with `z' and still allow individual users to change the collation order.
Users may put the above command into their own profiles as well, of course.
14. Bash versions up to 1.14.7 included an undocumented `-l' operator to
the `test/[' builtin. It was a unary operator that expanded to the
length of its string argument. This let you do things like
test -l $variable -lt 20
for example.
This was included for backwards compatibility with old versions of the
Bourne shell, which did not provide an easy way to obtain the length of
the value of a shell variable.
This operator is not part of the POSIX standard, because one can (and
should) use ${#variable} to get the length of a variable's value.
Bash-2.x does not support it.
15. Bash no longer auto-exports the HOME, PATH, SHELL, TERM, HOSTNAME,
HOSTTYPE, MACHTYPE, or OSTYPE variables.
16. Bash no longer initializes the FUNCNAME, GROUPS, or DIRSTACK variables
to have special behavior if they appear in the initial environment.
17. Bash no longer removes the export attribute from the SSH_CLIENT or
SSH2_CLIENT variables, and no longer attempts to discover whether or
not it has been invoked by sshd in order to run the startup files.
......@@ -3,8 +3,8 @@ Bash POSIX Mode
Starting Bash with the `--posix' command-line option or executing `set
-o posix' while Bash is running will cause Bash to conform more closely
to the POSIX.2 standard by changing the behavior to match that
specified by POSIX.2 in areas where the Bash default differs.
to the POSIX 1003.2 standard by changing the behavior to match that
specified by POSIX in areas where the Bash default differs.
The following list is what's changed when `POSIX mode' is in effect:
......@@ -12,14 +12,16 @@ The following list is what's changed when `POSIX mode' is in effect:
re-search `$PATH' to find the new location. This is also
available with `shopt -s checkhash'.
2. The `>&' redirection does not redirect stdout and stderr.
2. The message printed by the job control code and builtins when a job
exits with a non-zero status is `Done(status)'.
3. The message printed by the job control code and builtins when a job
exits with a non-zero status is `Done(status)'.
is stopped is `Stopped(SIGNAME)', where SIGNAME is, for example,
`SIGTSTP'.
4. Reserved words may not be aliased.
5. The POSIX.2 `PS1' and `PS2' expansions of `!' to the history
5. The POSIX 1003.2 `PS1' and `PS2' expansions of `!' to the history
number and `!!' to `!' are enabled, and parameter expansion is
performed on the values of `PS1' and `PS2' regardless of the
setting of the `promptvars' option.
......@@ -27,8 +29,8 @@ The following list is what's changed when `POSIX mode' is in effect:
6. Interactive comments are enabled by default. (Bash has them on by
default anyway.)
7. The POSIX.2 startup files are executed (`$ENV') rather than the
normal Bash files.
7. The POSIX 1003.2 startup files are executed (`$ENV') rather than
the normal Bash files.
8. Tilde expansion is only performed on assignments preceding a
command name, rather than on all assignment statements on the line.
......@@ -48,51 +50,82 @@ The following list is what's changed when `POSIX mode' is in effect:
13. Redirection operators do not perform filename expansion on the word
in the redirection unless the shell is interactive.
14. Function names must be valid shell `name's. That is, they may not
14. Redirection operators do not perform word splitting on the word in
the redirection.
15. Function names must be valid shell `name's. That is, they may not
contain characters other than letters, digits, and underscores, and
may not start with a digit. Declaring a function with an invalid
name causes a fatal syntax error in non-interactive shells.
15. POSIX.2 `special' builtins are found before shell functions during
command lookup.
16. POSIX 1003.2 `special' builtins are found before shell functions
during command lookup.
16. If a POSIX.2 special builtin returns an error status, a
17. If a POSIX 1003.2 special builtin returns an error status, a
non-interactive shell exits. The fatal errors are those listed in
the POSIX.2 standard, and include things like passing incorrect
options, redirection errors, variable assignment errors for
assignments preceding the command name, and so on.
17. If the `cd' builtin finds a directory to change to using
18. If the `cd' builtin finds a directory to change to using
`$CDPATH', the value it assigns to the `PWD' variable does not
contain any symbolic links, as if `cd -P' had been executed.
18. If `$CDPATH' is set, the `cd' builtin will not implicitly append
19. If `CDPATH' is set, the `cd' builtin will not implicitly append
the current directory to it. This means that `cd' will fail if no
valid directory name can be constructed from any of the entries in
`$CDPATH', even if the a directory with the same name as the name
given as an argument to `cd' exists in the current directory.
19. A non-interactive shell exits with an error status if a variable
20. A non-interactive shell exits with an error status if a variable
assignment error occurs when no command name follows the assignment
statements. A variable assignment error occurs, for example, when
trying to assign a value to a readonly variable.
20. A non-interactive shell exits with an error status if the iteration
21. A non-interactive shell exits with an error status if the iteration
variable in a `for' statement or the selection variable in a
`select' statement is a readonly variable.
21. Process substitution is not available.
22. Process substitution is not available.
23. Assignment statements preceding POSIX 1003.2 special builtins
persist in the shell environment after the builtin completes.
24. Assignment statements preceding shell function calls persist in the
shell environment after the function returns, as if a POSIX
special builtin command had been executed.
25. The `export' and `readonly' builtin commands display their output
in the format required by POSIX 1003.2.
22. Assignment statements preceding POSIX.2 special builtins persist
in the shell environment after the builtin completes.
26. The `trap' builtin displays signal names without the leading `SIG'.
23. The `export' and `readonly' builtin commands display their output
in the format required by POSIX.2.
27. The `.' and `source' builtins do not search the current directory
for the filename argument if it is not found by searching `PATH'.
28. Subshells spawned to execute command substitutions inherit the
value of the `-e' option from the parent shell. When not in POSIX
mode, Bash clears the `-e' option in such subshells.
There is other POSIX.2 behavior that Bash does not implement.
29. Alias expansion is always enabled, even in non-interactive shells.
30. When the `set' builtin is invoked without options, it does not
display shell function names and definitions.
There is other POSIX 1003.2 behavior that Bash does not implement.
Specifically:
1. Assignment statements affect the execution environment of all
builtins, not just special ones.
2. When a subshell is created to execute a shell script with execute
permission, but without a leading `#!', Bash sets `$0' to the full
pathname of the script as found by searching `$PATH', rather than
the command as typed by the user.
3. When using `.' to source a shell script found in `$PATH', bash
checks execute permission bits rather than read permission bits,
just as if it were searching for a command.
This diff is collapsed.
This patch is from Brian Fox, in reply to an email message from
"Marcin 'Qrczak' Kowalczyk" <qrczak@knm.org.pl>, who wrote:
I think that bash should accept such a syntax:
for var in ; do command; done
Of course it should do nothing. It would simplify some scripts.
Here is a patch for those who wish it:
*** parse.y.~1~ Wed Mar 4 09:39:46 1998
--- parse.y Mon Jul 13 14:40:23 1998
***************
*** 495,500 ****
--- 495,504 ----
{ $$ = make_for_command ($2, REVERSE_LIST ($5, WORD_LIST *), $9); }
| FOR WORD newline_list IN word_list list_terminator newline_list '{' compound_list '}'
{ $$ = make_for_command ($2, REVERSE_LIST ($5, WORD_LIST *), $9); }
+ | FOR WORD newline_list IN list_terminator newline_list DO compound_list DONE
+ { $$ = make_for_command ($2, (WORD_LIST *)NULL, $8); }
+ | FOR WORD newline_list IN list_terminator newline_list '{' compound_list '}'
+ { $$ = make_for_command ($2, (WORD_LIST *)NULL, $8); }
;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -26,6 +26,10 @@ Platform-Specific Configuration and Operation Notes
BSD/OS 2.1, 3.x if you want to use loadable builtins
Motorola m68k machines running System V.3. There is a file descriptor
leak caused by using the bash malloc because closedir(3) needs to read
freed memory to find the file descriptor to close
If you are using GNU libc, especially on a linux system
(Configuring --without-gnu-malloc will still result in lib/malloc/libmalloc.a
......@@ -47,9 +51,9 @@ being built and linked against, but there is only a stub file in the archive.)
configure runs and removing the `-lnsl' from the assignment to `LIBS'
fixes the problem.
5. There is a problem with Red Hat Linux's `makewhatis' script.
Running `makewhatis' with bash-2.0 or later versions results
in error messages like this:
5. There is a problem with the `makewhatis' script in older (pre-7.0)
versions of Red Hat Linux. Running `makewhatis' with bash-2.0 or
later versions results in error messages like this:
/usr/sbin/makewhatis: cd: manpath: No such file or directory
/usr/sbin/makewhatis: manpath/whatis: No such file or directory
......@@ -202,12 +206,17 @@ being built and linked against, but there is only a stub file in the archive.)
10. If you do not have /usr/ccs/bin in your PATH when building on SunOS 5.x
(Solaris 2), the configure script will be unable to find `ar' and
`ranlib' (of course, ranlib is unnecessary). Make sure your $PATH
includes /usr/ccs/bin on SunOS 5.x.
includes /usr/ccs/bin on SunOS 5.x. This generally manifests itself
with libraries not being built and make reporting errors like
`cr: not found' when library construction is attempted.
11. Building a statically-linked bash on Solaris 2.5.x, 2.6, 7, or 8 is
complicated.
11. Building a statically-linked bash on Solaris 2.5.x or 2.6 is complicated.
It's not possible to build a completely statically-linked binary, since
part of the C library depends on dynamic linking. The following recipe
assumes that you're using gcc and the Solaris ld (/usr/ccs/bin/ld).
assumes that you're using gcc and the Solaris ld (/usr/ccs/bin/ld) on
Solaris 2.5.x or 2.6:
configure --enable-static-link
make STATIC_LD= LOCAL_LIBS='-Wl,-B,dynamic -ldl -Wl,-B,static'
......@@ -243,6 +252,20 @@ being built and linked against, but there is only a stub file in the archive.)
thor(2)$ ldd bash
libdl.so.1 => /etc/lib/libdl.so.1
On Solaris 7 (Solaris 8, using the version of gcc on the free software
CD-ROM), the following recipe appears to work for gcc:
configure --enable-static-link
make STATIC_LD='-Wl,-Bstatic' LOCAL_LIBS='-Wl,-Bdynamic -Wl,-R/etc/lib -ldl -Wl,-Bstatic'
thor.ins.cwru.edu(2)$ ldd bash
libdl.so.1 => /etc/lib/libdl.so.1
Make the analogous changes if you are running Sun's C Compiler.
I have received word that adding -L/etc/lib (or the equivalent
-Wl,-L/etc/lib) might also be necessary, in addition to the -R/etc/lib.
12. Configuring bash to build it in a cross environment. Currently only
two native versions can be compiled this way, cygwin32 and x86 BeOS.
For BeOS, you would configure it like this:
......@@ -253,3 +276,53 @@ being built and linked against, but there is only a stub file in the archive.)
configure i586-beos
Similarly for cygwin32.
13. Bash-2.05 has reverted to the bash-2.03 behavior of honoring the current
locale setting when processing ranges within pattern matching bracket
expressions ([A-Z]). This is what POSIX.2 and SUSv2 specify.
The behavior of the matcher in bash-2.05 depends on the current LC_COLLATE
setting. Setting this variable to `C' or `POSIX' will result in the
traditional behavior ([A-Z] matches all uppercase ASCII characters).
Many other locales, including the en_US locale (the default on many US
versions of Linux) collate the upper and lower case letters like this:
AaBb...Zz
which means that [A-Z] matches every letter except `z'.
The portable way to specify upper case letters is [:upper:] instead of
A-Z; lower case may be specified as [:lower:] instead of a-z.
Look at the manual pages for setlocale(3), strcoll(3), and, if it is
present, locale(1). If you have locale(1), you can use it to find
your current locale information even if you do not have any of the
LC_ variables set.
My advice is to put
export LC_COLLATE=C
into /etc/profile and inspect any shell scripts run from cron for
constructs like [A-Z]. This will prevent things like
rm [A-Z]*
from removing every file in the current directory except those beginning
with `z' and still allow individual users to change the collation order.
Users may put the above command into their own profiles as well, of course.
14. Building on Interix (nee OpenNT), which Microsoft bought from Softway
Systems and has seemingly abandoned (thanks to Kevin Moore for this item).
1. cp cross-build/opennt.cache config.cache
2. If desired, edit pathnames.h to set the values of SYS_PROFILE and
DEFAULT_HOSTS_FILE appropriately.
3. export CONFIG_SHELL=$INTERIX_ROOT/bin/sh
4. ./configure --prefix=$INTERIX_ROOT/usr/local (or wherever you
want it).
5. make; make install; enjoy
Introduction
============
This is GNU Bash, version 2.03. Bash is the GNU Project's Bourne
This is GNU Bash, version 2.05a. Bash is the GNU Project's Bourne
Again SHell, a complete implementation of the POSIX.2 shell spec,
but also with interactive command line editing, job control on
architectures that support it, csh-like features such as history
......@@ -19,8 +19,9 @@ of Bash and the previous widely-distributed version, bash-1.14.
For details, see the file COMPAT. The NEWS file tersely lists
features that are new in this release.
Bash is free software, distributed under the terms of the GNU Public
License, version 2. For more information, see the file COPYING.
Bash is free software, distributed under the terms of the [GNU]
General Public License, version 2. For more information, see the
file COPYING.
A number of frequently-asked questions are answered in the file
`doc/FAQ'.
......@@ -51,21 +52,20 @@ Reporting Bugs
Bug reports for bash should be sent to:
bug-bash@prep.ai.mit.edu
bug-bash@gnu.org
using the `bashbug' program that is built and installed at the same
time as bash.
The discussion list `bug-bash@prep.ai.mit.edu' often contains
information about new ports of Bash, or discussions of new features or
behavior changes that people would like. This mailing list is also
available as a usenet newsgroup: gnu.bash.bug.
The discussion list `bug-bash@gnu.org' often contains information
about new ports of Bash, or discussions of new features or behavior
changes that people would like. This mailing list is also available
as a usenet newsgroup: gnu.bash.bug.
When you send a bug report, please use the `bashbug' program that is
built at the same time as bash. If bash fails to build, try building
bashbug directly with `make bashbug'. If you cannot build `bashbug',
please send mail to bug-bash@prep.ai.mit.edu with the following
information:
please send mail to bug-bash@gnu.org with the following information:
* the version number and release status of Bash (e.g., 2.01-release)
* the machine and OS that it is running on (look at the file
......@@ -79,7 +79,7 @@ information:
The `bashbug' program includes much of this automatically.
If you would like to contact the Bash maintainers directly, send mail
to bash-maintainers@prep.ai.mit.edu.
to bash-maintainers@gnu.org.
While the Bash maintainers do not promise to fix all bugs, we would
like this shell to be the best that we can make it.
......
This diff is collapsed.
......@@ -7,7 +7,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
......@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
......@@ -31,13 +31,29 @@
#endif
#include <stdio.h>
#include "chartypes.h"
#include "bashansi.h"
#include "command.h"
#include "general.h"
#include "externs.h"
#include "alias.h"
static int qsort_alias_compare ();
#if defined (PROGRAMMABLE_COMPLETION)
# include "pcomplete.h"
#endif
typedef int sh_alias_map_func_t __P((alias_t *));
static void free_alias_data __P((PTR_T));
static alias_t **map_over_aliases __P((sh_alias_map_func_t *));
static void sort_aliases __P((alias_t **));
static int qsort_alias_compare __P((alias_t **, alias_t **));
#if defined (READLINE)
static int skipquotes __P((char *, int));
static int skipws __P((char *, int));
static int rd_token __P((char *, int));
#endif
/* Non-zero means expand all words on the line. Otherwise, expand
after first expansion if the expansion ends in a space. */
......@@ -121,13 +137,16 @@ add_alias (name, value)
elt = add_hash_item (savestring (name), aliases);
elt->data = (char *)temp;
#if defined (PROGRAMMABLE_COMPLETION)
set_itemlist_dirty (&it_aliases);
#endif
}
}
/* Delete a single alias structure. */
static void
free_alias_data (data)
char *data;
PTR_T data;
{
register alias_t *a;
......@@ -155,6 +174,9 @@ remove_alias (name)
free_alias_data (elt->data);
free (elt->key); /* alias name */
free (elt); /* XXX */
#if defined (PROGRAMMABLE_COMPLETION)
set_itemlist_dirty (&it_aliases);
#endif
return (aliases->nentries);
}
return (-1);
......@@ -170,13 +192,16 @@ delete_all_aliases ()
flush_hash_table (aliases, free_alias_data);
dispose_hash_table (aliases);
aliases = (HASH_TABLE *)NULL;
#if defined (PROGRAMMABLE_COMPLETION)
set_itemlist_dirty (&it_aliases);
#endif
}
/* Return an array of aliases that satisfy the conditions tested by FUNCTION.
If FUNCTION is NULL, return all aliases. */
static alias_t **
map_over_aliases (function)
Function *function;
sh_alias_map_func_t *function;
{
register int i;
register BUCKET_CONTENTS *tlist;
......@@ -195,8 +220,11 @@ map_over_aliases (function)
if (!function || (*function) (alias))
{
if (list_index + 1 >= list_size)
list = (alias_t **)
xrealloc ((char *)list, (list_size += 20) * sizeof (alias_t *));
{
list_size += 20;
list = (alias_t **)xrealloc (list,
list_size * sizeof (alias_t *));
}
list[list_index++] = alias;
list[list_index] = (alias_t *)NULL;
......@@ -211,7 +239,7 @@ static void
sort_aliases (array)
alias_t **array;
{
qsort (array, array_len ((char **)array), sizeof (alias_t *), qsort_alias_compare);
qsort (array, array_len ((char **)array), sizeof (alias_t *), (QSFUNC *)qsort_alias_compare);
}
static int
......@@ -235,7 +263,7 @@ all_aliases ()
if (!aliases)
return ((alias_t **)NULL);