From cd5ef0816f76abb67a5ef2b8ae2c3e37a7b367c9 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 30 Nov 2011 15:50:18 -0500 Subject: [PATCH] Raise an error if the user tries to use wget-based repos with Bash < 4.0. --- dotfiles.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 -- 2.26.2