24

I was just going through the official bash repository(I don't usually do this) for something unrelated but noticed that bash 5 was already in beta. I was just curious about what's going to be new in bash 5 but couldn't find any information. Can someone summarize the changes between 4.4 and 5 version of Bash

17

The changes made to bash between release 4.4 and 5.0 (released 2019-01-07) may be found in the NEWS file in the bash source distribution.

Here is a link to it (the changes are too numerous to list here).

  • A short view shows the term loadable builtins. Does bash follow the new standard set up by ksh93 to find enhanced builtins via PATH instead of giving them always priority? – schily Oct 30 '18 at 8:42
  • @schily bash 4.4 and later uses BASH_LOADABLES_PATH and loads them from there with enable -f builtin-name. – Kusalananda Oct 30 '18 at 10:17
  • Well, this seems to apply to the time when the command is loaded. What about about the time past that? enable looks like a reimplementation of the ksh93 command builtin but it misses the feature to associate a path to every builtin command, which in ksh93 is usually predefined by /usr/ast/bin/<name> and allows to have a fine grained control over all buiiltins. – schily Oct 30 '18 at 10:22
  • @Kusalananda how can I get a new bash 5.0 – Ankur Loriya Jan 8 at 3:45
  • @AnkurLoriya You wait until you Unix distributor ships it as a package, or you compile it yourself from sources. The sources and the installation instructions are available on the GNU Bash page. – Kusalananda Jan 8 at 7:21
12

If you, like me, are looking for the headline features rather than the full changelog, this post by the maintainer, Chet Ramey goes over that. Here is the interesting section:

This release fixes several outstanding bugs in bash-4.4 and introduces several new features. The most significant bug fixes are an overhaul of how nameref variables resolve and a number of potential out-of-bounds memory errors discovered via fuzzing. There are a number of changes to the expansion of $@ and $* in various contexts where word splitting is not performed to conform to a Posix standard interpretation, and additional changes to resolve corner cases for Posix conformance.

The most notable new features are several new shell variables: BASH_ARGV0, EPOCHSECONDS, and EPOCHREALTIME. The `history' builtin can remove ranges of history entries and understands negative arguments as offsets from the end of the history list. There is an option to allow local variables to inherit the value of a variable with the same name at a preceding scope. There is a new shell option that, when enabled, causes the shell to attempt to expand associative array subscripts only once (this is an issue when they are used in arithmetic expressions). The `globasciiranges' shell option is now enabled by default; it can be set to off by default at configuration time.

There are a few incompatible changes between bash-4.4 and bash-5.0. The changes to how nameref variables are resolved means that some uses of namerefs will behave differently, though I have tried to minimize the compatibility issues. By default, the shell only sets BASH_ARGC and BASH_ARGV at startup if extended debugging mode is enabled; it was an oversight that it was set unconditionally and caused performance issues when scripts were passed large numbers of arguments.

He also refers to these two files, in case you want more:

  • NEWS: more detail (also in Kusalananda's answer)
  • CHANGES: most detail
4

The `history' builtin can remove ranges of history entries and understands negative arguments as offsets from the end of the history list.

Example on deleting a range:

history -d 123-130

or deleting the last 10:

history -d -10--1

Excerpt from Bash 5 Man Page:

'history'

Options, if supplied, have the following meanings:

'-d OFFSET' Delete the history entry at position OFFSET. If OFFSET is positive, it should be specified as it appears when the history is displayed. If OFFSET is negative, it is interpreted as relative to one greater than the last history position, so negative indices count back from the end of the history, and an index of '-1' refers to the current 'history -d' command.

'-d START-END' Delete the history entries between positions START and END, inclusive. Positive and negative values for START and END are interpreted as described above.

See my related answer: Delete a range of bash history

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.