1

bash 5.0

Screen Shot 2019-01-11 at 23.47.02.png
bash-5.0 on MacOS

Earlier this week we got a major upgrade to one of the most popular Unix shells in the world: BASH 5.0 (Bourne Again Sgell) was released on January 7, 2019.

Previous major release was bash 4.4, delivered in September 2016.

Unbelievable as it may sound, BASH was released in 1989, which makes it 30 years old!

Changes and Improvements in bash 5.0

Bugfixes

As expected over the period of 2+ years, lots of bug fixes were identified and resolved.

Readline 8.0

Readline is the library used by many projects, including bash, for advanced editing of the command lines. All these cool hotkeys for moving around the command line in bash (jumping words, editing/replacing characters) are provided by readline.

bash 5.0 shipped with readline 8.0 upgrade.

BASH_ARVG0 variable

You can now use this variable to confirm the name of the shell itself or the name of the script currently running:

greys@maverick:~ $ echo $BASH_ARGV0
/usr/local/Cellar/bash/5.0.0/bin/bash

EPOCHSECONDS variable

Very handy for timestamps, this variable returns the number of seconds since start of the Unix epoch.

EPOCHREALTIME

Another cool variable, EPOCHREALTIME reports Unix timestamps even more precisely: micro-second granularity is provided in addition to the Unix timestamp:

greys@maverick:~ $ echo $EPOCHREALTIME
1547250886.146766

For example, this simple one-liner can prove than sleeping for 1sec isn’t micro-second precise on my MacBook Pro. Notice how the micro-second part is slightly off every time:

greys@maverick:~ $ while true; do echo $EPOCHSECONDS; echo $EPOCHREALTIME; sleep 1; done
1547250913
1547250913.079728
1547250914
1547250914.097573
1547250915
1547250915.107237
1547250916
1547250916.118661
1547250917
1547250917.130726
^C

See also