To support Macs which have a 5 year old bash, don't use associative arrays

This commit is contained in:
Eric Paris 2014-10-02 12:06:48 -04:00
parent d3816069e6
commit 707e6ac561

View File

@ -119,17 +119,14 @@ _kubecfg()
-h -h
-c -c
) )
local -A all_services=( local create_services=(pods replicationControllers services)
[CREATE]="pods replicationControllers services" local update_services=(replicationControllers)
[UPDATE]="replicationControllers" local all_services=(pods replicationControllers services minions)
[ALL]="pods replicationControllers services minions" local services=("${all_services[@]}")
)
local services=(${all_services[ALL]}) local json_commands=(create update)
local -A all_commands=( local all_commands=(create update get list delete stop rm rollingupdate resize)
[WITH_JSON]="create update" local commands=("${all_commands[@]}")
[ALL]="create update get list delete stop rm rollingupdate resize"
)
local commands=(${all_commands[ALL]})
COMPREPLY=() COMPREPLY=()
local command local command
@ -155,8 +152,8 @@ _kubecfg()
# if you passed -c, you are limited to create or update # if you passed -c, you are limited to create or update
if __contains_word "-c" "${words[@]}"; then if __contains_word "-c" "${words[@]}"; then
services=(${all_services[CREATE]} ${all_services[UPDATE]}) services=("${create_services[@]}" "${update_services[@]}")
commands=(${all_commands[WITH_JSON]}) commands=("${json_commands[@]}")
fi fi
# figure out which command they are running, remembering that arguments to # figure out which command they are running, remembering that arguments to
@ -179,9 +176,9 @@ _kubecfg()
# remove services which you can't update given your command # remove services which you can't update given your command
if [[ ${command} == "create" ]]; then if [[ ${command} == "create" ]]; then
services=(${all_services[CREATE]}) services=("${create_services[@]}")
elif [[ ${command} == "update" ]]; then elif [[ ${command} == "update" ]]; then
services=(${all_services[UPDATE]}) services=("${update_services[@]}")
fi fi
case $command in case $command in