| 1 | 
 Compatibility with previous versions | 
 
 
 
 
 
 | 2 | 
 ==================================== | 
 
 
 
 
 
 | 3 | 
  | 
 
 
 
 
 
 | 4 | 
 This document details the incompatibilities between this version of bash, | 
 
 
 
 
 
 | 5 | 
 bash-5.1, and the previous widely-available versions, bash-3.2 (which is | 
 
 
 
 
 
 | 6 | 
 still the `standard' version for Mac OS X), 4.2/4.3 (which are still | 
 
 
 
 
 
 | 7 | 
 standard on a few Linux distributions), and bash-4.4/bash-5.0, the current | 
 
 
 
 
 
 | 8 | 
 widely-available versions.  These were discovered by users of bash-2.x | 
 
 
 
 
 
 | 9 | 
 through 5.x, so this list is not comprehensive.  Some of these | 
 
 
 
 
 
 | 10 | 
 incompatibilities occur between the current version and versions 2.0 and | 
 
 
 
 
 
 | 11 | 
 above.  | 
 
 
 
 
 
 | 12 | 
  | 
 
 
 
 
 
 | 13 | 
 1.  Bash uses a new quoting syntax, $"...", to do locale-specific | 
 
 
 
 
 
 | 14 | 
     string translation.  Users who have relied on the (undocumented) | 
 
 
 
 
 
 | 15 | 
     behavior of bash-1.14 will have to change their scripts.  For | 
 
 
 
 
 
 | 16 | 
     instance, if you are doing something like this to get the value of | 
 
 
 
 
 
 | 17 | 
     a variable whose name is the value of a second variable: | 
 
 
 
 
 
 | 18 | 
  | 
 
 
 
 
 
 | 19 | 
         eval var2=$"$var1" | 
 
 
 
 
 
 | 20 | 
  | 
 
 
 
 
 
 | 21 | 
     you will have to change to a different syntax. | 
 
 
 
 
 
 | 22 | 
  | 
 
 
 
 
 
 | 23 | 
     This capability is directly supported by bash-2.0: | 
 
 
 
 
 
 | 24 | 
  | 
 
 
 
 
 
 | 25 | 
         var2=${!var1} | 
 
 
 
 
 
 | 26 | 
  | 
 
 
 
 
 
 | 27 | 
     This alternate syntax will work portably between bash-1.14 and bash-2.0: | 
 
 
 
 
 
 | 28 | 
  | 
 
 
 
 
 
 | 29 | 
         eval var2=\$${var1} | 
 
 
 
 
 
 | 30 | 
  | 
 
 
 
 
 
 | 31 | 
 2.  One of the bugs fixed in the YACC grammar tightens up the rules | 
 
 
 
 
 
 | 32 | 
     concerning group commands ( {...} ).  The `list' that composes the | 
 
 
 
 
 
 | 33 | 
     body of the group command must be terminated by a newline or | 
 
 
 
 
 
 | 34 | 
     semicolon.  That's because the braces are reserved words, and are | 
 
 
 
 
 
 | 35 | 
     recognized as such only when a reserved word is legal.  This means | 
 
 
 
 
 
 | 36 | 
     that while bash-1.14 accepted shell function definitions like this: | 
 
 
 
 
 
 | 37 | 
  | 
 
 
 
 
 
 | 38 | 
         foo() { : } | 
 
 
 
 
 
 | 39 | 
  | 
 
 
 
 
 
 | 40 | 
     bash-2.0 requires this: | 
 
 
 
 
 
 | 41 | 
  | 
 
 
 
 
 
 | 42 | 
         foo() { :; } | 
 
 
 
 
 
 | 43 | 
  | 
 
 
 
 
 
 | 44 | 
     This is also an issue for commands like this: | 
 
 
 
 
 
 | 45 | 
  | 
 
 
 
 
 
 | 46 | 
         mkdir dir || { echo 'could not mkdir' ; exit 1; } | 
 
 
 
 
 
 | 47 | 
  | 
 
 
 
 
 
 | 48 | 
     The syntax required by bash-2.0 is also accepted by bash-1.14. | 
 
 
 
 
 
 | 49 | 
  | 
 
 
 
 
 
 | 50 | 
 3.  The options to `bind' have changed to make them more consistent with | 
 
 
 
 
 
 | 51 | 
     the rest of the bash builtins.  If you are using `bind -d' to list | 
 
 
 
 
 
 | 52 | 
     the readline key bindings in a form that can be re-read, use `bind -p' | 
 
 
 
 
 
 | 53 | 
     instead.  If you were using `bind -v' to list the key bindings, use | 
 
 
 
 
 
 | 54 | 
     `bind -P' instead. | 
 
 
 
 
 
 | 55 | 
  | 
 
 
 
 
 
 | 56 | 
 4.  The `long' invocation options must now be prefixed by `--' instead | 
 
 
 
 
 
 | 57 | 
     of `-'.  (The old form is still accepted, for the time being.) | 
 
 
 
 
 
 | 58 | 
  | 
 
 
 
 
 
 | 59 | 
 5.  There was a bug in the version of readline distributed with bash-1.14 | 
 
 
 
 
 
 | 60 | 
     that caused it to write badly-formatted key bindings when using  | 
 
 
 
 
 
 | 61 | 
     `bind -d'.  The only key sequences that were affected are C-\ (which | 
 
 
 
 
 
 | 62 | 
     should appear as \C-\\ in a key binding) and C-" (which should appear | 
 
 
 
 
 
 | 63 | 
     as \C-\").  If these key sequences appear in your inputrc, as, for | 
 
 
 
 
 
 | 64 | 
     example, | 
 
 
 
 
 
 | 65 | 
  | 
 
 
 
 
 
 | 66 | 
         "\C-\": self-insert | 
 
 
 
 
 
 | 67 | 
  | 
 
 
 
 
 
 | 68 | 
     they will need to be changed to something like the following: | 
 
 
 
 
 
 | 69 | 
  | 
 
 
 
 
 
 | 70 | 
         "\C-\\": self-insert | 
 
 
 
 
 
 | 71 | 
  | 
 
 
 
 
 
 | 72 | 
 6.  A number of people complained about having to use ESC to terminate an | 
 
 
 
 
 
 | 73 | 
     incremental search, and asked for an alternate mechanism.  Bash-2.03 | 
 
 
 
 
 
 | 74 | 
     uses the value of the settable readline variable `isearch-terminators' | 
 
 
 
 
 
 | 75 | 
     to decide which characters should terminate an incremental search.  If | 
 
 
 
 
 
 | 76 | 
     that variable has not been set, ESC and Control-J will terminate a | 
 
 
 
 
 
 | 77 | 
     search. | 
 
 
 
 
 
 | 78 | 
  | 
 
 
 
 
 
 | 79 | 
 7.  Some variables have been removed:  MAIL_WARNING, notify, history_control, | 
 
 
 
 
 
 | 80 | 
     command_oriented_history, glob_dot_filenames, allow_null_glob_expansion, | 
 
 
 
 
 
 | 81 | 
     nolinks, hostname_completion_file, noclobber, no_exit_on_failed_exec, and | 
 
 
 
 
 
 | 82 | 
     cdable_vars.  Most of them are now implemented with the new `shopt' | 
 
 
 
 
 
 | 83 | 
     builtin; others were already implemented by `set'.  Here is a list of | 
 
 
 
 
 
 | 84 | 
     correspondences: | 
 
 
 
 
 
 | 85 | 
  | 
 
 
 
 
 
 | 86 | 
         MAIL_WARNING                    shopt mailwarn | 
 
 
 
 
 
 | 87 | 
         notify                          set -o notify | 
 
 
 
 
 
 | 88 | 
         history_control                 HISTCONTROL | 
 
 
 
 
 
 | 89 | 
         command_oriented_history        shopt cmdhist | 
 
 
 
 
 
 | 90 | 
         glob_dot_filenames              shopt dotglob | 
 
 
 
 
 
 | 91 | 
         allow_null_glob_expansion       shopt nullglob | 
 
 
 
 
 
 | 92 | 
         nolinks                         set -o physical | 
 
 
 
 
 
 | 93 | 
         hostname_completion_file        HOSTFILE | 
 
 
 
 
 
 | 94 | 
         noclobber                       set -o noclobber | 
 
 
 
 
 
 | 95 | 
         no_exit_on_failed_exec          shopt execfail | 
 
 
 
 
 
 | 96 | 
         cdable_vars                     shopt cdable_vars | 
 
 
 
 
 
 | 97 | 
  | 
 
 
 
 
 
 | 98 | 
 8. `ulimit' now sets both hard and soft limits and reports the soft limit | 
 
 
 
 
 
 | 99 | 
     by default (when neither -H nor -S is specified).  This is compatible | 
 
 
 
 
 
 | 100 | 
     with versions of sh and ksh that implement `ulimit'.  The bash-1.14 | 
 
 
 
 
 
 | 101 | 
     behavior of, for example, | 
 
 
 
 
 
 | 102 | 
  | 
 
 
 
 
 
 | 103 | 
                 ulimit -c 0 | 
 
 
 
 
 
 | 104 | 
  | 
 
 
 
 
 
 | 105 | 
     can be obtained with | 
 
 
 
 
 
 | 106 | 
  | 
 
 
 
 
 
 | 107 | 
                 ulimit -S -c 0 | 
 
 
 
 
 
 | 108 | 
  | 
 
 
 
 
 
 | 109 | 
     It may be useful to define an alias: | 
 
 
 
 
 
 | 110 | 
  | 
 
 
 
 
 
 | 111 | 
                 alias ulimit="ulimit -S" | 
 
 
 
 
 
 | 112 | 
  | 
 
 
 
 
 
 | 113 | 
 9.  Bash-2.01 uses a new quoting syntax, $'...' to do ANSI-C string | 
 
 
 
 
 
 | 114 | 
     translation.  Backslash-escaped characters in ... are expanded and | 
 
 
 
 
 
 | 115 | 
     replaced as specified by the ANSI C standard. | 
 
 
 
 
 
 | 116 | 
  | 
 
 
 
 
 
 | 117 | 
 10. The sourcing of startup files has changed somewhat.  This is explained | 
 
 
 
 
 
 | 118 | 
     more completely in the INVOCATION section of the manual page. | 
 
 
 
 
 
 | 119 | 
  | 
 
 
 
 
 
 | 120 | 
     A non-interactive shell not named `sh' and not in posix mode reads | 
 
 
 
 
 
 | 121 | 
     and executes commands from the file named by $BASH_ENV.  A | 
 
 
 
 
 
 | 122 | 
     non-interactive shell started by `su' and not in posix mode will read | 
 
 
 
 
 
 | 123 | 
     startup files.  No other non-interactive shells read any startup files. | 
 
 
 
 
 
 | 124 | 
  | 
 
 
 
 
 
 | 125 | 
     An interactive shell started in posix mode reads and executes commands | 
 
 
 
 
 
 | 126 | 
     from the file named by $ENV. | 
 
 
 
 
 
 | 127 | 
  | 
 
 
 
 
 
 | 128 | 
 11. The <> redirection operator was changed to conform to the POSIX.2 spec. | 
 
 
 
 
 
 | 129 | 
     In the absence of any file descriptor specification preceding the `<>', | 
 
 
 
 
 
 | 130 | 
     file descriptor 0 is used.  In bash-1.14, this was the behavior only | 
 
 
 
 
 
 | 131 | 
     when in POSIX mode.  The bash-1.14 behavior may be obtained with | 
 
 
 
 
 
 | 132 | 
  | 
 
 
 
 
 
 | 133 | 
         <>filename 1>&0 | 
 
 
 
 
 
 | 134 | 
  | 
 
 
 
 
 
 | 135 | 
 12. The `alias' builtin now checks for invalid options and takes a `-p' | 
 
 
 
 
 
 | 136 | 
     option to display output in POSIX mode.  If you have old aliases beginning | 
 
 
 
 
 
 | 137 | 
     with `-' or `+', you will have to add the `--' to the alias command | 
 
 
 
 
 
 | 138 | 
     that declares them: | 
 
 
 
 
 
 | 139 | 
  | 
 
 
 
 
 
 | 140 | 
         alias -x='chmod a-x' --> alias -- -x='chmod a-x' | 
 
 
 
 
 
 | 141 | 
  | 
 
 
 
 
 
 | 142 | 
 13. The behavior of range specificiers within bracket matching expressions | 
 
 
 
 
 
 | 143 | 
     in the pattern matcher (e.g., [A-Z]) depends on the current locale, | 
 
 
 
 
 
 | 144 | 
     specifically the value of the LC_COLLATE environment variable.  Setting | 
 
 
 
 
 
 | 145 | 
     this variable to C or POSIX will result in the traditional ASCII behavior | 
 
 
 
 
 
 | 146 | 
     for range comparisons.  If the locale is set to something else, e.g., | 
 
 
 
 
 
 | 147 | 
     en_US (specified by the LANG or LC_ALL variables), collation order is | 
 
 
 
 
 
 | 148 | 
     locale-dependent.  For example, the en_US locale sorts the upper and | 
 
 
 
 
 
 | 149 | 
     lower case letters like this: | 
 
 
 
 
 
 | 150 | 
  | 
 
 
 
 
 
 | 151 | 
         AaBb...Zz | 
 
 
 
 
 
 | 152 | 
  | 
 
 
 
 
 
 | 153 | 
     so a range specification like [A-Z] will match every letter except `z'. | 
 
 
 
 
 
 | 154 | 
     Other locales collate like | 
 
 
 
 
 
 | 155 | 
  | 
 
 
 
 
 
 | 156 | 
         aAbBcC...zZ | 
 
 
 
 
 
 | 157 | 
  | 
 
 
 
 
 
 | 158 | 
     which means that [A-Z] matches every letter except `a'. | 
 
 
 
 
 
 | 159 | 
  | 
 
 
 
 
 
 | 160 | 
     The portable way to specify upper case letters is [:upper:] instead of | 
 
 
 
 
 
 | 161 | 
     A-Z; lower case may be specified as [:lower:] instead of a-z. | 
 
 
 
 
 
 | 162 | 
  | 
 
 
 
 
 
 | 163 | 
     Look at the manual pages for setlocale(3), strcoll(3), and, if it is | 
 
 
 
 
 
 | 164 | 
     present, locale(1). | 
 
 
 
 
 
 | 165 | 
  | 
 
 
 
 
 
 | 166 | 
     You can find your current locale information by running locale(1): | 
 
 
 
 
 
 | 167 | 
  | 
 
 
 
 
 
 | 168 | 
         caleb.ins.cwru.edu(2)$ locale | 
 
 
 
 
 
 | 169 | 
         LANG=en_US | 
 
 
 
 
 
 | 170 | 
         LC_CTYPE="en_US" | 
 
 
 
 
 
 | 171 | 
         LC_NUMERIC="en_US" | 
 
 
 
 
 
 | 172 | 
         LC_TIME="en_US" | 
 
 
 
 
 
 | 173 | 
         LC_COLLATE="en_US" | 
 
 
 
 
 
 | 174 | 
         LC_MONETARY="en_US" | 
 
 
 
 
 
 | 175 | 
         LC_MESSAGES="en_US" | 
 
 
 
 
 
 | 176 | 
         LC_ALL=en_US | 
 
 
 
 
 
 | 177 | 
  | 
 
 
 
 
 
 | 178 | 
     My advice is to put | 
 
 
 
 
 
 | 179 | 
  | 
 
 
 
 
 
 | 180 | 
         export LC_COLLATE=C | 
 
 
 
 
 
 | 181 | 
  | 
 
 
 
 
 
 | 182 | 
     into /etc/profile and inspect any shell scripts run from cron for | 
 
 
 
 
 
 | 183 | 
     constructs like [A-Z].  This will prevent things like | 
 
 
 
 
 
 | 184 | 
  | 
 
 
 
 
 
 | 185 | 
         rm [A-Z]* | 
 
 
 
 
 
 | 186 | 
  | 
 
 
 
 
 
 | 187 | 
     from removing every file in the current directory except those beginning | 
 
 
 
 
 
 | 188 | 
     with `z' and still allow individual users to change the collation order. | 
 
 
 
 
 
 | 189 | 
     Users may put the above command into their own profiles as well, of course. | 
 
 
 
 
 
 | 190 | 
  | 
 
 
 
 
 
 | 191 | 
 14. Bash versions up to 1.14.7 included an undocumented `-l' operator to | 
 
 
 
 
 
 | 192 | 
     the `test/[' builtin.  It was a unary operator that expanded to the | 
 
 
 
 
 
 | 193 | 
     length of its string argument.  This let you do things like | 
 
 
 
 
 
 | 194 | 
  | 
 
 
 
 
 
 | 195 | 
         test -l $variable -lt 20 | 
 
 
 
 
 
 | 196 | 
  | 
 
 
 
 
 
 | 197 | 
     for example. | 
 
 
 
 
 
 | 198 | 
  | 
 
 
 
 
 
 | 199 | 
     This was included for backwards compatibility with old versions of the | 
 
 
 
 
 
 | 200 | 
     Bourne shell, which did not provide an easy way to obtain the length of | 
 
 
 
 
 
 | 201 | 
     the value of a shell variable. | 
 
 
 
 
 
 | 202 | 
  | 
 
 
 
 
 
 | 203 | 
     This operator is not part of the POSIX standard, because one can (and | 
 
 
 
 
 
 | 204 | 
     should) use ${#variable} to get the length of a variable's value. | 
 
 
 
 
 
 | 205 | 
     Bash-2.x does not support it. | 
 
 
 
 
 
 | 206 | 
  | 
 
 
 
 
 
 | 207 | 
 15. Bash no longer auto-exports the HOME, PATH, SHELL, TERM, HOSTNAME, | 
 
 
 
 
 
 | 208 | 
     HOSTTYPE, MACHTYPE, or OSTYPE variables.  If they appear in the initial | 
 
 
 
 
 
 | 209 | 
     environment, the export attribute will be set, but if bash provides a | 
 
 
 
 
 
 | 210 | 
     default value, they will remain local to the current shell. | 
 
 
 
 
 
 | 211 | 
  | 
 
 
 
 
 
 | 212 | 
 16. Bash no longer initializes the FUNCNAME, GROUPS, or DIRSTACK variables | 
 
 
 
 
 
 | 213 | 
     to have special behavior if they appear in the initial environment. | 
 
 
 
 
 
 | 214 | 
  | 
 
 
 
 
 
 | 215 | 
 17. Bash no longer removes the export attribute from the SSH_CLIENT or | 
 
 
 
 
 
 | 216 | 
     SSH2_CLIENT variables, and no longer attempts to discover whether or | 
 
 
 
 
 
 | 217 | 
     not it has been invoked by sshd in order to run the startup files. | 
 
 
 
 
 
 | 218 | 
  | 
 
 
 
 
 
 | 219 | 
 18. Bash no longer requires that the body of a function be a group command; | 
 
 
 
 
 
 | 220 | 
     any compound command is accepted. | 
 
 
 
 
 
 | 221 | 
  | 
 
 
 
 
 
 | 222 | 
 19. As of bash-3.0, the pattern substitution operators no longer perform | 
 
 
 
 
 
 | 223 | 
     quote removal on the pattern before attempting the match.  This is the | 
 
 
 
 
 
 | 224 | 
     way the pattern removal functions behave, and is more consistent. | 
 
 
 
 
 
 | 225 | 
  | 
 
 
 
 
 
 | 226 | 
 20. After bash-3.0 was released, I reimplemented tilde expansion, incorporating | 
 
 
 
 
 
 | 227 | 
     it into the mainline word expansion code.  This fixes the bug that caused | 
 
 
 
 
 
 | 228 | 
     the results of tilde expansion to be re-expanded.  There is one | 
 
 
 
 
 
 | 229 | 
     incompatibility:  a ${paramOPword} expansion within double quotes will not | 
 
 
 
 
 
 | 230 | 
     perform tilde expansion on WORD.  This is consistent with the other | 
 
 
 
 
 
 | 231 | 
     expansions, and what POSIX specifies. | 
 
 
 
 
 
 | 232 | 
  | 
 
 
 
 
 
 | 233 | 
 21. A number of variables have the integer attribute by default, so the += | 
 
 
 
 
 
 | 234 | 
     assignment operator returns expected results: RANDOM, LINENO, MAILCHECK, | 
 
 
 
 
 
 | 235 | 
     HISTCMD, OPTIND. | 
 
 
 
 
 
 | 236 | 
  | 
 
 
 
 
 
 | 237 | 
 22. Bash-3.x is much stricter about $LINENO correctly reflecting the line | 
 
 
 
 
 
 | 238 | 
     number in a script; assignments to LINENO have little effect. | 
 
 
 
 
 
 | 239 | 
  | 
 
 
 
 
 
 | 240 | 
 23. By default, readline binds the terminal special characters to their | 
 
 
 
 
 
 | 241 | 
     readline equivalents.  As of bash-3.1/readline-5.1, this is optional and | 
 
 
 
 
 
 | 242 | 
     controlled by the bind-tty-special-chars readline variable. | 
 
 
 
 
 
 | 243 | 
  | 
 
 
 
 
 
 | 244 | 
 24. The \W prompt string expansion abbreviates $HOME as `~'.  The previous | 
 
 
 
 
 
 | 245 | 
     behavior is available with ${PWD##/*/}. | 
 
 
 
 
 
 | 246 | 
  | 
 
 
 
 
 
 | 247 | 
 25. The arithmetic exponentiation operator is right-associative as of bash-3.1. | 
 
 
 
 
 
 | 248 | 
  | 
 
 
 
 
 
 | 249 | 
 26. The rules concerning valid alias names are stricter, as per POSIX.2. | 
 
 
 
 
 
 | 250 | 
  | 
 
 
 
 
 
 | 251 | 
 27. The Readline key binding functions now obey the convert-meta setting active | 
 
 
 
 
 
 | 252 | 
     when the binding takes place, as the dispatch code does when characters | 
 
 
 
 
 
 | 253 | 
     are read and processed. | 
 
 
 
 
 
 | 254 | 
  | 
 
 
 
 
 
 | 255 | 
 28. The historical behavior of `trap' reverting signal disposition to the | 
 
 
 
 
 
 | 256 | 
     original handling in the absence of a valid first argument is implemented | 
 
 
 
 
 
 | 257 | 
     only if the first argument is a valid signal number. | 
 
 
 
 
 
 | 258 | 
  | 
 
 
 
 
 
 | 259 | 
 29. In versions of bash after 3.1, the ${parameter//pattern/replacement} | 
 
 
 
 
 
 | 260 | 
     expansion does not interpret `%' or `#' specially.  Those anchors don't | 
 
 
 
 
 
 | 261 | 
     have any real meaning when replacing every match. | 
 
 
 
 
 
 | 262 | 
  | 
 
 
 
 
 
 | 263 | 
 30. Beginning with bash-3.1, the combination of posix mode and enabling the | 
 
 
 
 
 
 | 264 | 
     `xpg_echo' option causes echo to ignore all options, not looking for `-n' | 
 
 
 
 
 
 | 265 | 
  | 
 
 
 
 
 
 | 266 | 
 31. Beginning with bash-3.2, bash follows the Bourne-shell-style (and POSIX- | 
 
 
 
 
 
 | 267 | 
     style) rules for parsing the contents of old-style backquoted command | 
 
 
 
 
 
 | 268 | 
     substitutions.  Previous versions of bash attempted to recursively parse | 
 
 
 
 
 
 | 269 | 
     embedded quoted strings and shell constructs; bash-3.2 uses strict POSIX | 
 
 
 
 
 
 | 270 | 
     rules to find the closing backquote and simply passes the contents of the | 
 
 
 
 
 
 | 271 | 
     command substitution to a subshell for parsing and execution. | 
 
 
 
 
 
 | 272 | 
  | 
 
 
 
 
 
 | 273 | 
 32. Beginning with bash-3.2, bash uses access(2) when executing primaries for | 
 
 
 
 
 
 | 274 | 
     the test builtin and the [[ compound command, rather than looking at the | 
 
 
 
 
 
 | 275 | 
     file permission bits obtained with stat(2).  This obeys restrictions of | 
 
 
 
 
 
 | 276 | 
     the file system (e.g., read-only or noexec mounts) not available via stat. | 
 
 
 
 
 
 | 277 | 
  | 
 
 
 
 
 
 | 278 | 
 33. Bash-3.2 adopts the convention used by other string and pattern matching | 
 
 
 
 
 
 | 279 | 
     operators for the `[[' compound command, and matches any quoted portion | 
 
 
 
 
 
 | 280 | 
     of the right-hand-side argument to the =~ operator as a string rather | 
 
 
 
 
 
 | 281 | 
     than a regular expression. | 
 
 
 
 
 
 | 282 | 
  | 
 
 
 
 
 
 | 283 | 
 34. Bash-4.0 allows the behavior in the previous item to be modified using | 
 
 
 
 
 
 | 284 | 
     the notion of a shell `compatibility level'.  If the compat31 shopt | 
 
 
 
 
 
 | 285 | 
     option is set, quoting the pattern has no special effect. | 
 
 
 
 
 
 | 286 | 
  | 
 
 
 
 
 
 | 287 | 
 35. Bash-3.2 (patched) and Bash-4.0 fix a bug that leaves the shell in an | 
 
 
 
 
 
 | 288 | 
     inconsistent internal state following an assignment error.  One of the | 
 
 
 
 
 
 | 289 | 
     changes means that compound commands or { ... } grouping commands are | 
 
 
 
 
 
 | 290 | 
     aborted under some circumstances in which they previously were not. | 
 
 
 
 
 
 | 291 | 
     This is what Posix specifies. | 
 
 
 
 
 
 | 292 | 
  | 
 
 
 
 
 
 | 293 | 
 36. Bash-4.0 now allows process substitution constructs to pass unchanged | 
 
 
 
 
 
 | 294 | 
     through brace expansion, so any expansion of the contents will have to be | 
 
 
 
 
 
 | 295 | 
     separately specified, and each process substitution will have to be | 
 
 
 
 
 
 | 296 | 
     separately entered. | 
 
 
 
 
 
 | 297 | 
  | 
 
 
 
 
 
 | 298 | 
 37. Bash-4.0 now allows SIGCHLD to interrupt the wait builtin, as Posix | 
 
 
 
 
 
 | 299 | 
     specifies, so the SIGCHLD trap is no longer always invoked once per | 
 
 
 
 
 
 | 300 | 
     exiting child if you are using `wait' to wait for all children.  As | 
 
 
 
 
 
 | 301 | 
     of bash-4.2, this is the status quo only when in posix mode. | 
 
 
 
 
 
 | 302 | 
  | 
 
 
 
 
 
 | 303 | 
 38. Since bash-4.0 now follows Posix rules for finding the closing delimiter | 
 
 
 
 
 
 | 304 | 
     of a $() command substitution, it will not behave as previous versions | 
 
 
 
 
 
 | 305 | 
     did, but will catch more syntax and parsing errors before spawning a | 
 
 
 
 
 
 | 306 | 
     subshell to evaluate the command substitution. | 
 
 
 
 
 
 | 307 | 
  | 
 
 
 
 
 
 | 308 | 
 39. The programmable completion code uses the same set of delimiting characters | 
 
 
 
 
 
 | 309 | 
     as readline when breaking the command line into words, rather than the | 
 
 
 
 
 
 | 310 | 
     set of shell metacharacters, so programmable completion and readline | 
 
 
 
 
 
 | 311 | 
     should be more consistent. | 
 
 
 
 
 
 | 312 | 
  | 
 
 
 
 
 
 | 313 | 
 40. When the read builtin times out, it attempts to assign any input read to | 
 
 
 
 
 
 | 314 | 
     specified variables, which also causes variables to be set to the empty | 
 
 
 
 
 
 | 315 | 
     string if there is not enough input.  Previous versions discarded the | 
 
 
 
 
 
 | 316 | 
     characters read. | 
 
 
 
 
 
 | 317 | 
  | 
 
 
 
 
 
 | 318 | 
 41. Beginning with bash-4.0, when one of the commands in a pipeline is killed | 
 
 
 
 
 
 | 319 | 
     by a SIGINT while executing a command list, the shell acts as if it | 
 
 
 
 
 
 | 320 | 
     received the interrupt.  This can be disabled by setting the compat31 or | 
 
 
 
 
 
 | 321 | 
     compat32 shell options. | 
 
 
 
 
 
 | 322 | 
  | 
 
 
 
 
 
 | 323 | 
 42. Bash-4.0 changes the handling of the set -e option so that the shell exits | 
 
 
 
 
 
 | 324 | 
     if a pipeline fails (and not just if the last command in the failing | 
 
 
 
 
 
 | 325 | 
     pipeline is a simple command).  This is not as Posix specifies.  There is | 
 
 
 
 
 
 | 326 | 
     work underway to update this portion of the standard; the bash-4.0 | 
 
 
 
 
 
 | 327 | 
     behavior attempts to capture the consensus at the time of release. | 
 
 
 
 
 
 | 328 | 
  | 
 
 
 
 
 
 | 329 | 
 43. Bash-4.0 fixes a Posix mode bug that caused the . (source) builtin to | 
 
 
 
 
 
 | 330 | 
     search the current directory for its filename argument, even if "." is | 
 
 
 
 
 
 | 331 | 
     not in $PATH.  Posix says that the shell shouldn't look in $PWD in this | 
 
 
 
 
 
 | 332 | 
     case. | 
 
 
 
 
 
 | 333 | 
  | 
 
 
 
 
 
 | 334 | 
 44. Bash-4.1 uses the current locale when comparing strings using the < and | 
 
 
 
 
 
 | 335 | 
     > operators to the `[[' command.  This can be reverted to the previous | 
 
 
 
 
 
 | 336 | 
     behavior (ASCII collating and strcmp(3)) by setting one of the | 
 
 
 
 
 
 | 337 | 
     `compatNN' shopt options, where NN is less than 41. | 
 
 
 
 
 
 | 338 | 
  | 
 
 
 
 
 
 | 339 | 
 45. Bash-4.1 conforms to the current Posix specification for `set -u': | 
 
 
 
 
 
 | 340 | 
     expansions of $@ and $* when there are no positional parameters do not | 
 
 
 
 
 
 | 341 | 
     cause the shell to exit. | 
 
 
 
 
 
 | 342 | 
  | 
 
 
 
 
 
 | 343 | 
 46. Bash-4.1 implements the current Posix specification for `set -e' and | 
 
 
 
 
 
 | 344 | 
     exits when any command fails, not just a simple command or pipeline. | 
 
 
 
 
 
 | 345 | 
  | 
 
 
 
 
 
 | 346 | 
 47. Command substitutions now remove the caller's trap strings when trap is | 
 
 
 
 
 
 | 347 | 
     run to set a new trap in the subshell.  Previous to bash-4.2, the old | 
 
 
 
 
 
 | 348 | 
     trap strings persisted even though the actual signal handlers were reset. | 
 
 
 
 
 
 | 349 | 
  | 
 
 
 
 
 
 | 350 | 
 48. When in Posix mode, a single quote is not treated specially in a | 
 
 
 
 
 
 | 351 | 
     double-quoted ${...} expansion, unless the expansion operator is | 
 
 
 
 
 
 | 352 | 
     # or % or the new `//', `^', or `,' expansions.  In particular, it | 
 
 
 
 
 
 | 353 | 
     does not define a new quoting context.  This is from Posix interpretation | 
 
 
 
 
 
 | 354 | 
     221. | 
 
 
 
 
 
 | 355 | 
  | 
 
 
 
 
 
 | 356 | 
 49. Posix mode shells no longer exit if a variable assignment error occurs | 
 
 
 
 
 
 | 357 | 
     with an assignment preceding a command that is not a special builtin. | 
 
 
 
 
 
 | 358 | 
  | 
 
 
 
 
 
 | 359 | 
 50. Bash-4.2 attempts to preserve what the user typed when performing word | 
 
 
 
 
 
 | 360 | 
     completion, instead of, for instance, expanding shell variable | 
 
 
 
 
 
 | 361 | 
     references to their value. | 
 
 
 
 
 
 | 362 | 
  | 
 
 
 
 
 
 | 363 | 
 51. When in Posix mode, bash-4.2 exits if the filename supplied as an argument | 
 
 
 
 
 
 | 364 | 
     to `.' is not found and the shell is not interactive. | 
 
 
 
 
 
 | 365 | 
  | 
 
 
 
 
 
 | 366 | 
 52. When compiled for strict Posix compatibility, bash-4.3 does not enable | 
 
 
 
 
 
 | 367 | 
     history expansion by default in interactive shells, since it results in | 
 
 
 
 
 
 | 368 | 
     a non-conforming environment. | 
 
 
 
 
 
 | 369 | 
  | 
 
 
 
 
 
 | 370 | 
 53. Bash-4.3 runs the replacement string in the pattern substitution word | 
 
 
 
 
 
 | 371 | 
     expansion through quote removal.  The code already treats quote | 
 
 
 
 
 
 | 372 | 
     characters in the replacement string as special; if it treats them as | 
 
 
 
 
 
 | 373 | 
     special, then quote removal should remove them. | 
 
 
 
 
 
 | 374 | 
  | 
 
 
 
 
 
 | 375 | 
 54. Bash-4.4 no longer considers a reference to ${a[@]} or ${a[*]}, where `a' | 
 
 
 
 
 
 | 376 | 
     is an array without any elements set, to be a reference to an unset | 
 
 
 
 
 
 | 377 | 
     variable.  This means that such a reference will not cause the shell to | 
 
 
 
 
 
 | 378 | 
     exit when the `-u' option is enabled. | 
 
 
 
 
 
 | 379 | 
  | 
 
 
 
 
 
 | 380 | 
 55. Bash-4.4 allows double quotes to quote the history expansion character (!) | 
 
 
 
 
 
 | 381 | 
     when in Posix mode, since Posix specifies the effects of double quotes. | 
 
 
 
 
 
 | 382 | 
  | 
 
 
 
 
 
 | 383 | 
 56. Bash-4.4 does not inherit $PS4 from the environment if running as root. | 
 
 
 
 
 
 | 384 | 
  | 
 
 
 
 
 
 | 385 | 
 57. Bash-4.4 doesn't allow a `break' or `continue' in a function to affect | 
 
 
 
 
 
 | 386 | 
     loop execution in the calling context. | 
 
 
 
 
 
 | 387 | 
  | 
 
 
 
 
 
 | 388 | 
 58. Bash-4.4 no longer expands tildes in $PATH elements when in Posix mode. | 
 
 
 
 
 
 | 389 | 
  | 
 
 
 
 
 
 | 390 | 
 59. Bash-4.4 does not attempt to perform a compound array assignment if an | 
 
 
 
 
 
 | 391 | 
     argument to `declare' or a similar builtin expands to a word that looks | 
 
 
 
 
 
 | 392 | 
     like a compound array assignment (e.g. declare w=$x where x='(foo)'). | 
 
 
 
 
 
 | 393 | 
  | 
 
 
 
 
 
 | 394 | 
 60. Bash-5.0 only sets up BASH_ARGV and BASH_ARGC at startup if extended | 
 
 
 
 
 
 | 395 | 
     debugging mode is active. The old behavior of unconditionally setting | 
 
 
 
 
 
 | 396 | 
     BASH_ARGC and BASH_ARGV is available at compatibility levels less than | 
 
 
 
 
 
 | 397 | 
     or equal to 44. | 
 
 
 
 
 
 | 398 | 
  | 
 
 
 
 
 
 | 399 | 
 61. Bash-5.0 doesn't allow a `break' or `continue' in a subshell to attempt | 
 
 
 
 
 
 | 400 | 
     to break or continue loop execution inherited from the calling context. | 
 
 
 
 
 
 | 401 | 
  | 
 
 
 
 
 
 | 402 | 
 62. Bash-5.0 doesn't allow variable assignments preceding builtins like | 
 
 
 
 
 
 | 403 | 
     export and readonly to modify variables with the same name in preceding | 
 
 
 
 
 
 | 404 | 
     contexts (including the global context) unless the shell is in posix | 
 
 
 
 
 
 | 405 | 
     mode, since export and readonly are special builtins. | 
 
 
 
 
 
 | 406 | 
  | 
 
 
 
 
 
 | 407 | 
 63. Bash-5.1 changes the way posix-mode shells handle assignment statements | 
 
 
 
 
 
 | 408 | 
     preceding shell function calls. Previous versions of POSIX specified that | 
 
 
 
 
 
 | 409 | 
     such assignments would persist after the function returned; subsequent | 
 
 
 
 
 
 | 410 | 
     versions of the standard removed that requirement (interpretation #654). | 
 
 
 
 
 
 | 411 | 
     Bash-5.1 posix mode assignment statements preceding shell function calls | 
 
 
 
 
 
 | 412 | 
     do not persist after the function returns. | 
 
 
 
 
 
 | 413 | 
  | 
 
 
 
 
 
 | 414 | 
 64. Bash-5.1 reverts to the bash-4.4 treatment of pathname expansion of words | 
 
 
 
 
 
 | 415 | 
     containing backslashes but no other special globbing characters. This comes | 
 
 
 
 
 
 | 416 | 
     after a protracted discussion and a POSIX interpretation (#1234). | 
 
 
 
 
 
 | 417 | 
  | 
 
 
 
 
 
 | 418 | 
 65. In bash-5.1, disabling posix mode attempts to restore the state of several | 
 
 
 
 
 
 | 419 | 
     options that posix mode modifies to the state they had before enabling | 
 
 
 
 
 
 | 420 | 
     posix mode. Previous versions restored these options to default values. | 
 
 
 
 
 
 | 421 | 
  | 
 
 
 
 
 
 | 422 | 
  | 
 
 
 
 
 
 | 423 | 
 Shell Compatibility Level | 
 
 
 
 
 
 | 424 | 
 ========================= | 
 
 
 
 
 
 | 425 | 
  | 
 
 
 
 
 
 | 426 | 
 Bash-4.0 introduced the concept of a `shell compatibility level', specified | 
 
 
 
 
 
 | 427 | 
 as a set of options to the shopt builtin (compat31, compat32, compat40, | 
 
 
 
 
 
 | 428 | 
 compat41, and so on).  There is only one current compatibility level -- | 
 
 
 
 
 
 | 429 | 
 each option is mutually exclusive.  The compatibility level is intended to | 
 
 
 
 
 
 | 430 | 
 allow users to select behavior from previous versions that is incompatible | 
 
 
 
 
 
 | 431 | 
 with newer versions while they migrate scripts to use current features and | 
 
 
 
 
 
 | 432 | 
 behavior.  It's intended to be a temporary solution.  | 
 
 
 
 
 
 | 433 | 
  | 
 
 
 
 
 
 | 434 | 
 This section does not mention behavior that is standard for a particular | 
 
 
 
 
 
 | 435 | 
 version (e.g., setting compat32 means that quoting the rhs of the regexp | 
 
 
 
 
 
 | 436 | 
 matching operator quotes special regexp characters in the word, which is | 
 
 
 
 
 
 | 437 | 
 default behavior in bash-3.2 and above).  | 
 
 
 
 
 
 | 438 | 
  | 
 
 
 
 
 
 | 439 | 
 If a user enables, say, compat32, it may affect the behavior of other | 
 
 
 
 
 
 | 440 | 
 compatibility levels up to and including the current compatibility level.  | 
 
 
 
 
 
 | 441 | 
 The idea is that each compatibility level controls behavior that changed in | 
 
 
 
 
 
 | 442 | 
 that version of bash, but that behavior may have been present in earlier | 
 
 
 
 
 
 | 443 | 
 versions.  For instance, the change to use locale-based comparisons with | 
 
 
 
 
 
 | 444 | 
 the `[[' command came in bash-4.1, and earlier versions used ASCII-based | 
 
 
 
 
 
 | 445 | 
 comparisons, so enabling compat32 will enable ASCII-based comparisons as | 
 
 
 
 
 
 | 446 | 
 well.  That granularity may not be sufficient for all uses, and as a result | 
 
 
 
 
 
 | 447 | 
 users should employ compatibility levels carefully.  Read the documentation | 
 
 
 
 
 
 | 448 | 
 for a particular feature to find out the current behavior.  | 
 
 
 
 
 
 | 449 | 
  | 
 
 
 
 
 
 | 450 | 
 Bash-4.3 introduced a new shell variable: BASH_COMPAT. The value assigned | 
 
 
 
 
 
 | 451 | 
 to this variable (a decimal version number like 4.2, or an integer | 
 
 
 
 
 
 | 452 | 
 corresponding to the compatNN option, like 42) determines the compatibility | 
 
 
 
 
 
 | 453 | 
 level. | 
 
 
 
 
 
 | 454 | 
  | 
 
 
 
 
 
 | 455 | 
 Starting with bash-4.4, bash has begun deprecating older compatibility | 
 
 
 
 
 
 | 456 | 
 levels.  Eventually, the options will be removed in favor of the | 
 
 
 
 
 
 | 457 | 
 BASH_COMPAT variable.  | 
 
 
 
 
 
 | 458 | 
  | 
 
 
 
 
 
 | 459 | 
 Bash-5.0 is the final version for which there will be an individual shopt | 
 
 
 
 
 
 | 460 | 
 option for the previous version.  Users should use the BASH_COMPAT variable | 
 
 
 
 
 
 | 461 | 
 on bash-5.0 and later versions.  | 
 
 
 
 
 
 | 462 | 
  | 
 
 
 
 
 
 | 463 | 
 The following table describes the behavior changes controlled by each | 
 
 
 
 
 
 | 464 | 
 compatibility level setting.  The `compatNN' tag is used as shorthand for | 
 
 
 
 
 
 | 465 | 
 setting the compatibility level to NN using one of the following | 
 
 
 
 
 
 | 466 | 
 mechanisms.  For versions prior to bash-5.0, the compatibility level may be | 
 
 
 
 
 
 | 467 | 
 set using the corresponding compatNN shopt option.  For bash-4.3 and later | 
 
 
 
 
 
 | 468 | 
 versions, the BASH_COMPAT variable is preferred, and it is required for | 
 
 
 
 
 
 | 469 | 
 bash-5.1 and later versions.  | 
 
 
 
 
 
 | 470 | 
  | 
 
 
 
 
 
 | 471 | 
 compat31 | 
 
 
 
 
 
 | 472 | 
         - the < and > operators to the [[ command do not consider the current | 
 
 
 
 
 
 | 473 | 
           locale when comparing strings; they use ASCII ordering | 
 
 
 
 
 
 | 474 | 
         - quoting the rhs of the [[ command's regexp matching operator (=~) | 
 
 
 
 
 
 | 475 | 
           has no special effect | 
 
 
 
 
 
 | 476 | 
  | 
 
 
 
 
 
 | 477 | 
 compat32 | 
 
 
 
 
 
 | 478 | 
         - the < and > operators to the [[ command do not consider the current | 
 
 
 
 
 
 | 479 | 
           locale when comparing strings; they use ASCII ordering | 
 
 
 
 
 
 | 480 | 
         - interrupting a command list such as "a ; b ; c" causes the execution | 
 
 
 
 
 
 | 481 | 
           of the next command in the list (in bash-4.0 and later versions, | 
 
 
 
 
 
 | 482 | 
           the shell acts as if it received the interrupt, so interrupting | 
 
 
 
 
 
 | 483 | 
           one command in a list aborts the execution of the entire list) | 
 
 
 
 
 
 | 484 | 
  | 
 
 
 
 
 
 | 485 | 
 compat40 | 
 
 
 
 
 
 | 486 | 
         - the < and > operators to the [[ command do not consider the current | 
 
 
 
 
 
 | 487 | 
           locale when comparing strings; they use ASCII ordering. | 
 
 
 
 
 
 | 488 | 
           Bash versions prior to bash-4.1 use ASCII collation and strcmp(3); | 
 
 
 
 
 
 | 489 | 
           bash-4.1 and later use the current locale's collation sequence and | 
 
 
 
 
 
 | 490 | 
           strcoll(3). | 
 
 
 
 
 
 | 491 | 
  | 
 
 
 
 
 
 | 492 | 
 compat41 | 
 
 
 
 
 
 | 493 | 
         - in posix mode, `time' may be followed by options and still be | 
 
 
 
 
 
 | 494 | 
           recognized as a reserved word (this is POSIX interpretation 267) | 
 
 
 
 
 
 | 495 | 
         - in posix mode, the parser requires that an even number of single | 
 
 
 
 
 
 | 496 | 
           quotes occur in the `word' portion of a double-quoted ${...} | 
 
 
 
 
 
 | 497 | 
           parameter expansion and treats them specially, so that characters | 
 
 
 
 
 
 | 498 | 
           within the single quotes are considered quoted (this is POSIX | 
 
 
 
 
 
 | 499 | 
           interpretation 221) | 
 
 
 
 
 
 | 500 | 
  | 
 
 
 
 
 
 | 501 | 
 compat42 | 
 
 
 
 
 
 | 502 | 
         - the replacement string in double-quoted pattern substitution is not | 
 
 
 
 
 
 | 503 | 
           run through quote removal, as it is in versions after bash-4.2 | 
 
 
 
 
 
 | 504 | 
         - in posix mode, single quotes are considered special when expanding | 
 
 
 
 
 
 | 505 | 
           the `word' portion of a double-quoted ${...} parameter expansion | 
 
 
 
 
 
 | 506 | 
           and can be used to quote a closing brace or other special character | 
 
 
 
 
 
 | 507 | 
           (this is part of POSIX interpretation 221); in later versions, | 
 
 
 
 
 
 | 508 | 
           single quotes are not special within double-quoted word expansions | 
 
 
 
 
 
 | 509 | 
  | 
 
 
 
 
 
 | 510 | 
 compat43 | 
 
 
 
 
 
 | 511 | 
         - the shell does not print a warning message if an attempt is made to | 
 
 
 
 
 
 | 512 | 
           use a quoted compound assignment as an argument to declare | 
 
 
 
 
 
 | 513 | 
           (declare -a foo='(1 2)'). Later versions warn that this usage is | 
 
 
 
 
 
 | 514 | 
           deprecated. | 
 
 
 
 
 
 | 515 | 
         - word expansion errors are considered non-fatal errors that cause the | 
 
 
 
 
 
 | 516 | 
           current command to fail, even in posix mode (the default behavior is | 
 
 
 
 
 
 | 517 | 
           to make them fatal errors that cause the shell to exit) | 
 
 
 
 
 
 | 518 | 
         - when executing a shell function, the loop state (while/until/etc.) | 
 
 
 
 
 
 | 519 | 
           is not reset, so `break' or `continue' in that function will break | 
 
 
 
 
 
 | 520 | 
           or continue loops in the calling context. Bash-4.4 and later reset | 
 
 
 
 
 
 | 521 | 
           the loop state to prevent this | 
 
 
 
 
 
 | 522 | 
  | 
 
 
 
 
 
 | 523 | 
 compat44 | 
 
 
 
 
 
 | 524 | 
         - the shell sets up the values used by BASH_ARGV and BASH_ARGC so | 
 
 
 
 
 
 | 525 | 
           they can expand to the shell's positional parameters even if extended | 
 
 
 
 
 
 | 526 | 
           debug mode is not enabled | 
 
 
 
 
 
 | 527 | 
         - a subshell inherits loops from its parent context, so `break' | 
 
 
 
 
 
 | 528 | 
           or `continue' will cause the subshell to exit. Bash-5.0 and later | 
 
 
 
 
 
 | 529 | 
           reset the loop state to prevent the exit | 
 
 
 
 
 
 | 530 | 
         - variable assignments preceding builtins like export and readonly | 
 
 
 
 
 
 | 531 | 
           that set attributes continue to affect variables with the same | 
 
 
 
 
 
 | 532 | 
           name in the calling environment even if the shell is not in posix | 
 
 
 
 
 
 | 533 | 
           mode | 
 
 
 
 
 
 | 534 | 
  | 
 
 
 
 
 
 | 535 | 
 compat50 (set using BASH_COMPAT) | 
 
 
 
 
 
 | 536 | 
         - Bash-5.1 changed the way $RANDOM is generated to introduce slightly | 
 
 
 
 
 
 | 537 | 
           more randomness. If the shell compatibility level is set to 50 or | 
 
 
 
 
 
 | 538 | 
           lower, it reverts to the method from bash-5.0 and previous versions, | 
 
 
 
 
 
 | 539 | 
           so seeding the random number generator by assigning a value to | 
 
 
 
 
 
 | 540 | 
           RANDOM will produce the same sequence as in bash-5.0 | 
 
 
 
 
 
 | 541 | 
         - If the command hash table is empty, bash versions prior to bash-5.1 | 
 
 
 
 
 
 | 542 | 
           printed an informational message to that effect even when writing | 
 
 
 
 
 
 | 543 | 
           output in a format that can be reused as input (-l). Bash-5.1 | 
 
 
 
 
 
 | 544 | 
           suppresses that message if -l is supplied | 
 
 
 
 
 
 | 545 | 
  | 
 
 
 
 
 
 | 546 | 
  | 
 
 
 
 
 
 | 547 | 
 ------------------------------------------------------------------------------- | 
 
 
 
 
 
 | 548 | 
  | 
 
 
 
 
 
 | 549 | 
 Copying and distribution of this file, with or without modification, | 
 
 
 
 
 
 | 550 | 
 are permitted in any medium without royalty provided the copyright | 
 
 
 
 
 
 | 551 | 
 notice and this notice are preserved.  This file is offered as-is, | 
 
 
 
 
 
 | 552 | 
 without any warranty. |