Some of the code requires Bash version 4.0 or later to work, so a check needs to be added to exit if the user has an old version.
if ((BASH_VERSINFO[0] < 4))
then
echo "Sorry, you need at least bash-4.0 to run this script."
exit 1
fi
Here's a breakdown of the BASH_VERSINFO array:
# Bash version information:
for n in 0 1 2 3 4 5
do
echo "BASH_VERSINFO[$n] = ${BASH_VERSINFO[$n]}"
done
# BASH_VERSINFO[0] = 5 # Major version no.
# BASH_VERSINFO[1] = 1 # Minor version no.
# BASH_VERSINFO[2] = 8 # Patch level.
# BASH_VERSINFO[3] = 1 # Build version.
# BASH_VERSINFO[4] = release # Release status.
# BASH_VERSINFO[5] = x86_64-redhat-linux-gnu # Architecture
# (same as $MACHTYPE).
# bash --version
GNU bash, version 5.1.8(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Some of the code requires Bash version 4.0 or later to work, so a check needs to be added to exit if the user has an old version.
Here's a breakdown of the BASH_VERSINFO array: