Created
July 6, 2017 14:53
-
-
Save superbrothers/0ede4292f6d973f93e54368e227a4902 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env zsh | |
| set -e | |
| __handle_flag() { | |
| local flagname="--namespace=" | |
| local flagval="kube-system" | |
| flaghash[${flagname}]=${flagval} | |
| echo "flaghash[${flagname}]=${flaghash[${flagname}]}" | |
| } | |
| __handle_word() { | |
| __handle_flag | |
| } | |
| __start_kubectl() { | |
| builtin declare -A flaghash | |
| __handle_word | |
| } | |
| __start_kubectl | |
| # | |
| # $ zsh fixed.zsh | |
| # flaghash[--namespace=]=kube-system | |
| # | |
| # __start_kubectl { | |
| # | |
| # builtin declare -A flaghash | |
| # | |
| # __handle_word { | |
| # | |
| # __handle_flag { | |
| # | |
| # # Being able to access flaghash declared in __start_kubectl from here | |
| # flaghash[${flagname}]=${flagval} | |
| # | |
| # } | |
| # | |
| # } | |
| # } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env zsh | |
| set -e | |
| __kubectl_declare() { | |
| builtin declare "$@" | |
| } | |
| __handle_flag() { | |
| local flagname="--namespace=" | |
| local flagval="kube-system" | |
| flaghash[${flagname}]=${flagval} | |
| echo "flaghash[${flagname}]=${flaghash[${flagname}]}" | |
| } | |
| __handle_word() { | |
| __handle_flag | |
| } | |
| __start_kubectl() { | |
| __kubectl_declare -A flaghash | |
| __handle_word | |
| } | |
| __start_kubectl | |
| # | |
| # $ zsh reproduction.zsh | |
| # __handle_flag:4: bad math expression: operand expected at end of string | |
| # | |
| # __start_kubectl { | |
| # | |
| # __kubectl_declare { | |
| # | |
| # builtin declare -A flaghash | |
| # | |
| # } | |
| # | |
| # __handle_word { | |
| # | |
| # __handle_flag { | |
| # | |
| # # Not being able to access flaghash declared in __kubectl_declare from here | |
| # flaghash[${flagname}]=${flagval} | |
| # | |
| # } | |
| # | |
| # } | |
| # } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment