From dff2462c63f8046561043e6757c57b3a5c41c888 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 1 Dec 2011 07:51:24 -0500 Subject: [PATCH] Add check for Bash >= 3.1 (required for += array assignment). Browsing through the changelog http://git.savannah.gnu.org/cgit/bash.git/tree/CWRU/changelog the change that added += was 2004/11/05 general.c - change `assignment()' to accept `+=' assignment operator Looking through the released tarballs ftp://ftp.gnu.org/gnu/bash/ this change made it in between release 3.0.16 and 3.1. --- dotfiles.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dotfiles.sh b/dotfiles.sh index d1305dd..b660596 100755 --- a/dotfiles.sh +++ b/dotfiles.sh @@ -24,12 +24,21 @@ TOUCH=$(which touch) WGET=$(which wget) ##### -# Utility functions +# Compatibility checks BASH="${BASH_VERSION%.*}" BASH_MAJOR="${BASH%.*}" BASH_MINOR="${BASH#*.}" +if [ "${BASH_MAJOR}" -eq 3 ] && [ "${BASH_MINOR}" -eq 0 ]; then + echo "ERROR: ${0} requires Bash version >= 3.1" >&2 + echo "you're running ${BASH}, which doesn't support += array assignment" >&2 + exit 1 +fi + +##### +# Utility functions + # usage: nonempty_option LOC NAME VALUE function nonempty_option() { -- 2.26.2