summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Stadler <patrick.stadler@gmail.com>2023-06-01 11:22:48 +0200
committerGitHub <noreply@github.com>2023-06-01 11:22:48 +0200
commit2ac6837f5275682bf63bd75dd9ef7b4a9ac20a3e (patch)
tree81c5df9b18ae4aed26068bb3872460f8c6f4f017
parenta63133cae11a7bdc7de8612eadc7ce118b7781b7 (diff)
fix "invalid number" errors (fix #40) (#41)
-rwxr-xr-xticker.sh8
1 files 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