The decade long wait for Bash 5

Full House

© Lead Image © ril, fotolia.com

© Lead Image © ril, fotolia.com

Article from Issue 223/2019
Author(s):

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.

Figure 1: The Bash homepage – without reference to the 30th anniversary.

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.

Figure 2: The new stable Bash ve

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

  1. "A Good Bash" by Bernhard Bablok and Nils Magnus, Linux Magazine, issue 105, August 2009 http://www.linuxpromagazine.com/Issues/2009/105/Bash-4
  2. Chet Ramey's Bash page: https://tiswww.case.edu/php/chet/bash/bashtop.html
  3. Official Bash website: https://www.gnu.org/software/bash/

The Author

Bernhard Bablok works at Allianz Technology SE as an SAP HR developer. When he's not listening to music, cycling, or walking, he deals with topics related to Linux, programming, and small computers. He can be reached at mailto:mail@bablokb.de.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Bash 4

    Despite the Bourne-again shell's biblical age and high level of maturity, developers continue to work on it. We take a look at the latest Bash release.

  • Letters

     

  • Scripting Tutorial for Bash 4.0

    The "Advanced Bash Scripting Guide" version 6 has been reworked to incorporate the new features of Bash 4.0.

  • Parallel Bash

    You don't need a heavy numeric mystery to benefit from the wonders of parallel processing. This article describes some simple techniques for parallelizing everyday bash scripts.

  • Bash Builtins

    Even beginners can benefit from a greater understanding of the Bash shell’s many builtin commands.

comments powered by Disqus
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.

Learn More

News