Imported from ../bash-2.05a.tar.gz.
[platform/upstream/bash.git] / COMPAT
1 This document details the incompatibilites between this version of bash,
2 bash-2.05a, and the previous widely-available version, bash-1.14 (which
3 is still the `standard' version for many Linux distributions).  These
4 were discovered by users of bash-2.x, so this list is not comprehensive.
5 Some of these incompatibilities occur between the current version and
6 versions 2.0 and above.
7
8 1.  Bash now uses a new quoting syntax, $"...", to do locale-specific
9     string translation.  Users who have relied on the (undocumented)
10     behavior of bash-1.14 will have to change their scripts.  For
11     instance, if you are doing something like this to get the value of
12     a variable whose name is the value of a second variable:
13
14         eval var2=$"$var1"
15
16     you will have to change to a different syntax.
17
18     This capability is directly supported by bash-2.0:
19
20         var2=${!var1}
21
22     This alternate syntax will work portably between bash-1.14 and bash-2.0:
23
24         eval var2=\$${var1}
25
26 2.  One of the bugs fixed in the YACC grammar tightens up the rules
27     concerning group commands ( {...} ).  The `list' that composes the
28     body of the group command must be terminated by a newline or
29     semicolon.  That's because the braces are reserved words, and are
30     recognized as such only when a reserved word is legal.  This means
31     that while bash-1.14 accepted shell function definitions like this:
32
33         foo() { : }
34
35     bash-2.0 requires this:
36
37         foo() { :; }
38
39     This is also an issue for commands like this:
40
41         mkdir dir || { echo 'could not mkdir' ; exit 1; }
42
43     The syntax required by bash-2.0 is also accepted by bash-1.14.
44
45 3.  The options to `bind' have changed to make them more consistent with
46     the rest of the bash builtins.  If you are using `bind -d' to list
47     the readline keybindings in a form that can be re-read, use `bind -p'
48     instead.  If you were using `bind -v' to list the keybindings, use
49     `bind -P' instead.
50
51 4.  The `long' invocation options must now be prefixed by `--' instead
52     of `-'.  (The old form is still accepted, for the time being.)
53
54 5.  There was a bug in the version of readline distributed with bash-1.14
55     that caused it to write badly-formatted key bindings when using 
56     `bind -d'.  The only key sequences that were affected are C-\ (which
57     should appear as \C-\\ in a key binding) and C-" (which should appear
58     as \C-\").  If these key sequences appear in your inputrc, as, for
59     example,
60
61         "\C-\": self-insert
62
63     they will need to be changed to something like the following:
64
65         "\C-\\": self-insert
66
67 6.  A number of people complained above having to use ESC to terminate an
68     incremental search, and asked for an alternate mechanism.  Bash-2.03
69     uses the value of the settable readline variable `isearch-terminators'
70     to decide which characters should terminate an incremental search.  If
71     that variable has not been set, ESC and Control-J will terminate a
72     search.
73
74 7.  Some variables have been removed:  MAIL_WARNING, notify, history_control,
75     command_oriented_history, glob_dot_filenames, allow_null_glob_expansion,
76     nolinks, hostname_completion_file, noclobber, no_exit_on_failed_exec, and
77     cdable_vars.  Most of them are now implemented with the new `shopt'
78     builtin; others were already implemented by `set'.  Here is a list of
79     correspondences:
80
81         MAIL_WARNING                    shopt mailwarn
82         notify                          set -o notify
83         history_control                 HISTCONTROL
84         command_oriented_history        shopt cmdhist
85         glob_dot_filenames              shopt dotglob
86         allow_null_glob_expansion       shopt nullglob
87         nolinks                         set -o physical
88         hostname_completion_file        HOSTFILE
89         noclobber                       set -o noclobber
90         no_exit_on_failed_exec          shopt execfail
91         cdable_vars                     shopt cdable_vars
92
93 8. `ulimit' now sets both hard and soft limits and reports the soft limit
94     by default (when neither -H nor -S is specified).  This is compatible
95     with versions of sh and ksh that implement `ulimit'.  The bash-1.14
96     behavior of, for example,
97
98                 ulimit -c 0
99
100     can be obtained with
101
102                 ulimit -S -c 0
103
104     It may be useful to define an alias:
105
106                 alias ulimit="ulimit -S"
107
108 9.  Bash-2.01 uses a new quoting syntax, $'...' to do ANSI-C string
109     translation.  Backslash-escaped characters in ... are expanded and
110     replaced as specified by the ANSI C standard.
111
112 10. The sourcing of startup files has changed somewhat.  This is explained
113     more completely in the INVOCATION section of the manual page.
114
115     A non-interactive shell not named `sh' and not in posix mode reads
116     and executes commands from the file named by $BASH_ENV.  A
117     non-interactive shell started by `su' and not in posix mode will read
118     startup files.  No other non-interactive shells read any startup files.
119
120     An interactive shell started in posix mode reads and executes commands
121     from the file named by $ENV.
122
123 11. The <> redirection operator was changed to conform to the POSIX.2 spec.
124     In the absence of any file descriptor specification preceding the `<>',
125     file descriptor 0 is used.  In bash-1.14, this was the behavior only
126     when in POSIX mode.  The bash-1.14 behavior may be obtained with
127
128         <>filename 1>&0
129
130 12. The `alias' builtin now checks for invalid options and takes a `-p'
131     option to display output in POSIX mode.  If you have old aliases beginning
132     with `-' or `+', you will have to add the `--' to the alias command
133     that declares them:
134
135         alias -x='chmod a-x' --> alias -- -x='chmod a-x'
136
137 13. The behavior of range specificiers within bracket matching expressions
138     in the pattern matcher (e.g., [A-Z]) depends on the current locale,
139     specifically the value of the LC_COLLATE environment variable.  Setting
140     this variable to C or POSIX will result in the traditional ASCII behavior
141     for range comparisons.  If the locale is set to something else, e.g.,
142     en_US (specified by the LANG or LC_ALL variables), collation order is
143     locale-dependent.  For example, the en_US locale sorts the upper and
144     lower case letters like this:
145
146         AaBb...Zz
147
148     so a range specification like [A-Z] will match every letter except `z'.
149
150     The portable way to specify upper case letters is [:upper:] instead of
151     A-Z; lower case may be specified as [:lower:] instead of a-z.
152
153     Look at the manual pages for setlocale(3), strcoll(3), and, if it is
154     present, locale(1).
155
156     You can find your current locale information by running locale(1):
157
158         caleb.ins.cwru.edu(2)$ locale
159         LANG=en_US
160         LC_CTYPE="en_US"
161         LC_NUMERIC="en_US"
162         LC_TIME="en_US"
163         LC_COLLATE="en_US"
164         LC_MONETARY="en_US"
165         LC_MESSAGES="en_US"
166         LC_ALL=en_US
167
168     My advice is to put
169
170         export LC_COLLATE=C
171
172     into /etc/profile and inspect any shell scripts run from cron for
173     constructs like [A-Z].  This will prevent things like
174
175         rm [A-Z]*
176
177     from removing every file in the current directory except those beginning
178     with `z' and still allow individual users to change the collation order.
179     Users may put the above command into their own profiles as well, of course.
180
181 14.  Bash versions up to 1.14.7 included an undocumented `-l' operator to
182      the `test/[' builtin.  It was a unary operator that expanded to the
183      length of its string argument.  This let you do things like
184
185         test -l $variable -lt 20
186
187      for example.
188
189      This was included for backwards compatibility with old versions of the
190      Bourne shell, which did not provide an easy way to obtain the length of
191      the value of a shell variable.
192
193      This operator is not part of the POSIX standard, because one can (and
194      should) use ${#variable} to get the length of a variable's value.
195      Bash-2.x does not support it.
196
197 15.  Bash no longer auto-exports the HOME, PATH, SHELL, TERM, HOSTNAME,
198      HOSTTYPE, MACHTYPE, or OSTYPE variables.
199
200 16.  Bash no longer initializes the FUNCNAME, GROUPS, or DIRSTACK variables
201      to have special behavior if they appear in the initial environment.
202
203 17.  Bash no longer removes the export attribute from the SSH_CLIENT or
204      SSH2_CLIENT variables, and no longer attempts to discover whether or
205      not it has been invoked by sshd in order to run the startup files.