16
16
17
17
[[ -z $CS_DEBUG ]] && CS_DEBUG=0
18
18
SSH_CONFIG=" $HOME /.ssh/config"
19
- VERSION=" v1.7"
20
- # set -o errexit
21
- # set -o nounset
22
- # set -o pipefail
23
-
24
- # Determine the shell that the script is being run from
25
- # if [[ "$SHELL" == "/bin/zsh" ]]; then
26
- # Zsh is running, set offset to 1
27
- # offset=1
28
- # else
29
- # Bash is running, set offset to 0
30
- offset=0
31
- # fi
19
+ VERSION=" v1.8"
20
+ # ensure brace expansion is on for the shell
21
+ set -o braceexpand && [[ $CS_DEBUG -eq 1 ]] && set -o && echo " $SHELL "
22
+ # ensure Zsh uses zero-based arrays
23
+ [[ " $SHELL " == " /bin/zsh" ]] && zsh -c ' emulate -LR zsh; setopt ksharrays; setopt' && [[ $CS_DEBUG -eq 1 ]] && echo " $SHELL "
32
24
33
25
# -------------------------- LIBRARIES
34
26
@@ -63,7 +55,7 @@ lib-error-check() {
63
55
local error_message=" ${2:- } "
64
56
if (( exit_code != 0 )) ; then
65
57
lib-debug
66
- if [ -n " $error_message " ]; then
58
+ if [[ -n " $error_message " ] ]; then
67
59
lib-msg " exit code: $exit_code , from: $error_message "
68
60
fi
69
61
exit " $exit_code "
@@ -72,10 +64,10 @@ lib-error-check() {
72
64
73
65
# display debug info
74
66
lib-debug () {
75
- if [ -n " $ZSH_VERSION " ]; then
76
- lib-msg " ${funcstack[$offset+ 1]} (${funcline[$offset ]} ) - ARGS: $* "
67
+ if [[ " $SHELL " == " /bin/zsh " ] ]; then
68
+ lib-msg " ${funcstack[1]} (${funcline[0 ]} ) - ARGS: $* "
77
69
else
78
- lib-msg " ${FUNCNAME[$offset+ 1]} (${BASH_LINENO[$offset ]} ) - ARGS: $* "
70
+ lib-msg " ${FUNCNAME[1]} (${BASH_LINENO[0 ]} ) - ARGS: $* "
79
71
fi
80
72
}
81
73
@@ -221,7 +213,7 @@ eks-clusters() {
221
213
instanceType=$( echo " $node_group_info " | jq -r ' .instanceType' )
222
214
version=$( echo " $node_group_info " | jq -r ' .version' )
223
215
224
- [[ $CS_DEBUG == 1 ]] && echo " $node_group_info "
216
+ [[ $CS_DEBUG -eq 1 ]] && echo " $node_group_info "
225
217
cs-print-row " $cluster_name " " $cluster_status " " $node_group_name " " $node_group_status " " $min_size " " $max_size " " $desired_size " " $type " " $instanceType " " $version "
226
218
done
227
219
done
@@ -542,9 +534,10 @@ cs-ec2-go() {
542
534
543
535
# capture input array
544
536
userCommand=(" $@ " ) || lib-error-check 1 " Error executing user command: ${userCommand[*]} "
537
+ [[ $CS_DEBUG -eq 1 ]] && echo " $@ " && echo " ${userCommand[0]} " && exit 0
545
538
546
- for c in ${userCommand[$offset ]} ; do
547
- [[ $CS_DEBUG == 1 ]] && echo " $c "
539
+ for c in ${userCommand[0 ]} ; do
540
+ [[ $CS_DEBUG -eq 1 ]] && echo " $c "
548
541
if [[ $c == " -v" ]] || [[ $c == " --version" ]]; then
549
542
cs-version $VERSION
550
543
elif [[ $c == " --help" ]]; then
0 commit comments