From d977d89f9121212e42516b328d2992f9dfd45aef Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 12 Dec 2012 12:24:11 +0000 Subject: [PATCH] Add comments to array hack in gvm script. For zsh compatibility. --- src/main/resources/scripts/gvm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/resources/scripts/gvm b/src/main/resources/scripts/gvm index 2fc3075b..41a9eecc 100755 --- a/src/main/resources/scripts/gvm +++ b/src/main/resources/scripts/gvm @@ -289,9 +289,14 @@ function __gvmtool_current { echo "Not using any version of ${CANDIDATE}" fi else + # The candidates are assigned to an array for zsh compliance, a list of words is not iterable + # Arrays are the only way, but unfortunately zsh arrays are not backward compatible with bash + # In bash arrays are zero index based, in zsh they are 1 based(!) CANDIDATES=($(curl -s "${GVM_SERVICE}/candidates" | tr -d ",")) INSTALLED_COUNT=0 + # The starts at 0 for bash, ends at the candidates array size for zsh for (( i=0; i <= ${#CANDIDATES}; i++ )); do + # Eliminate empty entries due to incompatibility if [[ -n ${CANDIDATES[$i]} ]]; then __gvmtool_determine_current_version "${CANDIDATES[$i]}" if [ -n "${CURRENT}" ]; then