Closed yadaniel closed 3 years ago
carrige return seems to be attached to variables somehow space seems to work in the script but not on command line
price=${price%%'\r'} diff=${diff%%'\r'} percent=${percent%%'\r'}
Which operating system / shell are you using?
I am using cygwin and my shell is bash $ echo $BASH_VERSION 4.4.12(3)-release
Here is the output.
$ ./ticker.sh MSFT : Ungültige Zahl.ile 81: printf: 213.98 MSFT 0.00
81 is the line with printf "%-10s$COLOR_BOLD%8.2f$COLOR_RESET" $symbol $price 213.98 comes from price
when I add debug option set -x
So, '\r' probably gets fetched from request and gets even interpreted by printf. Don't know why '$' appears in '[' $'213.98\r' '!=' null ']'
price=${price%%[[:space:]]} Somehow [[:space:]] works in script robust
price=${price%%'\r'} Somehow this does not work in script any more :)
I am just a bash user, possible that I have mixed something up.
floating point conversion with printf seems to blow up when there are trailing spaces in variables I added 3 lines to the script and it works fine now. Thank you for the script.
else nonRegularMarketSign='' price=$(query $symbol 'regularMarketPrice') diff=$(query $symbol 'regularMarketChange') percent=$(query $symbol 'regularMarketChangePercent') fi