bash version check
Posted: 21.11.2022, 19:47
A recent patch from Eduardo de Oliveira for the file 30-check-needed-applications.bash included the comparison:
but this doesn't work as expected:
For example, this script:
prints the error message "You need at least bash-4.2 to run this script", although this version should be sufficient.
This script:
does not print any error message.
Fortunately, there never was a bash version 3.3; but I still think, this version check is rather flawed.
Greetings,
Hartmut
- Code: Select all
if ((BASH_VERSINFO[0] <= 4))
then
if ((BASH_VERSINFO[1] <= 2))
then
log_error_message "You need at least bash-4.2 to run this script"
missing_binaries="$(( missing_binaries + 1 ))"
fi
fi
but this doesn't work as expected:
- If the bash-version is 4.2.x then we get the error message "You need at least bash-4.2 to run this script".
- If the first version number is lower than 4, and the second version number is greater than 2, then we do not get any error message. This can be shown with versions numbers like 3.3.x.
For example, this script:
- Code: Select all
#!/bin/bash
VERSINFO=("4" "2" "0")
if ((VERSINFO[0] <= 4))
then
if ((VERSINFO[1] <= 2))
then
echo "You need at least bash-4.2 to run this script"
fi
fi
exit 0
prints the error message "You need at least bash-4.2 to run this script", although this version should be sufficient.
This script:
- Code: Select all
#!/bin/bash
VERSINFO=("3" "3" "0")
if ((VERSINFO[0] <= 4))
then
if ((VERSINFO[1] <= 2))
then
echo "You need at least bash-4.2 to run this script"
fi
fi
exit 0
does not print any error message.
Fortunately, there never was a bash version 3.3; but I still think, this version check is rather flawed.
Greetings,
Hartmut