Raise an error if the user tries to use wget-based repos with Bash < 4.0.
authorW. Trevor King <wking@drexel.edu>
Wed, 30 Nov 2011 20:50:18 +0000 (15:50 -0500)
committerW. Trevor King <wking@drexel.edu>
Wed, 30 Nov 2011 20:50:18 +0000 (15:50 -0500)
dotfiles.sh

index 2f814faa818bdc3b8152e6ef388241d36940874e..cb9dc368828d16b2525ad15835101329552db3bb 100755 (executable)
@@ -26,6 +26,10 @@ WGET=$(which wget)
 #####
 # Utility functions
 
+BASH="${BASH_VERSION%.*}"
+BASH_MAJOR="${BASH%.*}"
+BASH_MINOR="${BASH#*.}"
+
 # usage: nonempty_option LOC NAME VALUE
 function nonempty_option()
 {
@@ -139,6 +143,12 @@ function get_repo_source()
 
 function wget_fetch()
 {
+       if [ "${BASH_MAJOR}" -lt 4 ]; then
+               echo "ERROR: ${0} requires Bash version >= 4.0 for wget support" >&2
+               echo "you're running ${BASH}, which doesn't support associative arrays" >&2
+               return 1
+       fi
+
        REPO=$(nonempty_option 'wget_fetch' 'REPO' "${1}") || return 1
        # get_repo_source() was just called on this repo in fetch()
        TRANSFER=$(nonempty_option 'wget_fetch' 'TRANSFER' "${REPO_SOURCE_DATA['transfer']}") || return 1