I'M using associative arrays in my script, which are available in bash version 4 and upwards. In terms of best practices, should I verify the version is at least 4? E.g. using echo $BASH_VERSION | cut -d. -f1
.
Although bash 4 was released in early 2009, some OSes are still using older versions. E.g. the default bash on OS X is stuck on bash 3.2 (for legal reasons).
${BASH_VERSION%%.*}
if [[ $BASH_VERSION == 4.* ]]
;(( ${BASH_VERSION%%.*} >= 4 ))
, it's future proof for versions 5+