The decade long wait for Bash 5
Full House
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
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
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.