From 2ac6837f5275682bf63bd75dd9ef7b4a9ac20a3e Mon Sep 17 00:00:00 2001 From: Patrick Stadler Date: Thu, 1 Jun 2023 11:22:48 +0200 Subject: [PATCH] fix "invalid number" errors (fix #40) (#41) --- ticker.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ticker.sh b/ticker.sh index b5059f5..f2ffe6c 100755 --- a/ticker.sh +++ b/ticker.sh @@ -72,7 +72,7 @@ for symbol in $(IFS=' '; echo "${SYMBOLS[*]}" | tr '[:lower:]' '[:upper:]'); do preMarketChange="$(query $symbol 'preMarketChange')" postMarketChange="$(query $symbol 'postMarketChange')" - if [ $marketState == "PRE" ] \ + if [ $marketState = "PRE" ] \ && [ $preMarketChange != "0" ] \ && [ $preMarketChange != "null" ]; then nonRegularMarketSign='*' @@ -93,7 +93,11 @@ for symbol in $(IFS=' '; echo "${SYMBOLS[*]}" | tr '[:lower:]' '[:upper:]'); do percent=$(query $symbol 'regularMarketChangePercent') fi - if [ "$diff" == "0" ] || [ "$diff" == "0.0" ]; then + # see https://github.com/pstadler/ticker.sh/issues/40 + [ "$diff" = "null" ] && diff="0.0" + [ "$percent" = "null" ] && percent="0.0" + + if [ "$diff" = "0" ] || [ "$diff" = "0.0" ]; then color= elif ( echo "$diff" | grep -q ^- ); then color=$COLOR_RED