diff options
author | Patrick Stadler <patrick.stadler@gmail.com> | 2023-06-01 11:22:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-01 11:22:48 +0200 |
commit | 2ac6837f5275682bf63bd75dd9ef7b4a9ac20a3e (patch) | |
tree | 81c5df9b18ae4aed26068bb3872460f8c6f4f017 | |
parent | a63133cae11a7bdc7de8612eadc7ce118b7781b7 (diff) |
fix "invalid number" errors (fix #40) (#41)
-rwxr-xr-x | ticker.sh | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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 |