Skip to content

Commit 2ac6837

Browse files
authored
fix "invalid number" errors (fix #40) (#41)
1 parent a63133c commit 2ac6837

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ticker.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ for symbol in $(IFS=' '; echo "${SYMBOLS[*]}" | tr '[:lower:]' '[:upper:]'); do
7272
preMarketChange="$(query $symbol 'preMarketChange')"
7373
postMarketChange="$(query $symbol 'postMarketChange')"
7474

75-
if [ $marketState == "PRE" ] \
75+
if [ $marketState = "PRE" ] \
7676
&& [ $preMarketChange != "0" ] \
7777
&& [ $preMarketChange != "null" ]; then
7878
nonRegularMarketSign='*'
@@ -93,7 +93,11 @@ for symbol in $(IFS=' '; echo "${SYMBOLS[*]}" | tr '[:lower:]' '[:upper:]'); do
9393
percent=$(query $symbol 'regularMarketChangePercent')
9494
fi
9595

96-
if [ "$diff" == "0" ] || [ "$diff" == "0.0" ]; then
96+
# see https://github.com/pstadler/ticker.sh/issues/40
97+
[ "$diff" = "null" ] && diff="0.0"
98+
[ "$percent" = "null" ] && percent="0.0"
99+
100+
if [ "$diff" = "0" ] || [ "$diff" = "0.0" ]; then
97101
color=
98102
elif ( echo "$diff" | grep -q ^- ); then
99103
color=$COLOR_RED

0 commit comments

Comments
 (0)