From: W. Trevor King Date: Wed, 30 Nov 2011 20:50:18 +0000 (-0500) Subject: Raise an error if the user tries to use wget-based repos with Bash < 4.0. X-Git-Tag: v0.3~32 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cd5ef0816f76abb67a5ef2b8ae2c3e37a7b367c9;p=dotfiles-framework.git Raise an error if the user tries to use wget-based repos with Bash < 4.0. --- diff --git a/dotfiles.sh b/dotfiles.sh index 2f814fa..cb9dc36 100755 --- a/dotfiles.sh +++ b/dotfiles.sh @@ -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