Add check for Bash >= 3.1 (required for += array assignment).
authorW. Trevor King <wking@drexel.edu>
Thu, 1 Dec 2011 12:51:24 +0000 (07:51 -0500)
committerW. Trevor King <wking@drexel.edu>
Thu, 1 Dec 2011 12:51:24 +0000 (07:51 -0500)
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

index d1305dd6d8915f22e67b126c25e032bf4b0496dc..b66059620768bfe43ea3e9a227d15ccafb3fa0c0 100755 (executable)
@@ -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()
 {