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
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.
-
Plasma Desktop Will Soon Ask for Donations
The next iteration of Plasma has reached the soft feature freeze for the 6.2 version and includes a feature that could be divisive.
-
Linux Market Share Hits New High
For the first time, the Linux market share has reached a new high for desktops, and the trend looks like it will continue.
-
LibreOffice 24.8 Delivers New Features
LibreOffice is often considered the de facto standard office suite for the Linux operating system.
-
Deepin 23 Offers Wayland Support and New AI Tool
Deepin has been considered one of the most beautiful desktop operating systems for a long time and the arrival of version 23 has bolstered that reputation.
-
CachyOS Adds Support for System76's COSMIC Desktop
The August 2024 release of CachyOS includes support for the COSMIC desktop as well as some important bits for video.
-
Linux Foundation Adopts OMI to Foster Ethical LLMs
The Open Model Initiative hopes to create community LLMs that rival proprietary models but avoid restrictive licensing that limits usage.
-
Ubuntu 24.10 to Include the Latest Linux Kernel
Ubuntu users have grown accustomed to their favorite distribution shipping with a kernel that's not quite as up-to-date as other distros but that changes with 24.10.
-
Plasma Desktop 6.1.4 Release Includes Improvements and Bug Fixes
The latest release from the KDE team improves the KWin window and composite managers and plenty of fixes.
-
Manjaro Team Tests Immutable Version of its Arch-Based Distribution
If you're a fan of immutable operating systems, you'll be thrilled to know that the Manjaro team is working on an immutable spin that is now available for testing.