diff --git a/container/src/finance/lib/internal/lib_fetch.bash b/container/src/finance/lib/internal/lib_fetch.bash index b42c16f..06a7a49 100644 --- a/container/src/finance/lib/internal/lib_fetch.bash +++ b/container/src/finance/lib/internal/lib_fetch.bash @@ -669,8 +669,8 @@ function lib_fetch::__fetch_price() for _api in "${global_arg_api[@]}"; do - if ! lib_fetch::__parse_yaml "get-value" "price.${_api}" &>/dev/null; then - lib_utils::print_warning "'${_api}' price API is not set" + if [[ $(lib_fetch::__parse_yaml "get-value" "price.${_api}" 2>/dev/null) == "null" ]]; then + lib_utils::print_warning "price.${_api} is not set" continue fi @@ -682,15 +682,17 @@ function lib_fetch::__fetch_price() case "$_member" in key) - [[ "$_value" == "null" ]] && lib_utils::print_warning "${_api} has empty ${_member}" + if [[ "$_value" == "null" ]]; then + lib_utils::print_warning "price.${_api}.${_member} is not set" + fi ;; asset) - if ! lib_fetch::__parse_yaml "get-value" "price.${_api}.${_member}" | grep -q "^- "; then - lib_utils::die_fatal "Invalid asset sequence!" + if [[ "$_value" =~ (^null$|^[^- ]) ]]; then + lib_utils::die_fatal "${_api} has invalid asset sequence" fi ;; *) - lib_utils::die_fatal "${_api} has invalid member: ${_member}" + lib_utils::die_fatal "price.${_api}.${_member} is invalid" ;; esac