The decade long wait for Bash 5
Full House

© Lead Image © ril, fotolia.com
It's a coincidence that the Linux kernel and Bash jumped to version 5.0 at about the same time. While Linus assigns the numbers as he sees fit, Bash changes its version when major adjustments are made. Here's what users can expect in Bash 5.
My last article about a Bash version change is 10 years old [1]. Version 4 was in the starting blocks at that time, but it took some time for all distributions to switch to this version. Nobody puts their production system at risk without good reason.
Nevertheless, the change was very attractive for developers of complex scripts, because – thanks to associative arrays – a completely new data structure was introduced. The advantages were more elegant, simpler programs that were also easier to maintain. Other important changes included the coproc
command (which supports parallelization) and redirection operators.
Treasure Hunt
For Bash 5, the first job is to look at files such as NEWS
and CHANGES
to separate the important changes from the unimportant ones. These files are linked from the Bash page of maintainer Chet Ramey [2], who – keeping to the true spirit of Bash – almost completely does without graphical elements. The Bash homepage on [3] is in no way inferior (Figure 1). The NEWS
file lists 44 changes to Bash and another 11 to the Readline library used since the last stable version. This is information overkill in its purest form.
On closer inspection, you feel more like a gold digger – the yield in terms of actual nuggets is extremely low. Even for me, and I have written several 10,000 lines of Bash code in the course of my life and exhausted the functionality of Bash in many areas, most of the changes relate to fairly arcane border areas.
One example is associative arrays. In Bash 5, strings consisting only of blanks can also act as keys. This is certainly logical, but not a change that would make you want to migrate prematurely. The new EPOCHSECONDS
and EPOCHREALTIME
variables are more useful. The first now contains the Unix time (seconds since the beginning of the epoch); the second additionally has the microseconds.
For example, anyone who feeds measurement data into an RRD database every second benefits from this and saves the operating system an additional fork (Figure 2) by not having to call the external Date binary. A list of potentially interesting changes can be found in Table 1.
Table 1
Changes in Bash 5
Change | Comment |
---|---|
New variable EPOCHSECONDS |
Seconds since 01.01.1970 |
New variable EPOCHREALTIME |
Seconds since 01.01.1970 (with microseconds) |
New variable BASH_ARGV0 |
Program ($0), can be redefined |
New built-ins: rm, stat, fdflags, seq |
Less forks for external commands |
history -d with negative offsets |
Delete history, oldest first |
coproc Name now expands Name |
Dynamic coprocesses possible |
Bash is compilable with a static PATH |
For secure shells |
Associative and indexed arrays can also contain only spaces in the index |
More a logic change than an exciting feature |
Installation
Because of the very manageable number of epochal innovations, installing the new Bash is not really an attractive option. However, if you want to try out Bash 5.0 anyway, you can build the shell yourself. Alternatively, openSUSE's build service offers several experimental and community builds. The problem with these builds, however, is the additional dependency on new glibc versions, so an installation is almost equivalent to a complete update of the whole system.
Users of the rolling release version Tumbleweed offered by openSUSE will find RPM packages for Bash 5.0 and Readline 8 that ensure a simple update path. Arch Linux now also provides a Bash 5.0 package; other well-known Linux distributions are likely to follow soon.
Changes
Given the meager yield of genuine innovations, the question arises as to why the Bash developers changed the major version at all – at the end of the day, it still wasn't quite clear to me either. One potentially decisive hint results from the detailed study of the individual changes. There are also some incompatibilities to the previous version.
Unlike the Linux kernel, changing the version for compatibility reasons is a common procedure for many software projects. If backward compatibility is broken, the team increments the major number. This sometimes leads to the situation where, for years, several versions require active support – Python is a notorious example.
Bash 5.0 basically shows that the scripting language has reached a mature state in the meantime. Like with the last change from Bash 3 to Bash 4, the major distributions will update to the current Bash in upcoming versions and almost no one will notice this change. By then, the worst of the newly-introduced bugs should have been fixed.
Infos
- "A Good Bash" by Bernhard Bablok and Nils Magnus, Linux Magazine, issue 105, August 2009 http://www.linuxpromagazine.com/Issues/2009/105/Bash-4
- Chet Ramey's Bash page: https://tiswww.case.edu/php/chet/bash/bashtop.html
- Official Bash website: https://www.gnu.org/software/bash/
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Direct Download
Read full article as PDF:
Price $2.95
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.
News
-
Linux Mint Finally Receiving Support for Gestures
If you use the Linux Mint Cinnamon desktop, you'll be thrilled to know that 21.2 is getting support for gestures on touchscreen devices and touchpads.
-
An All-Snap Version of Ubuntu is In The Works
Along with the standard deb version of the open-source operating system, Canonical will release an-all snap version.
-
Mageia 9 Beta 2 Ready for Testing
The latest beta of the popular Mageia distribution now includes the latest kernel and plenty of updated applications.
-
KDE Plasma 6 Looks to Bring Basic HDR Support
The KWin piece of KDE Plasma now has HDR support and color management geared for the 6.0 release.
-
Bodhi Linux 7.0 Beta Ready for Testing
The latest iteration of the Bohdi Linux distribution is now available for those who want to experience what's in store and for testing purposes.
-
Changes Coming to Ubuntu PPA Usage
The way you manage Personal Package Archives will be changing with the release of Ubuntu 23.10.
-
AlmaLinux 9.2 Now Available for Download
AlmaLinux has been released and provides a free alternative to upstream Red Hat Enterprise Linux.
-
An Immutable Version of Fedora Is Under Consideration
For anyone who's a fan of using immutable versions of Linux, the Fedora team is currently considering adding a new spin called Fedora Onyx.
-
New Release of Br OS Includes ChatGPT Integration
Br OS 23.04 is now available and is geared specifically toward web content creation.
-
Command-Line Only Peropesis 2.1 Available Now
The latest iteration of Peropesis has been released with plenty of updates and introduces new software development tools.