diff --git a/mc b/mc index ad34d56..bb69eda 100755 --- a/mc +++ b/mc @@ -137,18 +137,20 @@ function usage() { } function call_api() { + local command="$1" + local args=("${@}") # remove command from arg list while preserving quoted strings. - local args=("${ARGS[@]:1}") + local args=("${args[@]:1}") # Check if key does NOT exists in command array - if [[ ! -v commands[$1] ]]; then + if [[ ! -v commands[$command] ]]; then printf "${0}: invalid option -- $1\n\n" usage exit 1 fi local endpoint method body description - read -r endpoint method body description <<<"${commands[$1]}" + read -r endpoint method body description <<<"${commands[$command]}" case "${method}" in "POST")