
A few days ago, the GNU project announced the release of the new version of Bash 5.3, the popular command interpreter that remains the default option in most Linux distributions.
This new version represents almost three years of work , during which improvements were not only made to the language and behavior of the shell, but new features were also introduced to align it with modern standards such as C23. It is also accompanied by the release of the Readline 8.3 library.
What's new in Bash 5.3
One of the most notable changes in Bash 5.3 is the introduction of new command substitution methods: `${ command; }` and `${|command;}` . These allow you to intercept the output of a command without creating a child process or using pipelines, thus reducing resource consumption and improving performance. The result can be stored directly in the `REPLY` variable, simplifying common output capture tasks.
Another new feature introduced in GNU Bash 5.3 is the new GLOBSORT variable, which allows you to define the sorting criteria when expanding file paths. Users can sort by name, size, modification date, and more, with options for both ascending and descending order.
In addition, Bash 5.3 introduces improvements to several built-in commands. The `compgen` command can now store generated completions in a variable (`-V varname`), while `read` now includes the `-E` option to use the Readline library with Bash's autocomplete rules. `source` has also been improved, now supporting `-p PATH` to modify the search path.
In addition, the umask command has been adjusted to fully comply with the POSIX specification , and printf has been improved with new options for multibyte strings and alternative character and string representation.
C23 compatibility and goodbye to the K&R C
One of the most significant structural changes is the adoption of the C23 standard in the Bash source code. As a result, support for "K&R C" mode compilation , a technique dating back to the early days of the C language, has been removed.
On the other hand, Bash 5.3 introduces several loadable commands such as:
- kv: to generate associative arrays from data in key-value format.
- strptime: converts dates in text format to Unix time.
- fltexpr: allows you to perform floating point arithmetic operations, emulating the behavior of let.
In addition, the dynamic variable BASH_MONOSECONDS is added , which provides a monotonic system time counter , useful for tasks where temporal stability is critical.
In POSIX mode, Bash now performs string comparisons with the < and > operators while respecting locale settings. It also aligns the behavior of commands like test, trap, wait, and bind, closely adhering to the standard's requirements. For example, `trap -P` allows you to print the trap action for each signal, and `wait -n` improves the handling of terminated processes and substitutions.
Readline 8.3
The Readline library, a companion to Bash, also received a major update. Among its most notable new features are:
- search-ignore-case: allows case-insensitive searches in history.
- export-completions: exports the possible completions of a word for external processing.
- execute-named-command: Executes commands whose name is read from standard input, useful for scripting and customization.
- Improved macro support, new configurable variables, and better handling of screen dimensions after a resume (SIGCONT).
Installing and/or Updating Bash on Linux
For those interested in installing or updating Bash on Linux, you should know that it depends on the distribution you're using. Below, I'll explain how to do it on the main distributions:
On Debian-based distributions (such as Ubuntu, Linux Mint)
sudo apt install --only-upgrade bash
This will update Bash to the latest version available in the official repositories.
If you want to install it from scratch (for example, on a very minimal system):
sudo apt install bash
On Red Hat-based distributions (such as Fedora, CentOS, RHEL)
sudo dnf update bash To install Bash (if it isn't already):
sudo dnf install bash
On Arch Linux and derivatives (such as Manjaro)
sudo pacman -Syu bash
This will update Bash along with the entire system. To install only Bash:
sudo pacman -S bash